Java Code Examples for com.hp.hpl.jena.rdf.model.Literal#getDatatypeURI()
The following examples show how to use
com.hp.hpl.jena.rdf.model.Literal#getDatatypeURI() .
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: JenaSesameUtils.java From anno4j with Apache License 2.0 | 6 votes |
/** * Convert the given Jena Literal to a Sesame Literal * @param theLiteral the Jena Literal to convert * @return the Jena Literal as a Sesame Literal */ public static org.openrdf.model.Literal asSesameLiteral(Literal theLiteral) { if (theLiteral == null) { return null; } else if (theLiteral.getLanguage() != null && !theLiteral.getLanguage().equals("")) { return FACTORY.createLiteral(theLiteral.getLexicalForm(), theLiteral.getLanguage()); } else if (theLiteral.getDatatypeURI() != null) { return FACTORY.createLiteral(theLiteral.getLexicalForm(), FACTORY.createURI(theLiteral.getDatatypeURI())); } else { return FACTORY.createLiteral(theLiteral.getLexicalForm()); } }
Example 2
Source File: WP2RDFXMLWriter.java From GeoTriples with Apache License 2.0 | 6 votes |
protected void writeLiteral(Literal l, PrintWriter writer) { String lang = l.getLanguage(); String form = l.getLexicalForm(); if (!lang.equals("")) { writer.print(" xml:lang=" + attributeQuoted(lang)); } if (l.isWellFormedXML() && !blockLiterals) { writer.print(" " + rdfAt("parseType") + "=" + attributeQuoted("Literal") + ">"); writer.print(form); } else { String dt = l.getDatatypeURI(); if (dt != null) writer.print(" " + rdfAt("datatype") + "=" + substitutedAttribute(dt)); writer.print(">"); writer.print(Util.substituteEntitiesInElementContent(form)); } }
Example 3
Source File: RDFReader.java From marklogic-contentpump with Apache License 2.0 | 5 votes |
private String object(RDFNode node) { if (node.isLiteral()) { Literal lit = node.asLiteral(); String text = lit.getString(); String lang = lit.getLanguage(); String type = lit.getDatatypeURI(); 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.isAnon()) { return "<sem:object>http://marklogic.com/semantics/blank/" + Long.toHexString( hash64(fuse(scramble(milliSecs),randomValue), node.toString())) +"</sem:object>"; } else { return "<sem:object>" + escapeXml(node.toString()) + "</sem:object>"; } }
Example 4
Source File: R2RMLReader.java From GeoTriples with Apache License 2.0 | 4 votes |
public boolean isTypeOf(RDFNode node) { if (!node.isLiteral()) return false; Literal l = node.asLiteral(); return XSD.xstring.getURI().equals(l.getDatatypeURI()) || (l.getDatatypeURI() == null && "".equals(l.getLanguage())); }