本文整理匯總了Java中org.apache.jena.rdf.model.Resource.getLocalName方法的典型用法代碼示例。如果您正苦於以下問題:Java Resource.getLocalName方法的具體用法?Java Resource.getLocalName怎麽用?Java Resource.getLocalName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.jena.rdf.model.Resource
的用法示例。
在下文中一共展示了Resource.getLocalName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRelationshipType
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
public RelationshipType getRelationshipType(URI uri) throws ModelException {
String sparql =
"select ?relationshipTypeUri ?relationshipBaseType ?inverseRelationshipType where {"
+ " ?relationshipTypeUri rdfs:subPropertyOf* ?relationshipBaseType ."
+ " VALUES ?relationshipTypeUri { ?suppliedURI }"
+ " VALUES ?relationshipBaseType { skos:related skos:broader skos:narrower skosxl:altLabel }"
+ " OPTIONAL { ?relationshipTypeUri owl:inverseOf ?inverseRelationshipType }"
+"}";
ParameterizedSparqlString findRelationshipTypeSparql = new ParameterizedSparqlString(model);
findRelationshipTypeSparql.setCommandText(sparql);
findRelationshipTypeSparql.setParam("suppliedURI", model.getResource(uri.toString()));
Query query = QueryFactory.create(findRelationshipTypeSparql.asQuery());
QueryExecution qexec = QueryExecutionFactory.create(query, model);
ResultSet resultSet = qexec.execSelect();
RelationshipType relationshipType = null;
while (resultSet.hasNext()) {
QuerySolution querySolution = resultSet.next();
Resource relationshipTypeResource = querySolution.getResource("?relationshipTypeUri");
Resource inverseRelationshipTypeResource = querySolution.getResource("?inverseRelationshipType");
Resource relationshipBaseTypeResource = querySolution.getResource("?relationshipBaseType");
if ("broader".equals(relationshipBaseTypeResource.getLocalName())) {
relationshipType = new HasBroaderRelationshipType(model, relationshipTypeResource, inverseRelationshipTypeResource);
} else if ("narrower".equals(relationshipBaseTypeResource.getLocalName())) {
relationshipType = new HasNarrowerRelationshipType(model, relationshipTypeResource, inverseRelationshipTypeResource);
} else if ("related".equals(relationshipBaseTypeResource.getLocalName())) {
relationshipType = new AssocativeRelationshipType(model, relationshipTypeResource, inverseRelationshipTypeResource);
} else if ("altLabel".equals(relationshipBaseTypeResource.getLocalName())) {
relationshipType = new HasEquivalentRelationshipType(model, relationshipTypeResource);
} else {
throw new ModelException("Unrecognized base type: '%s' for relationship '%s'", relationshipBaseTypeResource.getLocalName(), uri.toString());
}
}
return relationshipType;
}