/** * Answer a new ontology model constructed according to the specification, which includes * a ModelMaker which will create the necessary base model. */ public static OntModel createOntologyModel( OntModelSpec spec ) { return new OntModelImpl( spec ); }
@Override protected Model readDelegate( String url ) { acceptHeaderSet[0] = true; return super.readDelegate( url ); } };
/** * <p> * Add the given model as one of the sub-models of the enclosed ontology union model. * <strong>Note</strong> that if <code>model</code> is a composite model (i.e. an * {@link OntModel} or {@link InfModel}), the model and all of its submodels will * be added to the union of sub-models of this model. If this is <strong>not</strong> required, * callers should explicitly add only the base model: * </p> * <pre> * parent.addSubModel( child.getBaseModel() ); * </pre> * * @param model A sub-model to add */ @Override public void addSubModel( Model model) { addSubModel( model, true ); }
/** * <p> * Answer a resource that represents an anonymous class description in this model. A new * anonymous resource of <code>rdf:type C</code>, where C is the class type from the * language profile. * </p> * * @return An anonymous Class resource. */ @Override public OntClass createClass() { checkProfileEntry( getProfile().CLASS(), "CLASS" ); return createOntResource( OntClass.class, getProfile().CLASS(), null ); }
/** * <p>Answer a resource presenting the {@link OntResource} facet, which has the given * URI. If no such resource is currently present in the model, return null.</p> * @param uri The URI of a resource * @return An OntResource with the given URI, or null */ @Override public OntResource getOntResource( String uri ) { Resource r = getResource( uri ); if (containsResource( r )) { return r.as( OntResource.class ); } return null; }
/** * <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; }
/** * <p>Answer an iterator over the DataRange objects in this ontology, if there * are any.</p> * @return An iterator, whose values are {@link DataRange} objects. */ @Override public ExtendedIterator<DataRange> listDataRanges() { checkProfileEntry( getProfile().DATARANGE(), "DATARANGE" ); return findByTypeAs( getProfile().DATARANGE(), DataRange.class ) .filterKeep( new UniqueFilter<DataRange>()); }
public Model read( String uri, String base, String syntax ) { addLoadedImport( uri ); OntDocumentManager odm = getDocumentManager(); !ignoreFileURI( source ) && // and that negotiation makes sense (don't conneg to file:) readDelegate( source ); readDelegate( source, syntax ); readDelegate( source, (base == null ? uri : base), syntax ); getDocumentManager().addModel( uri, this ); loadImports(); rebind(); return this;
/** * <p> * Answer an iterator that ranges over the enumerated class class-descriptions * in this model, i.e. the class resources specified to have a property * <code>oneOf</code> (or equivalent) and a list of values. * </p> * <p> * <strong>Note:</strong> the number of nodes returned by this iterator will vary according to * the completeness of the deductive extension of the underlying graph. See class * overview for more details. * </p> * * @return An iterator over enumerated class resources. * @see Profile#ONE_OF */ @Override public ExtendedIterator<EnumeratedClass> listEnumeratedClasses() { checkProfileEntry( getProfile().ONE_OF(), "ONE_OF" ); return findByDefiningPropertyAs( getProfile().ONE_OF(), EnumeratedClass.class ) .filterKeep( new UniqueFilter<EnumeratedClass>()); }
/** * <p>Answer a class description defined as the class of those individuals that have at least * 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 minimum cardinality of the property * @return A new resource representing a min-cardinality restriction */ @Override public MinCardinalityRestriction createMinCardinalityRestriction( 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 minCardinalityRestriction with a null property" ); } checkProfileEntry( getProfile().MIN_CARDINALITY(), "MIN_CARDINALITY" ); r.addProperty( getProfile().ON_PROPERTY(), prop ); r.addProperty( getProfile().MIN_CARDINALITY(), createTypedLiteral( cardinality ) ); return r.as( MinCardinalityRestriction.class ); }
/** * <p> * Answer the base model of this model. The base model is the model wrapping * the graph that contains the triples read from the source document for this * ontology. It is therefore the model that will be updated if statements are * added to a model that is built from a union of documents (via the * <code>imports</code> statements in the source document). * </p> * * @return The base model for this ontology model */ @Override public Model getBaseModel() { return ModelFactory.createModelForGraph( getBaseGraph() ); }
/** Find all the statements matching a pattern. * <p>Return an iterator over all the statements in a model * that match a pattern. The statements selected are those * whose subject matches the <code>subject</code> argument, * whose predicate matches the <code>predicate</code> argument * and whose object matches the <code>object</code> argument. * If an argument is <code>null</code> it matches anything.</p> * <p> * The s/p/o terms may refer to resources which are temporarily defined in the "posit" model. * This allows one, for example, to query what resources are of type CE where CE is a * class expression rather than a named class - put CE in the posit arg.</p> * * @return an iterator over the subjects * @param subject The subject sought * @param predicate The predicate sought * @param object The value sought * @param posit Model containing additional assertions to be considered when matching statements */ @Override public StmtIterator listStatements( Resource subject, Property predicate, RDFNode object, Model posit ) { if (getGraph() instanceof InfGraph) { Graph gp = posit == null ? ModelFactory.createDefaultModel().getGraph() : posit.getGraph(); Iterator<Triple> iter = getInfGraph().find( asNode(subject), asNode(predicate), asNode(object), gp ); return IteratorFactory.asStmtIterator(iter,this); } else { return null; } }
ExtendedIterator<Graph> i = WrappedIterator.create( getSubGraphs().iterator() ); OntModel om = new OntModelImpl( m_spec, base, withImports ); return om; } );
/** * <p> * Answer a resource that represents datatype property in this model, and that is * not a functional property. * </p> * * @param uri The uri for the datatype property. May not be null. * @return A DatatypeProperty resource. * @see #createDatatypeProperty( String, boolean ) */ @Override public DatatypeProperty createDatatypeProperty( String uri ) { return createDatatypeProperty( uri, false ); }
/** * <p> * Answer a new, anonymous node representing the fact that a given set of classes are all * pair-wise distinct. <code>AllDifferent</code> is a feature of OWL only, and is something * of an anomaly in that it exists only to give a place to anchor the <code>distinctMembers</code> * property, which is the actual expression of the fact. * </p> * * @return A new AllDifferent resource */ @Override public AllDifferent createAllDifferent() { return createAllDifferent( null ); }
/** * <p> * Answer a resource that represents an anonymous class description in this model. A new * anonymous resource of <code>rdf:type C</code>, where C is the class type from the * language profile. * </p> * * @return An anonymous Class resource. */ @Override public OntClass createClass() { checkProfileEntry( getProfile().CLASS(), "CLASS" ); return createOntResource( OntClass.class, getProfile().CLASS(), null ); }
/** * <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 an iterator over the DataRange objects in this ontology, if there * are any.</p> * @return An iterator, whose values are {@link DataRange} objects. */ @Override public ExtendedIterator<DataRange> listDataRanges() { checkProfileEntry( getProfile().DATARANGE(), "DATARANGE" ); return findByTypeAs( getProfile().DATARANGE(), DataRange.class ) .filterKeep( new UniqueFilter<DataRange>()); }
public Model read( String uri, String base, String syntax ) { addLoadedImport( uri ); OntDocumentManager odm = getDocumentManager(); !ignoreFileURI( source ) && // and that negotiation makes sense (don't conneg to file:) readDelegate( source ); readDelegate( source, syntax ); readDelegate( source, (base == null ? uri : base), syntax ); getDocumentManager().addModel( uri, this ); loadImports(); rebind(); return this;
/** * <p> * Answer an iterator that ranges over the union class-descriptions * in this model, i.e. the class resources specified to have a property * <code>unionOf</code> (or equivalent) and a list of values. * </p> * <p> * <strong>Note:</strong> the number of nodes returned by this iterator will vary according to * the completeness of the deductive extension of the underlying graph. See class * overview for more details. * </p> * * @return An iterator over union class resources. * @see Profile#UNION_OF */ @Override public ExtendedIterator<UnionClass> listUnionClasses() { checkProfileEntry( getProfile().UNION_OF(), "UNION_OF" ); return findByDefiningPropertyAs( getProfile().UNION_OF(), UnionClass.class ) .filterKeep( new UniqueFilter<UnionClass>()); }