Java Code Examples for com.hp.hpl.jena.rdf.model.Literal#getString()

The following examples show how to use com.hp.hpl.jena.rdf.model.Literal#getString() . 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: RDFReader.java    From marklogic-contentpump with Apache License 2.0 5 votes vote down vote up
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 2
Source File: RDFFileManager.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
private static String extractEventType(String edID, Dataset dataset) {
	String queryStr = queryPrefix + " select  ?name where {<" + edID
			+ "> owls:presents ?profile. ?profile owlssc:serviceCategory ?z. ?z owlssc:serviceCategoryName ?name}";
	QueryExecution qe = QueryExecutionFactory.create(queryStr, dataset);
	ResultSet results = qe.execSelect();
	String type = "";
	if (results.hasNext()) {
		Literal l = results.next().getLiteral("name");
		type = l.getString();
	}
	return type;
}
 
Example 3
Source File: Template.java    From r2rml-parser with Apache License 2.0 5 votes vote down vote up
public Template(Literal literal, TermType termType, String namespace, Model model) {
	this.text = literal.getString();
	this.language = literal.getLanguage();
	this.fields = createTemplateFields();
	this.termType = termType;
	this.namespace = namespace;
	this.model = model;
}