Java Code Examples for com.hp.hpl.jena.rdf.model.RDFNode#isURIResource()
The following examples show how to use
com.hp.hpl.jena.rdf.model.RDFNode#isURIResource() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlainTextMessageRenderer.java From GeoTriples with Apache License 2.0 | 6 votes |
private String nodeType(RDFNode node) { if (node.isURIResource()) { return "IRI"; } if (node.isAnon()) { return "blank node"; } if (!"".equals(node.asLiteral().getLanguage())) { return "language-tagged string"; } if (node.asLiteral().getDatatypeURI() == null) { return "plain literal"; } if (XSD.xstring.getURI().equals(node.asLiteral().getDatatypeURI())) { return "string literal"; } return "non-string typed literal"; }
Example 2
Source File: PrettyTurtleWriter.java From GeoTriples with Apache License 2.0 | 6 votes |
private String toTurtle(RDFNode r) { if (r.isURIResource()) { return PrettyPrinter.qNameOrURI(relativize(r.asResource().getURI()), prefixes); } else if (r.isLiteral()) { StringBuffer result = new StringBuffer(quote(r.asLiteral().getLexicalForm())); if (!"".equals(r.asLiteral().getLanguage())) { result.append("@"); result.append(r.asLiteral().getLanguage()); } else if (r.asLiteral().getDatatype() != null) { result.append("^^"); result.append(toTurtle(ResourceFactory.createResource(r.asLiteral().getDatatypeURI()))); } return result.toString(); } else { if (!blankNodeMap.containsKey(r)) { blankNodeMap.put(r.asResource(), "_:b" + blankNodeCounter++); } return blankNodeMap.get(r); } }
Example 3
Source File: RDFComparator.java From GeoTriples with Apache License 2.0 | 6 votes |
public int compare(RDFNode n1, RDFNode n2) { if (n1.isURIResource()) { if (!n2.isURIResource()) return -1; return n1.asResource().getURI().compareTo(n2.asResource().getURI()); } if (n1.isAnon()) { if (n2.isURIResource()) return 1; if (n2.isLiteral()) return -1; return n1.asResource().getId().getLabelString().compareTo(n2.asResource().getId().getLabelString()); } if (!n2.isLiteral()) return 1; int cmpLex = n1.asLiteral().getLexicalForm().compareTo(n2.asLiteral().getLexicalForm()); if (cmpLex != 0) return cmpLex; if (n1.asLiteral().getDatatypeURI() == null) { if (n2.asLiteral().getDatatypeURI() != null) return -1; return n1.asLiteral().getLanguage().compareTo(n2.asLiteral().getLanguage()); } if (n2.asLiteral().getDatatypeURI() == null) return 1; return n1.asLiteral().getDatatypeURI().compareTo(n2.asLiteral().getDatatypeURI()); }
Example 4
Source File: PrettyPrinter.java From GeoTriples with Apache License 2.0 | 5 votes |
public static String toString(RDFNode n) { if (n == null) return "null"; if (n.isURIResource()) { Resource r = (Resource) n; return toString(r.asNode(), r.getModel()); } return toString(n.asNode()); }
Example 5
Source File: R2RMLReader.java From GeoTriples with Apache License 2.0 | 5 votes |
public RDFNode coerce(RDFNode in) { if (in.isAnon()) return null; if (in.isURIResource()) { return ResourceFactory.createPlainLiteral(in.asResource().getURI()); } return ResourceFactory.createPlainLiteral(in.asLiteral().getLexicalForm()); }
Example 6
Source File: R2RMLReader.java From GeoTriples with Apache License 2.0 | 4 votes |
public boolean isTypeOf(RDFNode node) { return (node.isURIResource()); }
Example 7
Source File: R2RMLReader.java From GeoTriples with Apache License 2.0 | 4 votes |
public RDFNode coerce(RDFNode in) { return in.isURIResource() ? in : null; }
Example 8
Source File: R2RMLReader.java From GeoTriples with Apache License 2.0 | 4 votes |
public boolean isTypeOf(RDFNode node) { return (node.isURIResource() || node.isLiteral()); }
Example 9
Source File: R2RMLReader.java From GeoTriples with Apache License 2.0 | 4 votes |
public boolean isTypeOf(RDFNode node) { return (node.isURIResource() || node.isAnon()); }