本文整理匯總了Java中com.hp.hpl.jena.ontology.OntModel.getNsURIPrefix方法的典型用法代碼示例。如果您正苦於以下問題:Java OntModel.getNsURIPrefix方法的具體用法?Java OntModel.getNsURIPrefix怎麽用?Java OntModel.getNsURIPrefix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hp.hpl.jena.ontology.OntModel
的用法示例。
在下文中一共展示了OntModel.getNsURIPrefix方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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();
}
示例3: getPrefix
import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
protected String getPrefix(OntModel om, String uri) {
String prefix = om.getNsURIPrefix(uri);
if (prefix == null || prefix.length() == 0) {
if (uri.endsWith("#")) {
uri = uri.substring(0, uri.length() - 1);
}
return getGlobalPrefix(uri);
}
return prefix;
}
示例4: loadImportedModel
import com.hp.hpl.jena.ontology.OntModel; //導入方法依賴的package包/類
@Override
public List<ImportMapping> loadImportedModel(Ontology importingOntology, OntModel importingModel,
String publicImportUri, String altImportUrl) throws ConfigurationException {
// if not given the publicImportUri, then we must have the altImportUrl so find the publicImportUri in mapping
if (publicImportUri == null) {
if (altImportUrl == null) {
throw new ConfigurationException("Must have either a public URI or an actual URL to import a model.");
}
publicImportUri = getPublicUriFromActualUrl(altImportUrl);
}
if (importingOntology == null) {
throw new ConfigurationException("Importing ontology is null!");
}
// if not given altImportUrl, then we must have the publicImportUri so find the altImportUrl in mapping
if (altImportUrl == null) {
altImportUrl = getAltUrlFromPublicUri(publicImportUri);
}
String importingOntologyUri = importingOntology.getURI();
if (importingOntologyUri == null) {
throw new ConfigurationException("Importing ontology '" + importingOntology.toString() + "' does not have an ontology declaration.");
}
if (!importingOntologyUri.equals(publicImportUri)) { // don't import to self
// Now load import model (with setCachedModels true so it loads any indirect imports)
// and add all import OntModels to importing mappings
Resource importedOntology = importingModel.createResource(publicImportUri);
importingOntology.addImport(importedOntology);
}
// this.getJenaDocumentMgr().setCacheModels(true);
this.getJenaDocumentMgr().setProcessImports(true);
ReadFailureHandler rfh = this.getJenaDocumentMgr().getReadFailureHandler();
if (rfh instanceof SadlReadFailureHandler) {
((SadlReadFailureHandler)rfh).setSadlConfigMgr(this);
}
getModelGetter().configureToModel(importingModel);
importingModel.loadImports();
if (readError != null) {
String err = readError;
readError = null;
if (importingModel.hasLoadedImport(publicImportUri)) {
// this must be removed or it will prevent correct loading from another project
importingModel.removeLoadedImport(publicImportUri);
}
this.getJenaDocumentMgr().setProcessImports(false);
throw new ConfigurationException(err);
}
this.getJenaDocumentMgr().setProcessImports(false);
List<ImportMapping> map = new ArrayList<ImportMapping>();
Iterator<String> itr = importingModel.listImportedOntologyURIs(true).iterator();
while (itr.hasNext()) {
String impUri = itr.next();
if (impUri.equals(importingOntology.getURI())) {
// don't count ourselves as an import
importingModel.setNsPrefix("", ConfigurationManager.addHashToNonTerminatedNamespace(impUri));
continue;
}
String prefix = importingModel.getNsURIPrefix(ConfigurationManager.addHashToNonTerminatedNamespace(impUri));
if (prefix == null) {
prefix = getGlobalPrefix(impUri);
if (prefix != null) {
importingModel.setNsPrefix(prefix, ConfigurationManager.addHashToNonTerminatedNamespace(impUri));
}
}
OntModel impModel = importingModel.getImportedModel(impUri);
String actImpUrl = getAltUrlFromPublicUri(impUri);
logger.debug("processing importingModel, url = "+actImpUrl);
ImportMapping im = new ImportMapping(impUri, actImpUrl, null);
im.setModel(impModel);
im.setPrefix(prefix);
map.add(im);
}
this.getJenaDocumentMgr().setProcessImports(false);
// this.getJenaDocumentMgr().setCacheModels(false);
return map;
}