Package org.semanticweb.owlapi.model

Examples of org.semanticweb.owlapi.model.OWLDatatypeRestriction


    @Test
    public void shouldBuildDatatypeRestriction() {
        // given
        OWLFacetRestriction r = df.getOWLFacetRestriction(OWLFacet.MAX_LENGTH,
                lit);
        OWLDatatypeRestriction expected = df.getOWLDatatypeRestriction(d, r);
        BuilderDatatypeRestriction builder = new BuilderDatatypeRestriction(
                expected, df);
        // when
        OWLObject built = builder.buildObject();
        // then
View Full Code Here


        // restrict the xsd:integer datatype using the xsd:minInclusive facet
        // with a value of 18. Get hold of a literal that is an integer value 18
        OWLLiteral eighteen = factory.getOWLLiteral(18);
        // Now create the restriction. The OWLFacet enum provides an enumeration
        // of the various facets that can be used
        OWLDatatypeRestriction integerGE18 = factory.getOWLDatatypeRestriction(
                integer, MIN_INCLUSIVE, eighteen);
        // We could use this datatype in restriction, as the range of data
        // properties etc. For example, if we want to restrict the range of the
        // :hasAge data property to 18 or more we specify its range as this data
        // range
        PrefixManager pm = new DefaultPrefixManager(null, null,
                "http://www.semanticweb.org/ontologies/dataranges#");
        OWLDataProperty hasAge = factory.getOWLDataProperty(":hasAge", pm);
        OWLDataPropertyRangeAxiom rangeAxiom = factory
                .getOWLDataPropertyRangeAxiom(hasAge, integerGE18);
        OWLOntology ontology = manager.createOntology(IRI
                .create("http://www.semanticweb.org/ontologies/dataranges"));
        // Add the range axiom to our ontology
        manager.addAxiom(ontology, rangeAxiom);
        // For creating datatype restrictions on integers or doubles there are
        // some convenience methods on OWLDataFactory For example: Create a data
        // range of integers greater or equal to 60
        OWLDatatypeRestriction integerGE60 = factory
                .getOWLDatatypeMinInclusiveRestriction(60);
        // Create a data range of integers less than 16
        OWLDatatypeRestriction integerLT16 = factory
                .getOWLDatatypeMaxExclusiveRestriction(18);
        // In OWL 2 it is possible to represent the intersection, union and
        // complement of data types For example, we could create a union of data
        // ranges of the data range integer less than 16 or integer greater or
        // equal to 60
View Full Code Here

    @Test
    public void testCreationDataRange() {
        OWLDatatype rng = D(IRI());
        OWLLiteral facetValue = testSubject.getOWLLiteral("3", D(IRI()));
        OWLDatatypeRestriction restRng = testSubject.getOWLDatatypeRestriction(
                rng,
                testSubject.getOWLFacetRestriction(MAX_EXCLUSIVE, facetValue));
        assertNotNull(restRng);
    }
View Full Code Here

    @Test
    public void testEqualsPositiveDataRange() {
        OWLDatatype rng = D(IRI());
        OWLLiteral facetValue = testSubject.getOWLLiteral("3", D(IRI()));
        OWLDatatypeRestriction restRngA = testSubject
                .getOWLDatatypeRestriction(rng, testSubject
                        .getOWLFacetRestriction(MAX_EXCLUSIVE, facetValue));
        OWLDatatypeRestriction restRngB = testSubject
                .getOWLDatatypeRestriction(rng, testSubject
                        .getOWLFacetRestriction(MAX_EXCLUSIVE, facetValue));
        assertEquals(restRngA, restRngB);
    }
View Full Code Here

    @Test
    public void testEqualsNegativeDataRange() {
        OWLDatatype rng = D(IRI());
        OWLLiteral facetValue = testSubject.getOWLLiteral("3", D(IRI()));
        OWLDatatypeRestriction restRngA = testSubject
                .getOWLDatatypeRestriction(rng, testSubject
                        .getOWLFacetRestriction(MAX_EXCLUSIVE, facetValue));
        OWLDatatypeRestriction restRngB = testSubject
                .getOWLDatatypeRestriction(rng, testSubject
                        .getOWLFacetRestriction(MIN_INCLUSIVE, facetValue));
        assertFalse(restRngA.equals(restRngB));
    }
View Full Code Here

    @Test
    public void testHashCodeDataRange() {
        OWLDatatype rng = D(IRI());
        OWLLiteral facetValue = testSubject.getOWLLiteral("3", D(IRI()));
        OWLDatatypeRestriction restRngA = testSubject
                .getOWLDatatypeRestriction(rng, testSubject
                        .getOWLFacetRestriction(MAX_EXCLUSIVE, facetValue));
        OWLDatatypeRestriction restRngB = testSubject
                .getOWLDatatypeRestriction(rng, testSubject
                        .getOWLFacetRestriction(MAX_EXCLUSIVE, facetValue));
        assertEquals(restRngA.hashCode(), restRngB.hashCode());
    }
View Full Code Here

        // The top datatype is rdfs:Literal
        OWLDatatype rdfsLiteral = df.getTopDatatype();
        // Custom data ranges can be built up from these basic datatypes
        // Get hold of a literal that is an integer value 18
        OWLLiteral eighteen = df.getOWLLiteral(18);
        OWLDatatypeRestriction integerGE18 = df.getOWLDatatypeRestriction(
                integer, OWLFacet.MIN_INCLUSIVE, eighteen);
        OWLDataProperty hasAge = df
                .getOWLDataProperty(IRI
                        .create("http://www.semanticweb.org/ontologies/dataranges#hasAge"));
        OWLDataPropertyRangeAxiom rangeAxiom = df.getOWLDataPropertyRangeAxiom(
View Full Code Here

                        problems.add("Axiom " + e + " will be ignored because of the unsupported literal.");
                    }
                } else if(range instanceof OWLDatatypeRestriction) {
                    NamedFeature f = new NamedFeature(dp.toStringID());
                   
                    OWLDatatypeRestriction dtr = (OWLDatatypeRestriction)range;
                    Set<OWLFacetRestriction> frs = dtr.getFacetRestrictions();
                   
                    List<Datatype> conjuncts = new ArrayList<Datatype>();
                    for(OWLFacetRestriction fr : frs) {
                        OWLLiteral l = fr.getFacetValue();
                       
View Full Code Here

  public boolean equals(Object obj) {
        if (super.equals(obj)) {
            if (!(obj instanceof OWLDatatypeRestriction)) {
                return false;
            }
            OWLDatatypeRestriction other = (OWLDatatypeRestriction) obj;
            return other.getDatatype().equals(datatype) && other.getFacetRestrictions().equals(facetRestrictions);
        }
        return false;
    }
View Full Code Here

        return visitor.visit(this);
    }

    @Override
  protected int compareObjectOfSameType(OWLObject object) {
        OWLDatatypeRestriction other = (OWLDatatypeRestriction) object;
        int diff = datatype.compareTo(other.getDatatype());
        if (diff != 0) {
            return diff;
        }
        return compareSets(facetRestrictions, other.getFacetRestrictions());
    }
View Full Code Here

TOP

Related Classes of org.semanticweb.owlapi.model.OWLDatatypeRestriction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.