public static AnonId create( String id ) { return new AnonId( id ); }
public static AnonId create() { return new AnonId(); }
public Node create(String label) { String $ = format("B0x%04X", ++counter) ; return Node.createAnon(new AnonId($)) ; }
private Node create(String label) { return NodeFactory.createAnon(new AnonId(label)) ; } }
@Override public Node create() { String label = SysRIOT.BNodeGenIdPrefix + (counter.getAndIncrement()) ; return NodeFactory.createAnon(new AnonId(label)) ; } }
public Node create(String label) { if ( label == null ) label = SysRIOT.BNodeGenIdPrefix+counter++ ; return Node.createAnon(new AnonId(label)) ; }
private Resource createBNode(Model m) { Resource b = m.createResource( new AnonId( "bnode-" + bnodeCounter++ ) ); return b; }
private Node alloc(byte[] labelBytes) { mDigest.update(seedBytes) ; mDigest.update(labelBytes) ; byte[] bytes = mDigest.digest() ; // resets String hexString = Bytes.asHexLC(bytes) ; return NodeFactory.createAnon(new AnonId(hexString)) ; } }
protected Node createNode(String iri) { // Is it a bNode label? i.e. <_:xyz> if ( isBNodeIRI(iri) ) { String s = iri.substring(bNodeLabelStart.length()) ; Node n = Node.createAnon(new AnonId(s)) ; return n ; } return Node.createURI(iri) ; }
@Override public Node alloc(String label) { return NodeFactory.createAnon(new AnonId(NodeFmtLib.decodeBNodeLabel(label))) ; }
protected Node createNode(String iri) { // Is it a bNode label? i.e. <_:xyz> if ( isBNodeIRI(iri) ) { String s = iri.substring(bNodeLabelStart.length()) ; Node n = NodeFactory.createAnon(new AnonId(s)) ; return n ; } return NodeFactory.createURI(iri) ; }
public static Node build(Document doc) { String lex = doc.get(LARQ.fLex) ; if ( lex != null ) return buildLiteral(doc) ; String uri = doc.get(LARQ.fURI) ; if ( uri != null ) return Node.createURI(uri) ; String bnode = doc.get(LARQ.fBNodeID) ; if ( bnode != null ) return Node.createAnon(new AnonId(bnode)) ; throw new ARQLuceneException("Can't build: "+doc) ; }
/** Implement <_:....> as a 2bNode IRI" * that is, use the given label as the BNode internal label. * Use with care. */ public static Node createIRIorBNode(String iri) { // Is it a bNode label? i.e. <_:xyz> if ( isBNodeIRI(iri) ) { String s = iri.substring(bNodeLabelStart.length()) ; Node n = NodeFactory.createAnon(new AnonId(s)) ; return n ; } return NodeFactory.createURI(iri) ; }
/** * Retrieve the anonymous node for a value, creating a new one if none exists * for it yet. * * @param value The value to retrieve the anonymous node for. * @return An anonymous node which is unique for the value. */ private com.hp.hpl.jena.graph.Node getAnon(BNode value) { com.hp.hpl.jena.graph.Node n = (com.hp.hpl.jena.graph.Node)anonMap.get(value); if (n == null) { String nodeId = ((BNode)value).toString(); n = com.hp.hpl.jena.graph.Node.createAnon(new AnonId(nodeId)); addAnon((BNode)value, n); // tell the JrdfFactory as well jrdfFactory.addAnon(n, (BNode) value); } return n; }
/** * Convert the given Sesame Resource to a Jena Resource * @param theRes the sesame resource to convert * @return the sesame resource as a jena resource */ public static com.hp.hpl.jena.rdf.model.Resource asJenaResource(org.openrdf.model.Resource theRes) { if (theRes == null) { return null; } else if (theRes instanceof URI) { return asJenaURI( (URI) theRes); } else { return mInternalModel.createResource(new AnonId(((BNode) theRes).getID())); } }
@Override public Collection<Node> listObjects(Node subject, Node property) { Collection<Node> nodes = new ArrayList<Node>(); if(bnodePrefix != null && subject.isURI() && subject.getURI().startsWith(bnodePrefix)){ subject = NodeFactory.createAnon(new AnonId(subject.getURI().substring(bnodePrefix.length()))); } ExtendedIterator<Triple> it = indexingDataset.getDefaultGraph().find(subject, property, null); while(it.hasNext()){ //STANBOL-765: we need also to transform bnodes to URIs for the //RDFBackend implementation Node object = it.next().getObject(); if(bnodePrefix != null && object.isBlank()){ StringBuilder sb = new StringBuilder(bnodePrefix); sb.append(object.getBlankNodeId().getLabelString()); object = NodeFactory.createURI(sb.toString()); } nodes.add(object); } it.close(); return nodes; } @Override
@Override public Collection<Node> listSubjects(Node property, Node object) { Collection<Node> nodes = new ArrayList<Node>(); if(bnodePrefix != null && object.isURI() && object.getURI().startsWith(bnodePrefix)){ object = NodeFactory.createAnon(new AnonId(object.getURI().substring(bnodePrefix.length()))); } ExtendedIterator<Triple> it = indexingDataset.getDefaultGraph().find(null, property, object); while(it.hasNext()){ Node subject = it.next().getSubject(); //STANBOL-765: we need also to transform bnodes to URIs for the //RDFBackend implementation if(bnodePrefix != null && subject.isBlank()){ StringBuilder sb = new StringBuilder(bnodePrefix); sb.append(subject.getBlankNodeId().getLabelString()); subject = NodeFactory.createURI(sb.toString()); } nodes.add(subject); } it.close(); return nodes; } /**
@Test public void nodec_blank_01() { test (Node.createAnon(new AnonId("a"))) ; } @Test public void nodec_blank_02() { test (Node.createAnon(new AnonId("a:b:c-d"))) ; }
@Test public void nodec_blank_02() { test (Node.createAnon(new AnonId("a:b:c-d"))) ; } @Test public void nodec_blank_03() { test (Node.createAnon()) ; }
@Test public void testRenamesResource() { Model m = ModelFactory.createDefaultModel(); Resource blank = m.createResource(new AnonId("http://alpha.com/renamed" ) ); Literal literal = m.createLiteral( "http://alpha.com/unchanged" ); ModelPrefixEditor pe = new ModelPrefixEditor().set( "http://alpha.com/", "http://localalpha/" ); assertEquals( literal, pe.rename( literal ) ); assertEquals( blank, pe.rename( blank ) ); assertEquals( m.createResource( "http://localalpha/renamed" ), pe.rename( m.createResource( "http://alpha.com/renamed" ) ) ); }