Java Code Examples for com.hp.hpl.jena.graph.Node#getLiteralDatatypeURI()
The following examples show how to use
com.hp.hpl.jena.graph.Node#getLiteralDatatypeURI() .
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: NTriples.java From SolRDF with Apache License 2.0 | 6 votes |
/** * Returns a {@link String} representation of the given literal. * * @param literal the literal node. * @return a {@link String} representation of the given literal. */ public static String asNtLiteral(final Node literal) { final StringBuilder buffer = new StringBuilder("\""); escapeAndAppend(String.valueOf(literal.getLiteral().getLexicalForm()), buffer); buffer.append("\""); final String language = literal.getLiteralLanguage(); if (isNotNullOrEmptyString(language)) { buffer.append("@").append(language); } final String datatypeURI = literal.getLiteralDatatypeURI(); if (datatypeURI != null) { buffer.append("^^"); escapeAndAppend(datatypeURI, buffer); } return buffer.toString(); }
Example 2
Source File: RDFReader.java From marklogic-contentpump with Apache License 2.0 | 5 votes |
protected String object(Node node) { if (node.isLiteral()) { String text = node.getLiteralLexicalForm(); String type = node.getLiteralDatatypeURI(); String lang = node.getLiteralLanguage(); if (lang == null || "".equals(lang)) { lang = ""; } else { lang = " xml:lang='" + escapeXml(lang) + "'"; } if ("".equals(lang)) { if (type == null) { type = "http://www.w3.org/2001/XMLSchema#string"; } type = " datatype='" + escapeXml(type) + "'"; } else { type = ""; } return "<sem:object" + type + lang + ">" + escapeXml(text) + "</sem:object>"; } else if (node.isBlank()) { return "<sem:object>http://marklogic.com/semantics/blank/" + Long.toHexString( hash64(fuse(scramble(milliSecs),randomValue), node.getBlankNodeLabel())) +"</sem:object>"; } else { return "<sem:object>" + escapeXml(node.toString()) + "</sem:object>"; } }