/** * <p>Answer true if this resource can be viewed as an 'all different' declaration</p> * @return True if this resource can be viewed as an AllDifferent node */ @Override public boolean isAllDifferent() { return getProfile().ALL_DIFFERENT() != null && canAs( AllDifferent.class ); }
/** * <p>Remove the statement that this restriction has all values from the given class among * the values for the restricted property. If this statement * is not true of the current model, nothing happens.</p> * @param cls A Resource the denotes the class to be removed from this restriction */ @Override public void removeAllValuesFrom( Resource cls ) { removePropertyValue( getProfile().ALL_VALUES_FROM(), "ALL_VALUES_FROM", cls ); }
/** * <p>Answer true if this resource can be viewed as an annotation property</p> * @return True if this resource can be viewed as an AnnotationProperty */ @Override public boolean isAnnotationProperty() { return getProfile().ANNOTATION_PROPERTY() != null && canAs( AnnotationProperty.class ); }
@Override public boolean canWrap( Node node, EnhGraph eg ) { // node will support being an ComplementClass facet if it has rdf:type owl:Class and an owl:complementOf statement (or equivalents) Profile profile = (eg instanceof OntModel) ? ((OntModel) eg).getProfile() : null; Property comp = (profile == null) ? null : profile.COMPLEMENT_OF(); return (profile != null) && profile.isSupported( node, eg, OntClass.class ) && comp != null && eg.asGraph().contains( node, comp.asNode(), Node.ANY ); } };
/** * <p>Answer a resource representing the class that is the complement of the given argument class</p> * @param uri The URI of the new complement class, or null for an anonymous class description. * @param cls Resource denoting the class that the new class is a complement of * @return A complement class */ @Override public ComplementClass createComplementClass( String uri, Resource cls ) { checkProfileEntry( getProfile().CLASS(), "CLASS" ); OntClass c = createOntResource( OntClass.class, getProfile().CLASS(), uri ); checkProfileEntry( getProfile().COMPLEMENT_OF(), "COMPLEMENT_OF" ); // if the class that this class is a complement of is not specified, use owl:nothing or daml:nothing c.addProperty( getProfile().COMPLEMENT_OF(), (cls == null) ? getProfile().NOTHING() : cls ); return c.as( ComplementClass.class ); }
/** * <p>Answer a data range defined as the given set of concrete data values. DataRange resources * are necessarily bNodes.</p> * * @param literals An iterator over a set of literals that will be the members of the data range, * or null to define an empty data range * @return A new data range containing the given literals as permissible values */ @Override public DataRange createDataRange( RDFList literals ) { checkProfileEntry( getProfile().DATARANGE(), "DATARANGE" ); DataRange d = createOntResource( DataRange.class, getProfile().DATARANGE(), null ); checkProfileEntry( getProfile().ONE_OF(), "ONE_OF" ); d.addProperty( getProfile().ONE_OF(), (literals == null) ? createList() : literals ); return d; }
Profile prof = mOnt.getProfile(); ExtendedIterator<Statement> pi = mOnt.listStatements( null, RDF.type, getProfile().PROPERTY() ); if (prof.OBJECT_PROPERTY() != null) { pi = pi.andThen( mOnt.listStatements( null, RDF.type, prof.OBJECT_PROPERTY() ) ); if (prof.DATATYPE_PROPERTY() != null) { pi = pi.andThen( mOnt.listStatements( null, RDF.type, prof.DATATYPE_PROPERTY() ) ); if (prof.FUNCTIONAL_PROPERTY() != null) { pi = pi.andThen( mOnt.listStatements( null, RDF.type, prof.FUNCTIONAL_PROPERTY() ) ); if (prof.INVERSE_FUNCTIONAL_PROPERTY() != null) { pi = pi.andThen( mOnt.listStatements( null, RDF.type, prof.INVERSE_FUNCTIONAL_PROPERTY() ) ); if (prof.SYMMETRIC_PROPERTY() != null) { pi = pi.andThen( mOnt.listStatements( null, RDF.type, prof.SYMMETRIC_PROPERTY() ) ); if (prof.TRANSITIVE_PROPERTY() != null) { pi = pi.andThen( mOnt.listStatements( null, RDF.type, prof.TRANSITIVE_PROPERTY() ) ); if (prof.ANNOTATION_PROPERTY() != null) { pi = pi.andThen( mOnt.listStatements( null, RDF.type, prof.ANNOTATION_PROPERTY() ) );
/** * <p>Answer a class description defined as the class of those individuals that have exactly * the given number of values for the given property, all values of which belong to the given * class.</p> * * @param uri The optional URI for the restriction, or null for an anonymous restriction (which * should be the normal case) * @param prop The property the restriction applies to * @param cardinality The cardinality of the property * @param cls The class to which all values of the restricted property should belong * @return A new resource representing a mas-cardinality restriction */ @Override public CardinalityQRestriction createCardinalityQRestriction( String uri, Property prop, int cardinality, OntClass cls ) { checkProfileEntry( getProfile().RESTRICTION(), "RESTRICTION" ); checkProfileEntry( getProfile().ON_PROPERTY(), "ON_PROPERTY" ); checkProfileEntry( getProfile().CARDINALITY_Q(), "CARDINALITY_Q" ); checkProfileEntry( getProfile().HAS_CLASS_Q(), "HAS_CLASS_Q" ); if (prop == null) { throw new IllegalArgumentException( "Cannot create CardinalityQRestriction with a null property" ); } if (cls == null) { throw new IllegalArgumentException( "Cannot create CardinalityQRestriction with a null class" ); } Restriction r = createOntResource( Restriction.class, getProfile().RESTRICTION(), uri ); r.addProperty( getProfile().ON_PROPERTY(), prop ); r.addProperty( getProfile().CARDINALITY_Q(), createTypedLiteral( cardinality ) ); r.addProperty( getProfile().HAS_CLASS_Q(), cls ); return r.as( CardinalityQRestriction.class ); }
/** * <p>Answer a class description defined as the class of those individuals that have exactly * the given number of values for the given property.</p> * * @param uri The optional URI for the restriction, or null for an anonymous restriction (which * should be the normal case) * @param prop The property the restriction applies to * @param cardinality The exact cardinality of the property * @return A new resource representing a has-value restriction */ @Override public CardinalityRestriction createCardinalityRestriction( String uri, Property prop, int cardinality ) { checkProfileEntry( getProfile().RESTRICTION(), "RESTRICTION" ); Restriction r = createOntResource( Restriction.class, getProfile().RESTRICTION(), uri ); if (prop == null) { throw new IllegalArgumentException( "Cannot create cardinalityRestriction with a null property" ); } checkProfileEntry( getProfile().CARDINALITY(), "CARDINALITY" ); r.addProperty( getProfile().ON_PROPERTY(), prop ); r.addProperty( getProfile().CARDINALITY(), createTypedLiteral( cardinality ) ); return r.as( CardinalityRestriction.class ); }
/** * <p>Answer a class description defined as the class of those individuals for which all values * of the given property belong to the given class</p> * * @param uri The optional URI for the restriction, or null for an anonymous restriction (which * should be the normal case) * @param prop The property the restriction applies to * @param cls The class to which any value of the property belongs * @return A new resource representing an all-values-from restriction */ @Override public AllValuesFromRestriction createAllValuesFromRestriction( String uri, Property prop, Resource cls ) { checkProfileEntry( getProfile().RESTRICTION(), "RESTRICTION" ); Restriction r = createOntResource( Restriction.class, getProfile().RESTRICTION(), uri ); if (prop == null || cls == null) { throw new IllegalArgumentException( "Cannot create allValuesFromRestriction with a null property or class" ); } checkProfileEntry( getProfile().ALL_VALUES_FROM(), "ALL_VALUES_FROM" ); r.addProperty( getProfile().ON_PROPERTY(), prop ); r.addProperty( getProfile().ALL_VALUES_FROM(), cls ); return r.as( AllValuesFromRestriction.class ); }
/** * <p>Answer the property that is used to construct this boolean expression, for example * {@link Profile#UNION_OF()}.</p> * @return {@link Profile#COMPLEMENT_OF()} */ @Override public Property operator() { return getProfile().COMPLEMENT_OF(); }
/** * <p>Answer a resource representing the class that is the intersection of the given list of class descriptions.</p> * @param uri The URI of the new intersection class, or null for an anonymous class description. * @param members A list of resources denoting the classes that comprise the intersection * @return An intersection class description */ @Override public IntersectionClass createIntersectionClass( String uri, RDFList members ) { checkProfileEntry( getProfile().CLASS(), "CLASS" ); OntClass c = createOntResource( OntClass.class, getProfile().CLASS(), uri ); checkProfileEntry( getProfile().INTERSECTION_OF(), "INTERSECTION_OF" ); c.addProperty( getProfile().INTERSECTION_OF(), (members == null) ? createList() : members ); return c.as( IntersectionClass.class ); }
/** * <p>Answer a resource representing the class that is the enumeration of the given list of individuals</p> * @param uri The URI of the new enumeration class, or null for an anonymous class description. * @param members An optional list of resources denoting the individuals in the enumeration * @return An enumeration class */ @Override public EnumeratedClass createEnumeratedClass( String uri, RDFList members ) { checkProfileEntry( getProfile().CLASS(), "CLASS" ); OntClass c = createOntResource( OntClass.class, getProfile().CLASS(), uri ); checkProfileEntry( getProfile().ONE_OF(), "ONE_OF" ); c.addProperty( getProfile().ONE_OF(), (members == null) ? createList() : members ); return c.as( EnumeratedClass.class ); }
/** * <p>Answer a resource representing the class that is the union of the given list of class desctiptions</p> * @param uri The URI of the new union class, or null for an anonymous class description. * @param members A list of resources denoting the classes that comprise the union * @return A union class description */ @Override public UnionClass createUnionClass( String uri, RDFList members ) { checkProfileEntry( getProfile().CLASS(), "CLASS" ); OntClass c = createOntResource( OntClass.class, getProfile().CLASS(), uri ); checkProfileEntry( getProfile().UNION_OF(), "UNION_OF" ); c.addProperty( getProfile().UNION_OF(), (members == null) ? createList() : members ); return c.as( UnionClass.class ); }
/** * <p>Add a resource representing an ontology that this ontology * (strictly, the ontology reprsented by this node) is backwards compatible with.</p> * @param res Represents a resource that this ontology is compatible with. * @exception OntProfileException If the {@link Profile#BACKWARD_COMPATIBLE_WITH} property is not supported in the current language profile. */ @Override public void addBackwardCompatibleWith( Resource res ) { addPropertyValue( getProfile().BACKWARD_COMPATIBLE_WITH(), "BACKWARD_COMPATIBLE_WITH", res ); }
/** * <p>Answer true if this restriction is a cardinality restriction (ie is a property restriction * constructed with an <code>owl:cardinality</code> operator, or similar). This is not a test for * a restriction that tests cardinalities in general.</p> * @return True if this is a cardinality property restriction * @exception ProfileException if {@link Profile#CARDINALITY()} is not supported in the current profile */ @Override public boolean isCardinalityRestriction() { checkProfile( getProfile().CARDINALITY(), "CARDINALITY" ); return hasProperty( getProfile().CARDINALITY() ); }
/** * <p>Remove the statement that the given string is a comment on * this resource. If this statement * is not true of the current model, nothing happens.</p> * @param comment A comment literal to be removed */ @Override public void removeComment( Literal comment ) { removePropertyValue( getProfile().COMMENT(), "COMMENT", comment ); }
/** * <p>Answer the cardinality of the restricted property.</p> * @return The cardinality of the restricted property * @exception OntProfileException If the {@link Profile#CARDINALITY_Q()} property is not supported in the current language profile. */ @Override public int getCardinalityQ() { return objectAsInt( getProfile().CARDINALITY_Q(), "CARDINALITY_Q" ); }
/** * <p>Answer true if this resource can be viewed as a data range</p> * @return True if this resource can be viewed as a DataRange */ @Override public boolean isDataRange() { return getProfile().DATARANGE() != null && canAs( DataRange.class ); }