本文整理匯總了Java中com.hp.hpl.jena.ontology.OntModel.getOntology方法的典型用法代碼示例。如果您正苦於以下問題:Java OntModel.getOntology方法的具體用法?Java OntModel.getOntology怎麽用?Java OntModel.getOntology使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hp.hpl.jena.ontology.OntModel
的用法示例。
在下文中一共展示了OntModel.getOntology方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: listSubModelsAndPrefixes
import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
private Map<String, String> listSubModelsAndPrefixes(Map<String, String> map, OntModel m, String modelUri) {
Ontology onto = m.getOntology(modelUri);
if (onto != null) {
String prefix = m.getNsURIPrefix(modelUri);
if (prefix == null) {
prefix = getGlobalPrefix(modelUri);
}
if (!map.containsKey(modelUri)) {
map.put(modelUri, prefix);
}
ExtendedIterator<OntResource> importsItr = onto.listImports();
if (importsItr.hasNext()) {
while (importsItr.hasNext()) {
OntResource or = importsItr.next();
logger.debug("Ontology of model '" + modelUri + "' has import '" + or.toString() + "' with prefix '" + prefix + "'");
if (!map.containsKey(or.toString())) {
OntModel submodel = m.getImportedModel(or.getURI());
if (submodel != null) {
map = listSubModelsAndPrefixes(map, submodel, or.getURI());
}
}
}
}
}
return map;
}
示例2: addImport
import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
@Override
public boolean addImport(String modelName, String importedModelUri) throws ConfigurationException, IOException, InvalidNameException, URISyntaxException {
try {
String altImportUrl = getConfigurationMgr().getAltUrlFromPublicUri(importedModelUri);
OntModel model = getOntModelForEditing(modelName);
Resource importingOntology = model.getOntology(modelName);
if (importingOntology == null) {
importingOntology = model.createResource(modelName);
}
model.getOntology(modelName).addImport(importingOntology);
model.loadImports();
return true;
} catch (ConfigurationException e) {
throw new ConfigurationException("Model cannot be imported as its location is unknown.", e);
}
}
示例3: getImports
import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
public synchronized Map<String, String> getImports(String publicUri, Scope scope) throws ConfigurationException, IOException {
OntModel theModel = getOntModel(publicUri, scope);
if (theModel != null) {
Ontology onto = theModel.getOntology(publicUri);
if (onto != null) {
ExtendedIterator<OntResource> importsItr = onto.listImports();
if (importsItr.hasNext()) {
Map<String, String> map = new HashMap<String, String>();
while (importsItr.hasNext()) {
OntResource or = importsItr.next();
String importUri = or.toString();
String prefix = theModel.getNsURIPrefix(importUri);
if (prefix == null) {
prefix = getGlobalPrefix(importUri);
}
logger.debug("Ontology of model '" + publicUri + "' has import '" + importUri + "' with prefix '" + prefix + "'");
if (!map.containsKey(importUri)) {
map.put(importUri, prefix);
}
}
return map;
}
}
}
return Collections.emptyMap();
}