當前位置: 首頁>>代碼示例>>Java>>正文


Java OntModel.getOntology方法代碼示例

本文整理匯總了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;
}
 
開發者ID:crapo,項目名稱:sadlos2,代碼行數:27,代碼來源:ConfigurationManager.java

示例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);
	}
}
 
開發者ID:crapo,項目名稱:sadlos2,代碼行數:17,代碼來源:SadlServerPEImpl.java

示例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();
}
 
開發者ID:crapo,項目名稱:sadlos2,代碼行數:27,代碼來源:ConfigurationManagerForIDE.java


注:本文中的com.hp.hpl.jena.ontology.OntModel.getOntology方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。