本文整理匯總了Java中org.apache.jena.rdf.model.RDFNode.isAnon方法的典型用法代碼示例。如果您正苦於以下問題:Java RDFNode.isAnon方法的具體用法?Java RDFNode.isAnon怎麽用?Java RDFNode.isAnon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.jena.rdf.model.RDFNode
的用法示例。
在下文中一共展示了RDFNode.isAnon方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDisplayName
import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
public static String getDisplayName(RDFNode node) {
if (node == null)
return "unknown";
else if (node.isAnon())
return "anon";
else if (node.isLiteral())
return node.asLiteral().getLexicalForm();
else if (node.isResource()) {
Resource resource = node.asResource();
if (resource instanceof OntResource) {
String label = ((OntResource) resource).getLabel(null);
if (label != null)
return label;
}
String localName = resource.getLocalName();
if ((localName != null) && !localName.isEmpty())
return localName;
return resource.toString();
} else
return "unknown";
}
示例2: mergeDescription
import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
private void mergeDescription(Resource ir, Resource r, boolean flagOK, Map<RDFNode,RDFNode> visited) {
for (StmtIterator si = r.listProperties(); si.hasNext(); ) {
Statement stmt = si.nextStatement();
Property p = stmt.getPredicate();
RDFNode o = stmt.getObject();
if (flagOK && r.hasProperty(RDF.type, OWL.Class))
ir.addProperty(RDF.type, infModel.getResource(Gloze.OK));
if (o.isLiteral())
ir.addProperty(p,o);
else if (!o.isAnon())
ir.addProperty(p,infModel.createResource(((Resource)o).getURI()));
else if (o.isAnon() && visited.containsKey(o))
ir.addProperty(p,visited.get(o));
else { // recursively merge anonymous objects
Resource a = infModel.createResource();
visited.put(o,a);
ir.addProperty(p,a);
mergeDescription(a, (Resource)o, false, visited);
}
}
}
示例3: isNodeShape
import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
/**
* Checks if a given node is a NodeShape.
* This is just an approximation based on a couple of hard-coded properties.
* @param node the node to test
* @return true if node is a NodeShape
*/
public static boolean isNodeShape(RDFNode node) {
if(node instanceof Resource) {
if(JenaUtil.hasIndirectType((Resource)node, SH.NodeShape)) {
return true;
}
else if(node.isAnon() && !((Resource)node).hasProperty(RDF.type)) {
if(node.getModel().contains(null, SH.node, node)) {
return true;
}
}
}
return false;
}
示例4: cleanup
import org.apache.jena.rdf.model.RDFNode; //導入方法依賴的package包/類
public void cleanup(Resource rez, Set<Resource> visited) {
visited.add(rez);
Set<Resource> clean = new HashSet<Resource>();
for (StmtIterator i = rez.listProperties(); i.hasNext(); ) {
RDFNode obj = i.nextStatement().getObject();
if (obj.isAnon() && obj instanceof Resource && !visited.contains(obj))
clean.add((Resource) obj);
}
for (Resource r: clean) cleanup(r,visited);
rez.removeProperties();
}