org.apache.jena.sparql.util.FmtUtils Java Examples
The following examples show how to use
org.apache.jena.sparql.util.FmtUtils.
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 |
@Override protected String getVarValueAsString(QuerySolution rBind, String varName) { final RDFNode obj = rBind.get(varName); if ( obj == null ) { return super.getVarValueAsString(rBind, varName); } else if ( obj.asNode() instanceof Node_Triple ) { final Triple t = ( (Node_Triple) obj.asNode() ).get(); return getAsString(t); } else { return FmtUtils.stringForRDFNode(obj, context); } }
Example #2
Source File: TextOutputStar.java From RDFstarTools with Apache License 2.0 | 5 votes |
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 #3
Source File: HDTStreamRDF.java From sparql-generate with Apache License 2.0 | 5 votes |
@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 #4
Source File: SHACLPaths.java From shacl with Apache License 2.0 | 5 votes |
/** * Renders a given path into a given StringBuffer, using the prefixes supplied by the * Path's Model. * @param sb the StringBuffer to write into * @param path the path resource */ public static void appendPath(StringBuffer sb, Resource path) { if(path.isURIResource()) { sb.append(FmtUtils.stringForNode(path.asNode(), path.getModel())); } else { appendPathBlankNode(sb, path, SEQUENCE_PATH_SEPARATOR); } }
Example #5
Source File: SHACLPaths.java From shacl with Apache License 2.0 | 5 votes |
private static void appendNestedPath(StringBuffer sb, Resource path, String separator) { if(path.isURIResource()) { sb.append(FmtUtils.stringForNode(path.asNode(), path.getModel())); } else { sb.append("("); appendPathBlankNode(sb, path, separator); sb.append(")"); } }
Example #6
Source File: AbstractSPARQLExpression.java From shacl with Apache License 2.0 | 5 votes |
@Override public List<String> getFunctionalSyntaxArguments() { List<String> results = new LinkedList<>(); results.add(FmtUtils.stringForNode(NodeFactory.createLiteral(queryString))); NodeExpression input = getInput(); if(input != null) { results.add(input.getFunctionalSyntax()); } return results; }
Example #7
Source File: FunctionExpression.java From shacl with Apache License 2.0 | 5 votes |
@Override public List<String> getFunctionalSyntaxArguments() { List<String> results = new LinkedList<>(); results.add(FmtUtils.stringForRDFNode(function)); for(NodeExpression arg : args) { results.add(arg.getFunctionalSyntax()); } return results; }
Example #8
Source File: PathExpression.java From shacl with Apache License 2.0 | 5 votes |
public PathExpression(RDFNode expr, Resource path, NodeExpression input) { super(expr, input); this.path = path; if(path.isAnon()) { pathString = SHACLPaths.getPathString(path); Path jenaPath = (Path) SHACLPaths.getJenaPath(pathString, path.getModel()); eval = new PathEvaluator(jenaPath, expr.getModel()); } else { pathString = FmtUtils.stringForRDFNode(path); eval = new PathEvaluator(JenaUtil.asProperty(path)); } eval.setInput(input); }
Example #9
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 4 votes |
private String tokenToString(Token token) { switch (token.getType()) { // superclass case NODE: case IRI : return "<" + token.getImage() + ">"; case PREFIXED_NAME : notImplemented(token); return null; case BNODE : return "_:" + token.getImage(); //case BOOLEAN: case STRING : return "\"" + FmtUtils.stringEsc(token.getImage()) + "\""; case LITERAL_LANG : return "\"" + FmtUtils.stringEsc(token.getImage()) + "\"@" + token.getImage2(); case LITERAL_DT : return "\"" + FmtUtils.stringEsc(token.getImage()) + "\"^^" + tokenToString(token.getSubToken2()); case INTEGER : case DECIMAL : case DOUBLE : return token.getImage(); // Not RDF case KEYWORD : return token.getImage(); case DOT : return Chars.S_DOT; case VAR : return "?" + token.getImage(); case COMMA : return Chars.S_COMMA; case SEMICOLON : return Chars.S_SEMICOLON; case COLON : return Chars.S_COLON; case LT : return Chars.S_LT; case GT : return Chars.S_GT; case LE : return Chars.S_LE; case GE : return Chars.S_GE; case UNDERSCORE : return Chars.S_UNDERSCORE; case LBRACE : return Chars.S_LBRACE; case RBRACE : return Chars.S_RBRACE; case LPAREN : return Chars.S_LPAREN; case RPAREN : return Chars.S_RPAREN; case LBRACKET : return Chars.S_LBRACKET; case RBRACKET : return Chars.S_RBRACKET; case PLUS : return Chars.S_PLUS; case MINUS : return Chars.S_MINUS; case STAR : return Chars.S_STAR; case SLASH : return Chars.S_SLASH; case RSLASH : return Chars.S_RSLASH; case HEX : return "0x" + token.getImage(); // Syntax // COLON is only visible if prefix names are not being processed. case DIRECTIVE : return "@" + token.getImage(); case VBAR : return Chars.S_VBAR; case AMPHERSAND : return Chars.S_AMPHERSAND; case EQUALS : return Chars.S_EQUALS; default : notImplemented(token); return null; // case EOF: // case EQUIVALENT : // return "=="; // case LOGICAL_AND : // return "&&"; // case LOGICAL_OR : // return "||"; // case NL : // break; // case NODE : // break; // case WS : // break; } }
Example #10
Source File: RDFChangesApplyGraph.java From rdf-delta with Apache License 2.0 | 4 votes |
@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 #11
Source File: RDFChangesApplyGraph.java From rdf-delta with Apache License 2.0 | 4 votes |
@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 #12
Source File: ConstantTermExpression.java From shacl with Apache License 2.0 | 4 votes |
@Override public String getFunctionalSyntax() { return FmtUtils.stringForNode(getRDFNode().asNode(), getRDFNode().getModel()); }
Example #13
Source File: ConstantTermExpression.java From shacl with Apache License 2.0 | 4 votes |
@Override public String toString() { return FmtUtils.stringForRDFNode(getRDFNode()); }