Java Code Examples for com.hp.hpl.jena.graph.NodeFactory#createURI()
The following examples show how to use
com.hp.hpl.jena.graph.NodeFactory#createURI() .
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: IsATestEvaluator.java From anno4j with Apache License 2.0 | 5 votes |
@Override public Expr evaluate(NodeTest nodeTest, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) { IsATest isATest = (IsATest) nodeTest; Var tmpVar = Var.alloc(Var.alloc(VarIDGenerator.createID())); elementGroup.addTriplePattern(new Triple(var.asNode(), RDF.type.asNode(), tmpVar.asNode())); return new E_Equals(new ExprVar(tmpVar.asNode()), new NodeValueNode(NodeFactory.createURI(isATest.getPathExpression(new SesameValueBackend()).replace("<", "").replace(">", "").replaceFirst("is-a ", "")))); }
Example 2
Source File: PathEqualityTestEvaluator.java From anno4j with Apache License 2.0 | 5 votes |
@Override public Expr evaluate(NodeTest nodeTest, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) { PathEqualityTest pathEqualityTest = (PathEqualityTest) nodeTest; Var tmpVar = LDPathEvaluator.evaluate(pathEqualityTest.getPath(), elementGroup, var, evaluatorConfiguration); if(pathEqualityTest.getNode() instanceof org.openrdf.model.impl.LiteralImpl) { return new E_Equals(new ExprVar(tmpVar.asNode()), new NodeValueNode(NodeFactory.createLiteral(((LiteralImpl) pathEqualityTest.getNode()).getLabel().toString()))); } else { return new E_Equals(new ExprVar(tmpVar.asNode()), new NodeValueNode(NodeFactory.createURI(pathEqualityTest.getNode().toString()))); } }
Example 3
Source File: RecursivePathSelectorEvaluator.java From anno4j with Apache License 2.0 | 5 votes |
@Override public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) { RecursivePathSelector recursivePathSelector = (RecursivePathSelector) nodeSelector; Var id = Var.alloc(VarIDGenerator.createID()); ElementPathBlock epb = new ElementPathBlock(); String pathExpression = recursivePathSelector.getPathExpression(new SesameValueBackend()); /** * initial pathExpression contains: * (<http://www.w3.org/ns/oa#hasBody> / <http://www.example.com/schema#recursiveBodyValue>)* * * Because P_ZeroOrMore and so one, creates the same expression we have to strip the redundant chars. */ String strippedPathExpression = pathExpression.substring(2, pathExpression.length() -3 ); TriplePath triplePath = null; if (pathExpression.contains("*")) { triplePath = new TriplePath(var.asNode(), new P_ZeroOrMore1(new P_Link(NodeFactory.createURI(strippedPathExpression))), id.asNode()); } else if (pathExpression.contains("+")) { triplePath = new TriplePath(var.asNode(), new P_OneOrMore1(new P_Link(NodeFactory.createURI(strippedPathExpression))), id.asNode()); } else { throw new IllegalStateException("Only ZeroOrMorePath(*), OneOrMorePath(+) path selectors are currently supported."); } epb.addTriple(triplePath); ElementGroup group = new ElementGroup(); group.addElement(epb); elementGroup.addElement(group); return id; }
Example 4
Source File: EvalQuery.java From anno4j with Apache License 2.0 | 5 votes |
public static <T extends ResourceObject> Query evaluate(QueryServiceConfiguration queryServiceDTO, URI rootType) throws ParseException { Query query = QueryFactory.make(); query.setQuerySelectType(); ElementGroup elementGroup = new ElementGroup(); Var objectVar = Var.alloc("root"); // Creating and adding the first triple - could be something like: "?objectVar rdf:type oa:Annotation Triple t1 = new Triple(objectVar, RDF.type.asNode(), NodeFactory.createURI(rootType.toString())); elementGroup.addTriplePattern(t1); // Evaluating the criteria for (Criteria c : queryServiceDTO.getCriteria()) { SesameValueBackend backend = new SesameValueBackend(); LdPathParser parser = new LdPathParser(backend, queryServiceDTO.getConfiguration(), new StringReader(c.getLdpath())); Var var = LDPathEvaluator.evaluate(parser.parseSelector(queryServiceDTO.getPrefixes()), elementGroup, objectVar, queryServiceDTO.getEvaluatorConfiguration()); if (c.getConstraint() != null) { String resolvedConstraint = resolveConstraintPrefix(c.getConstraint(), queryServiceDTO, parser); EvalComparison.evaluate(elementGroup, c, var, resolvedConstraint); } } // Adding all generated patterns to the query object query.setQueryPattern(elementGroup); // Choose what we want so select - SELECT ?annotation in this case query.addResultVar(objectVar); // Setting the default prefixes, like rdf: or dc: query.getPrefixMapping().setNsPrefixes(queryServiceDTO.getPrefixes()); return query; }
Example 5
Source File: NTriples.java From SolRDF with Apache License 2.0 | 2 votes |
/** * Parses the given input as URI. * * @param uriAsString the URI string value. * @return the {@link Node} URI representation of the given value. */ private static Node internalAsURI(final String uriAsString) { final String uri = unescape(uriAsString.substring(1, uriAsString.length() - 1)); return NodeFactory.createURI(uri); }