Java Code Examples for org.apache.jena.sparql.util.FmtUtils#stringForNode()

The following examples show how to use org.apache.jena.sparql.util.FmtUtils#stringForNode() . 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: TextOutputStar.java    From RDFstarTools with Apache License 2.0 5 votes vote down vote up
protected String getAsString( Triple t ) {
	//String result = "<< ";
	String result = "";

	final Node s = t.getSubject();
	if ( s instanceof Node_Triple ) {
    	final Triple st = ( (Node_Triple) s ).get();
		//result += getAsString(st) + " ";
		result += "<< " + getAsString(st) + ">> ";
	}
	else
		result += FmtUtils.stringForNode(s, context) + " ";

	result += FmtUtils.stringForNode(t.getPredicate(), context) + " ";

	final Node o = t.getObject();
	if ( o instanceof Node_Triple ) {
    	final Triple ot = ( (Node_Triple) o ).get();
		//result += getAsString(ot) + " ";
		result += "<< " + getAsString(ot) + ">> ";
	}
	else
		result += FmtUtils.stringForNode(o, context) + " ";

	//result += ">>";
	return result;
}
 
Example 2
Source File: HDTStreamRDF.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
@Override
public void triple(Triple t) {
    CharSequence subject = FmtUtils.stringForNode(t.getSubject());
    CharSequence predicate = FmtUtils.stringForNode(t.getPredicate());
    CharSequence object = FmtUtils.stringForNode(t.getObject());
    triples.insert(
            dictionary.insert(subject, TripleComponentRole.SUBJECT),
            dictionary.insert(predicate, TripleComponentRole.PREDICATE),
            dictionary.insert(object, TripleComponentRole.OBJECT)
    );
    num++;
    size += subject.length() + predicate.length() + object.length() + 4;
    listener.notifyProgressCond(t);
}
 
Example 3
Source File: RDFChangesApplyGraph.java    From rdf-delta with Apache License 2.0 4 votes vote down vote up
@Override
public void add(Node g, Node s, Node p, Node o) {
    if ( g != null )
        throw new QuadDataException("Attempt to add quad data to a graph: g="+FmtUtils.stringForNode(g));
    graph.add(Triple.create(s, p, o));
}
 
Example 4
Source File: RDFChangesApplyGraph.java    From rdf-delta with Apache License 2.0 4 votes vote down vote up
@Override
public void delete(Node g, Node s, Node p, Node o) {
    if ( g != null )
        throw new QuadDataException("Attempt to delete quad data to a graph: g="+FmtUtils.stringForNode(g));
    graph.delete(Triple.create(s, p, o));
}
 
Example 5
Source File: ConstantTermExpression.java    From shacl with Apache License 2.0 4 votes vote down vote up
@Override
public String getFunctionalSyntax() {
	return FmtUtils.stringForNode(getRDFNode().asNode(), getRDFNode().getModel());
}