📄 ontmodelspec.java
字号:
/**
* Answer the model maker used for creating base models.
*/
public ModelMaker getBaseModelMaker() {
return super.getModelMaker();
}
public ModelGetter getImportModelGetter() {
if (importModelGetter == null) importModelGetter = m_importsMaker; // fabricateModelGetter();
return importModelGetter;
}
// private ModelGetter fabricateModelGetter()
// {
// return new ModelGetter()
// {
// public Model getModel( String URL )
// {
// return m_importsMaker.hasModel( URL ) ? m_importsMaker.openModel( URL ) : null;
// }
//
// public Model getModel( String URL, ModelReader loadIfAbsent )
// {
// return m_importsMaker.hasModel( URL ) ? m_importsMaker.openModel( URL ) : createAndLoad( URL, loadIfAbsent );
// }
//
// private Model createAndLoad( String URL, ModelReader loadIfAbsent )
// {
// Model result = m_importsMaker.createModel( URL );
// return loadIfAbsent.readModel( result, URL );
// }
// };
// }
public void setImportModelGetter( ModelGetter mg ) {
importModelGetter = mg;
}
/**
* <p>Initialise an OntModelSpec from an RDF description using the JenaModelSpec vocabulary. See
* <a href="../../../../../doc/howto/modelspec.html">the modelspec howto</a>
* for the description of the OntModel used. The root of the
* description is the unique resource with type <code>jms:OntMakerClass</code>.</p>
*
* @param description an RDF model using the JenaModelSpec vocabulary
*/
public OntModelSpec( Model description ) {
this( findRootByType( description, JenaModelSpec.OntModelSpec ), description );
}
/**
* <p>Initialise an OntModelSpec from an RDF description using the JenaModelSpec vocabulary. See
* <a href="../../../../../doc/howto/modelspec.html">the modelspec howto</a>
* for the description of the OntModel used. The root of the
* description is supplied as a parameter (so the description may describe several
* different OntModels).</p>
*
* @param description an RDF model using the JenaModelSpec vocabulary
* @param root the root of the sub-graph to use for the specification
*/
public OntModelSpec( Resource root, Model description ) {
this( getBaseModelName( description, root ),
getBaseMaker( description, root ),
getImportMaker( description, root ),
getDocumentManager( description, root ),
getReasonerFactory( description, root ),
getLanguage( description, root ) );
}
/**
* <p>Answer a default specification for the given language URI. This default
* will typically use a memory model and have minimal inferencing capabilities.
* Specifically, OWL and RDFS languages will have RDFS level inferencing
* capability (chosen to give a reasonable balance between power and efficiency
* of computation), and DAML language will have the minimal DAML rule reasoner.
* To get other (more powerful or less powerful) reasoning capabilities, users
* should create ontology models by passing an explicit <code>OntModelSpec</code>
* parameter to the
* {@link ModelFactory#createOntologyModel( OntModelSpec, Model ) model factory}.
* </p>
* @param languageURI The ontology language we want a default model spec for
* @return The default model spec for that language
* @exception OntologyException if the URI is not a recognised name of an ontology language
*/
public static OntModelSpec getDefaultSpec( String languageURI ) {
if (languageURI.equals( ProfileRegistry.OWL_LANG )) {
return OWL_MEM_RDFS_INF;
}
else if (languageURI.equals( ProfileRegistry.OWL_DL_LANG )) {
return OWL_DL_MEM_RDFS_INF;
}
else if (languageURI.equals( ProfileRegistry.OWL_LITE_LANG )) {
return OWL_LITE_MEM_RDFS_INF;
}
else if (languageURI.equals( ProfileRegistry.DAML_LANG )) {
return DAML_MEM_RULE_INF;
}
else if (languageURI.equals( ProfileRegistry.RDFS_LANG )) {
return RDFS_MEM_RDFS_INF;
}
else {
throw new OntologyException( "Did not recognise this language URI, so cannot determine default model spec: " + languageURI );
}
}
/**
* <p>Answer the document manager for this model specification. Defaults to
* a standard instance of {@link OntDocumentManager}</p>
* @return The document manager to be used by models matching this specification
*/
public OntDocumentManager getDocumentManager() {
if (m_docManager == null) {
// need to set the default document manager
m_docManager = OntDocumentManager.getInstance();
}
return m_docManager;
}
/**
* <p>Set the document manager in this specification</p>
* @param docMgr The new document manager
*/
public void setDocumentManager( OntDocumentManager docMgr ) {
m_docManager = docMgr;
}
/**
* <p>Set the model maker that will be used when the ontology model needs to create
* an additional container for an imported ontology</p>
* @param maker The new model maker to use
*/
public void setImportModelMaker( ModelMaker maker ) {
m_importsMaker = maker;
}
/**
* <p>Set the model maker used for imported models. OntModelSpecs now have
* separate model makers for imported and base models - use the correct
* one.</p>
*
* @deprecated use {@link #setImportModelMaker} or {@link #setBaseModelMaker}
*/
public void setModelMaker( ModelMaker m ) {
setImportModelMaker( m );
}
/**
* <p>Set the model maker used for base models.</p>
* @param m The model maker that is used to create the base model
* if one is not supplied when a model is created.
*/
public void setBaseModelMaker( ModelMaker m ) {
this.maker = m;
}
/**
* <p>Answer the reasoner that will be used to infer additional entailed
* triples in the ontology model.</p>
* @return The reasoner for this specification
*/
public Reasoner getReasoner() {
if (m_reasoner == null && m_rFactory != null) {
// we need to create the reasoner
// create a new one on each call since reasoners aren't guaranteed to be reusable
return m_rFactory.create( null );
}
return m_reasoner;
}
/**
* <p>Set the reasoner that will be used by ontology models that conform
* to this specification to compute entailments.
* <strong>Note:</strong> The reasoner is generated on demand by the reasoner
* factory. To prevent this spec from having a reasoner, set the reasoner factory
* to null, see {@link #setReasonerFactory}.
* </p>
* @param reasoner The new reasoner
*/
public void setReasoner( Reasoner reasoner ) {
m_reasoner = reasoner;
}
/**
* <p>Set the factory object that will be used to generate the reasoner object
* for this model specification. <strong>Note</strong> that the reasoner itself is cached, so setting
* the factory after a call to {@link #getReasoner()} will have no effect.</p>
* @param rFactory The new reasoner factory, or null to prevent any reasoner being used
*/
public void setReasonerFactory( ReasonerFactory rFactory ) {
m_rFactory = rFactory;
}
/**
* <p>Answer the current reasoner factory</p>
* @return The reasoner factory, or null.
*/
public ReasonerFactory getReasonerFactory() {
return m_rFactory;
}
/**
* <p>Answer the URI of the ontology lanuage to use when constructing
* models from this specification. Well known language URI's are
* available from the {@link ProfileRegistry}</p>
* @return The ontology language URI
*/
public String getLanguage() {
return m_languageURI;
}
/**
* <p>Set the URI of the ontology to use for models that conform to
* this specification.</p>
* @param languageURI The new language URI
* @exception OntologyException if the URI does not map to a known language profile
*/
public void setLanguage( String languageURI ) {
m_languageURI = languageURI;
m_profile = ProfileRegistry.getInstance().getProfile( m_languageURI );
if (m_profile == null) {
throw new OntologyException( "Could not determine an ontology language profile for URI " + m_languageURI );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -