@Override public void insertPrefix(String graphName, String prefix, String uri) { Node g = NodeFactory.createURI(graphName) ; Node p = NodeFactory.createLiteral(prefix) ; Node u = NodeFactory.createURI(uri) ; nodeTupleTable.addRow(g,p,u) ; }
protected Node makeNodeForURI(String vitroURIStr) { if (vitroURIStr.indexOf(PSEUDO_BNODE_NS)==0) { return NodeFactory.createBlankNode(vitroURIStr.split("#")[1]); } else { return NodeFactory.createURI(vitroURIStr); } }
private Triple getTriple2() { Node n1 = NodeFactory.createURI("nb1") ; Node n2 = NodeFactory.createURI("nb2") ; Node l3 = NodeFactory.createLiteral("lb3") ; return new Triple(n1, n2, l3) ; }
@Test public void testRDFtermEquals1() { Node n1 = NodeFactory.createURI("xyz") ; Node n2 = NodeFactory.createLiteral("xyz") ; assertFalse(NodeFunctions.rdfTermEquals(n1, n2)) ; }
@Test public void distinct_triples_01() throws IOException { MapReduceDriver<LongWritable, TripleWritable, TripleWritable, NullWritable, NullWritable, TripleWritable> driver = this .getMapReduceDriver(); Triple t = new Triple(NodeFactory.createURI("urn:s"), NodeFactory.createURI("urn:p"), NodeFactory.createLiteral("1")); TripleWritable tw = new TripleWritable(t); driver.addInput(new LongWritable(1), tw); driver.addOutput(NullWritable.get(), tw); driver.runTest(); }
@Test public void deleteAny_01() { DatasetGraph dsg = emptyDataset() ; Node subject = NodeFactory.createURI("http://example/s"); Node predicate = NodeFactory.createURI("http://example/p"); Node object = NodeFactory.createBlankNode(); dsg.add(new Quad(Quad.defaultGraphIRI, subject, predicate, object)); dsg.deleteAny(Node.ANY, subject, null, null); }
@Test public void testUpdateScript2() { DatasetGraph gStore = getEmptyDatasetGraph() ; script(gStore, "update-2.ru") ; assertTrue(graphContains(gStore.getGraph(org.apache.jena.graph.NodeFactory.createURI("http://example/g1")), new Triple(s,p,NodeFactoryExtra.parseNode("123")))) ; assertTrue(graphEmpty(gStore.getDefaultGraph())) ; }
public void testEquals() { assertDiffer( "different variables", NodeFactory.createVariable( "xx" ), NodeFactory.createVariable( "yy" ) ); assertEquals( "same vars", NodeFactory.createVariable( "aa" ), NodeFactory.createVariable( "aa" ) ); assertEquals( "same URI", NodeFactory.createURI( U ), NodeFactory.createURI( U ) ); assertEquals( "same anon", NodeFactory.createBlankNode( A ), NodeFactory.createBlankNode( A ) ); assertEquals( "same literal", NodeFactory.createLiteral( L ), NodeFactory.createLiteral( L ) ); assertFalse( "distinct URIs", NodeFactory.createURI( U ) == NodeFactory.createURI( U ) ); assertFalse( "distinct hyphens", NodeFactory.createBlankNode( A ) == NodeFactory.createBlankNode( A ) ); assertFalse( "distinct literals", NodeFactory.createLiteral( L ) == NodeFactory.createLiteral( L ) ); assertFalse( "distinct vars", NodeFactory.createVariable( "aa" ) == NodeFactory.createVariable( "aa" ) ); }
@Before public void setup() { tripleArray = new Triple[] { new Triple(NodeFactory.createURI("http://example.com/1"), NodeFactory.createURI("http://example.com/v"), NodeFactory.createBlankNode()), new Triple(NodeFactory.createURI("http://example.com/2"), NodeFactory.createURI("http://example.com/v"), NodeFactory.createBlankNode()), new Triple(NodeFactory.createURI("http://example.com/3"), NodeFactory.createURI("http://example.com/v"), NodeFactory.createBlankNode()) }; } }
@Override public SecuredBag getBag(final String uri) throws ReadDeniedException, AuthenticationRequiredException { checkRead(); checkRead(new Triple(NodeFactory.createURI(uri), RDF.type.asNode(), RDF.Bag.asNode())); return SecuredBagImpl.getInstance(holder.getSecuredItem(), holder.getBaseItem().getBag(uri)); }
@Test public void testSameTerm3() { Node n1 = NodeFactory.createLiteral("xyz") ; Node n2 = NodeFactory.createURI("xyz") ; assertFalse(NodeFunctions.sameTerm(n1, n2)) ; }
@Test public void rdfjson_escapes() { Graph g = GraphFactory.createGraphMem(); Node s = NodeFactory.createBlankNode(); Node p = NodeFactory.createURI("http://predicate"); g.add(new Triple(s, p, NodeFactory.createLiteral("quote \" character"))); g.add(new Triple(s, p, NodeFactory.createLiteral("new \n\r lines"))); g.add(new Triple(s, p, NodeFactory.createLiteral("tab \t character"))); test(g); }
@Test public void testCompareGeneral2() { NodeValue nv1 = NodeValue.makeNode(NodeFactory.createBlankNode()) ; NodeValue nv2 = NodeValue.makeNode(NodeFactory.createURI("test:abc")) ; // bNodes before URIs int x = NodeValue.compareAlways(nv1, nv2) ; assertEquals("Does not compare "+nv1+" & "+nv2, NodeValue.CMP_LESS, NodeValue.compareAlways(nv1, nv2) ) ; }
@Override protected TripleWritable createInvalidValue(int i) { return new TripleWritable( new Triple(NodeFactory.createURI("http://subjects/" + i), NodeFactory.createURI("http://predicate"), NodeFactory.createLiteral(Integer.toString(i), XSDDatatype.XSDinteger))); }
public void testEquals() { assertDiffer( "different variables", NodeFactory.createVariable( "xx" ), NodeFactory.createVariable( "yy" ) ); assertEquals( "same vars", NodeFactory.createVariable( "aa" ), NodeFactory.createVariable( "aa" ) ); assertEquals( "same URI", NodeFactory.createURI( U ), NodeFactory.createURI( U ) ); assertEquals( "same anon", NodeFactory.createBlankNode( A ), NodeFactory.createBlankNode( A ) ); assertEquals( "same literal", NodeFactory.createLiteral( L ), NodeFactory.createLiteral( L ) ); assertFalse( "distinct URIs", NodeFactory.createURI( U ) == NodeFactory.createURI( U ) ); assertFalse( "distinct hyphens", NodeFactory.createBlankNode( A ) == NodeFactory.createBlankNode( A ) ); assertFalse( "distinct literals", NodeFactory.createLiteral( L ) == NodeFactory.createLiteral( L ) ); assertFalse( "distinct vars", NodeFactory.createVariable( "aa" ) == NodeFactory.createVariable( "aa" ) ); }
/** Recover a Node from a stored Lucene string */ public static Node stringToNode(String v) { if ( v.startsWith("_:") ) { v = v.substring("_:".length()) ; return NodeFactory.createBlankNode(v) ; } else return NodeFactory.createURI(v) ; }
private List<Triple> writeTriples(StreamRDF out, int size) { List<Triple> results = new ArrayList<>(); out.start(); for (int i = 1; i <= size; i++) { Triple t = new Triple(NodeFactory.createBlankNode(), NodeFactory.createURI("http://predicate"), NodeFactoryExtra.intToNode(i)); out.triple(t); results.add(t); } out.finish(); return results; }
@Override public SecuredSeq getSeq(final String uri) throws ReadDeniedException, AuthenticationRequiredException { checkRead(); checkRead(new Triple(NodeFactory.createURI(uri), RDF.type.asNode(), RDF.Seq.asNode())); return SecuredSeqImpl.getInstance(holder.getSecuredItem(), holder.getBaseItem().getSeq(uri)); }