use of org.apache.jena.graph.Node in project jena by apache.
the class CanonicalizeLiteral method apply.
@Override
public Node apply(Node node) {
if (!node.isLiteral())
return node;
if (!node.getLiteralDatatype().isValid(node.getLiteralLexicalForm()))
// Invalid lexical form for the datatype - do nothing.
return node;
RDFDatatype dt = node.getLiteralDatatype();
Node n2;
if (NodeUtils.isLangString(node)) {
// RDF 1.0, no datatype ; RDF 1.1 : datatype is rdf:langString
if (node.getLiteralLanguage().equals(""))
//n2 = NormalizeValue.dtSimpleLiteral.handle(node, node.getLiteralLexicalForm(), null) ;
return node;
else
n2 = canonicalLangtag(node.getLiteralLexicalForm(), node.getLiteralLanguage());
} else if (dt == null) {
// RDF 1.0 / no lang.
n2 = NormalizeValue.dtSimpleLiteral.handle(node, node.getLiteralLexicalForm(), null);
} else {
// Dataype, not rdf:langString (RDF 1.1).
DatatypeHandler handler = dispatch.get(dt);
if (handler == null)
return node;
n2 = handler.handle(node, node.getLiteralLexicalForm(), dt);
}
if (n2 == null)
return node;
return n2;
}
use of org.apache.jena.graph.Node in project jena by apache.
the class RiotLib method createIRIorBNode.
/** Implement <_:....> as a "Node IRI"
* that is, use the given label as the BNode internal label.
* Use with care.
*/
public static Node createIRIorBNode(String iri) {
// Is it a bNode label? i.e. <_:xyz>
if (isBNodeIRI(iri)) {
String s = iri.substring(bNodeLabelStart.length());
Node n = NodeFactory.createBlankNode(s);
return n;
}
return NodeFactory.createURI(iri);
}
use of org.apache.jena.graph.Node in project jena by apache.
the class STriple method readObject.
private void readObject(java.io.ObjectInputStream in) throws IOException {
TProtocol protocol = TRDF.protocol(in);
RDF_Term tterm = new RDF_Term();
Node s = SerializerRDF.read(protocol, tterm);
Node p = SerializerRDF.read(protocol, tterm);
Node o = SerializerRDF.read(protocol, tterm);
triple = Triple.create(s, p, o);
}
use of org.apache.jena.graph.Node in project jena by apache.
the class SinkTripleOutput method send.
@Override
public void send(Triple triple) {
Node s = triple.getSubject();
Node p = triple.getPredicate();
Node o = triple.getObject();
nodeFmt.format(out, s);
out.print(" ");
nodeFmt.format(out, p);
out.print(" ");
nodeFmt.format(out, o);
out.print(" .\n");
}
use of org.apache.jena.graph.Node in project jena by apache.
the class RiotLib method calcWidth.
public static int calcWidth(PrefixMap prefixMap, String baseURI, Collection<Node> nodes, int minWidth, int maxWidth) {
Node prev = null;
int nodeMaxWidth = minWidth;
for (Node n : nodes) {
if (prev != null && prev.equals(n))
continue;
int len = calcWidth(prefixMap, baseURI, n);
if (len > maxWidth)
continue;
if (nodeMaxWidth < len)
nodeMaxWidth = len;
prev = n;
}
return nodeMaxWidth;
}
Aggregations