Java Code Examples for org.apache.jena.graph.NodeFactory#createURI()
The following examples show how to use
org.apache.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: DatasetDeclarationPlan.java From sparql-generate with Apache License 2.0 | 6 votes |
private void addNamedGraph(Binding binding, Context context, DatasetGraph dsg, Expr sourceExpr) { String sourceURI = evalSourceURI(binding, context, sourceExpr); final String absURI = baseURI(sourceURI, baseURI); Dataset dataset = ContextUtils.getDataset(context); Node n = NodeFactory.createURI(absURI); Graph g = dsg.getGraph(n); if (g == null) { g = GraphFactory.createJenaDefaultGraph(); dsg.addGraph(n, g); } // default: check the dataset if (dataset.containsNamedModel(absURI)) { Graph dg = dataset.getNamedModel(absURI).getGraph(); GraphUtil.addInto(g, dg); return; } // fallback: load as RDF graph StreamRDF dest = StreamRDFLib.graph(g); ContextUtils.loadGraph(context, sourceURI, absURI, dest); }
Example 2
Source File: OCUtils.java From quetzal with Eclipse Public License 2.0 | 6 votes |
public static Set<ConjunctiveQuery> getMembershipQuery(OWLOntology ont) { Set<ConjunctiveQuery> ret = new HashSet<ConjunctiveQuery>(); for (OWLClass owlclass: ont.getClassesInSignature(true)) { ElementTriplesBlock p = new ElementTriplesBlock(); String x = "x"; Node sub = NodeFactory.createVariable(x); Node pred = NodeFactory.createURI(RDFConstants.RDF_TYPE); Node obj = NodeFactory.createURI(owlclass.getIRI().toString()); Triple qt = new Triple(sub, pred, obj); p.getPattern().add(qt); ConjunctiveQuery cq = new ConjunctiveQuery(); cq.setQueryPattern(p); cq.addResultVar(x); cq.setDistinct(true); ret.add(cq); } return ret; }
Example 3
Source File: Query.java From quetzal with Eclipse Public License 2.0 | 6 votes |
@Override public List<Node> getResultURIs() { List<Node> list = new ArrayList<Node>(); if (describeQuery != null) { List<BinaryUnion<Variable, IRI>> binaryUnions = describeQuery .getResources(); if (binaryUnions != null) { for (BinaryUnion<Variable, IRI> binaryUnion : binaryUnions) { if (binaryUnion.getSecond() != null) { String v = binaryUnion.getSecond().toString(); Node e = NodeFactory.createURI(v); list.add(e); } } } } return list; }
Example 4
Source File: SinkTripleStarOutputTest.java From RDFstarTools with Apache License 2.0 | 5 votes |
@Test public void withBaseIRIandPrefixMap() { final Node u = NodeFactory.createURI("http://example.com/i"); final Node n = new Node_Triple(new Triple(u, u, u)); final String result = serialize( n, u, u, "http://example.com/", getPrefixMapForTests() ); assertEquals("<<ex:i ex:i ex:i>> ex:i ex:i .\n", result); }
Example 5
Source File: NodeFormatterTurtleStarExtImplTest.java From RDFstarTools with Apache License 2.0 | 5 votes |
@Test public void triple() { final Node u = NodeFactory.createURI("http://example.com"); final Node n = new Node_Triple(new Triple(u, u, u)); final String s = serialize(n); assertEquals("<<<http://example.com> <http://example.com> <http://example.com>>>", s); }
Example 6
Source File: DatasetDeclarationPlan.java From sparql-generate with Apache License 2.0 | 5 votes |
private void addNamedGraph(Binding binding, Context context, DatasetGraph dsg, SPARQLExtQuery generate, Expr name) { String sourceURI = evalSourceURI(binding, context, name); final String absURI = baseURI(sourceURI, baseURI); Node n = NodeFactory.createURI(absURI); Graph g = dsg.getGraph(n); if (g == null) { g = GraphFactory.createJenaDefaultGraph(); dsg.addGraph(n, g); } loadGraph(binding, context, generate, g); }
Example 7
Source File: NodeFormatterTurtleStarWrapperImplTest.java From RDFstarTools with Apache License 2.0 | 5 votes |
@Test public void triple() { final Node u = NodeFactory.createURI("http://example.com"); final Node n = new Node_Triple(new Triple(u, u, u)); final String s = serialize(n); assertEquals("<<<http://example.com> <http://example.com> <http://example.com>>>", s); }
Example 8
Source File: RdflintParserRdfxml.java From rdflint with MIT License | 5 votes |
private Node convert(AResource r) { if (!r.isAnonymous()) { // URI. String uriStr = r.getURI(); if (errorForSpaceInURI) { // Special check for spaces in a URI. // Convert to an error like TokernizerText. if (uriStr.contains(" ")) { int i = uriStr.indexOf(' '); String s = uriStr.substring(0, i); String msg = String.format("Bad character in IRI (space): <%s[space]...>", s); int line = arp.getLocator().getLineNumber(); int col = arp.getLocator().getColumnNumber(); riotErrorHandler.error(msg, line, col);// NOPMD throw new RiotParseException(msg, line, col); } } return NodeFactory.createURI(uriStr); } // String id = r.getAnonymousID(); Node rr = (Node) r.getUserData(); if (rr == null) { rr = NodeFactory.createBlankNode(); r.setUserData(rr); } return rr; }
Example 9
Source File: TextIndexSolr5.java From BioSolr with Apache License 2.0 | 5 votes |
private List<Map<String, Node>> process(SolrDocumentList solrResults) { List<Map<String, Node>> records = new ArrayList<>() ; for ( SolrDocument sd : solrResults ) { Map<String, Node> record = new HashMap<>() ; String uriStr = (String)sd.getFieldValue(docDef.getEntityField()) ; Node entity = NodeFactory.createURI(uriStr) ; record.put(docDef.getEntityField(), entity) ; for ( String f : docDef.fields() ) { // log.info("Field: "+f) ; Object obj = sd.getFieldValue(f) ; // log.info("Value: "+obj) ; if ( obj == null ) continue ; // Multivalued -> array. // Null means "not stored" or "not present" if ( obj instanceof List<? > ) { @SuppressWarnings("unchecked") List<String> vals = (List<String>)obj ; continue ; } String v = (String)obj ; Node n = entryToNode(v) ; record.put(f, n) ; } // log.info("Entity: "+uriStr) ; records.add(record) ; } return records ; }
Example 10
Source File: TextOutputStarTest.java From RDFstarTools with Apache License 2.0 | 5 votes |
@Test public void nested1() { final MyTextOutput o = new MyTextOutput( getPrefixMappingForTests() ); final Node u = NodeFactory.createURI("http://example.com/i"); final Node n1 = new Node_Triple(new Triple(u, u, u)); final Node n2 = new Node_Triple(new Triple(n1, u, u)); final QuerySolution s = createQuerySolution( "?t", n2 ); final String result = o.get(s, "?t"); assertEquals("<< ex:i ex:i ex:i >> ex:i ex:i ", result); }
Example 11
Source File: SinkTripleStarOutputTest.java From RDFstarTools with Apache License 2.0 | 5 votes |
@Test public void neitherBaseIRInotPrefixMap() { final Node u = NodeFactory.createURI("http://example.com/i"); final Node n = new Node_Triple(new Triple(u, u, u)); final String result = serialize( n, u, u, null, null ); assertEquals("<<<http://example.com/i> <http://example.com/i> <http://example.com/i>>> <http://example.com/i> <http://example.com/i> .\n", result); }
Example 12
Source File: QueryIterTripleStarPatternTest.java From RDFstarTools with Apache License 2.0 | 5 votes |
@Test public void createWithoutNestedTP() { final Node u = NodeFactory.createURI("http://example.com/i"); final Triple tp = new Triple( u, u, u ); final QueryIterator input = new QueryIterNullIterator(null); final QueryIterator it = QueryIterTripleStarPattern.create(input, tp, null); assertTrue( it instanceof QueryIterTriplePattern ); it.close(); }
Example 13
Source File: NodeFormatterTurtleStarExtImplTest.java From RDFstarTools with Apache License 2.0 | 5 votes |
@Test public void nestedTripleO() { final Node u = NodeFactory.createURI("http://example.com"); final Node n1 = new Node_Triple(new Triple(u, u, u)); final Node n2 = new Node_Triple(new Triple(u, u, n1)); final String s = serialize(n2); assertEquals("<<<http://example.com> <http://example.com> <<<http://example.com> <http://example.com> <http://example.com>>>>>", s); }
Example 14
Source File: TextOutputStarTest.java From RDFstarTools with Apache License 2.0 | 5 votes |
@Test public void nested2() { final MyTextOutput o = new MyTextOutput( getPrefixMappingForTests() ); final Node u = NodeFactory.createURI("http://example.com/i"); final Node n1 = new Node_Triple(new Triple(u, u, u)); final Node n2 = new Node_Triple(new Triple(u, u, n1)); final QuerySolution s = createQuerySolution( "?t", n2 ); final String result = o.get(s, "?t"); assertEquals("ex:i ex:i << ex:i ex:i ex:i >> ", result); }
Example 15
Source File: TermFactory.java From shacl with Apache License 2.0 | 4 votes |
public JSNamedNode namedNode(String value) { Node node = NodeFactory.createURI(value); return new JSNamedNode(node); }
Example 16
Source File: TextOutputStarTest.java From RDFstarTools with Apache License 2.0 | 4 votes |
public String getResult( MyTextOutput o ) { final Node u = NodeFactory.createURI("http://example.com/i"); final Node n = new Node_Triple(new Triple(u, u, u)); final QuerySolution s = createQuerySolution( "?t", n ); return o.get(s, "?t"); }
Example 17
Source File: QueryIterTripleStarPatternTest.java From RDFstarTools with Apache License 2.0 | votes |
static protected Node $o() { return NodeFactory.createURI("http://example.com/o"); }
Example 18
Source File: QueryIterTripleStarPatternTest.java From RDFstarTools with Apache License 2.0 | votes |
static protected Node $x1() { return NodeFactory.createURI("http://example.com/x1"); }
Example 19
Source File: QueryIterTripleStarPatternTest.java From RDFstarTools with Apache License 2.0 | votes |
static protected Node $x2() { return NodeFactory.createURI("http://example.com/x2"); }
Example 20
Source File: QueryIterTripleStarPatternTest.java From RDFstarTools with Apache License 2.0 | votes |
static protected Node $s() { return NodeFactory.createURI("http://example.com/s"); }