@Override public boolean traverse(Resource r) { return r.isAnon() ; }
/** * Local and/or anonymous resources. */ private boolean isGenuineAnon(Resource r) { if (!r.isAnon()) return false; Integer v = objectTable.get(r); return v == null || ((!prettyWriter.sResourcePropertyElt) && v.intValue() <= 1 && (!haveReified .contains(r))); }
/** Record a use of the given namespace in the count map */ private void countNamespace( Resource r, Map<String,Integer> nsCount ) { if (!r.isAnon()) { String ns = r.getNameSpace(); // increment the count for this namespace Integer count = nsCount.containsKey( ns ) ? (Integer) nsCount.get( ns ) : new Integer( 0 ); Integer count1 = new Integer( count.intValue() + 1 ); nsCount.put( ns, count1 ); } }
private String getXMLNameSpace(Resource r) { if (r.isAnon()) { logger.error("Internal error - Unparser.getNameSpace; giving up"); throw new BrokenException("Internal error: getNameSpace(bNode)"); } String uri = r.getURI(); int split = Util.splitNamespaceXML(uri); return uri.substring(0, split); }
private String getXMLLocalName(Resource r) { if (r.isAnon()) { logger.error("Internal error - giving up - Unparser.getLocalName"); throw new BrokenException("Internal error: getLocalName(bNode)"); } String uri = r.getURI(); int split = Util.splitNamespaceXML(uri); return uri.substring(split); }
protected void writeResourceId( Resource r, PrintWriter writer ) { if (r.isAnon()) { writer.print(rdfAt("nodeID") + "=" + attributeQuoted(anonId(r))); } else { writer.print( rdfAt("about") + "=" + substitutedAttribute(relativize(r.getURI()))); } }
/** Answer a "nice" representation of <code>r</code>, suitable for appearance within an exception message. */ protected static String nice( Resource r ) { String rString = r.asNode().toString( r.getModel() ); return r.isAnon() ? rString + getLabels( r ) : rString; }
protected void writeResourceReference( Resource r, PrintWriter writer ) { if (r.isAnon()) { writer.print(rdfAt("nodeID") + "=" + attributeQuoted(anonId(r))); } else { writer.print( rdfAt("resource") + "=" + substitutedAttribute(relativize(r.getURI()))); } }
/** Answer a "nice" representation of <code>r</code>, suitable for appearance within an exception message. */ protected static String nice( Resource r ) { String rString = r.asNode().toString( r.getModel() ); return r.isAnon() ? rString + getLabels( r ) : rString; }
private boolean wResourceAttr(Resource r) { if (r.isAnon()) return false; print(" "); printRdfAt("resource"); print("="); wURIreference(r); return true; }
private boolean wResourceAttr(Resource r) { if (r.isAnon()) return false; print(" "); printRdfAt("resource"); print("="); wURIreference(r); return true; }
private static void addToIdList(Statement stmt, Set<AnonId> ids) { if (stmt.getSubject().isAnon()) { ids.add(stmt.getSubject().getId()); } if (stmt.getObject().isAnon()) { ids.add(stmt.getObject().asResource().getId()); } }
private static Resource otherModel(Resource r, Model model) { if ( r.isURIResource() ) return model.createResource(r.getURI()) ; if ( r.isAnon() ) return model.createResource(r.getId()) ; // Literals do not need converting. return r ; }
private boolean wNodeIDAttr(Resource r) { if (!r.isAnon()) return false; print(" "); printRdfAt("nodeID"); print("="); print(q(prettyWriter.anonId(r))); return true; }
public void testCreateResource() { Resource r1 = ResourceFactory.createResource(); Assert.assertTrue(r1.isAnon()); final Resource r2 = ResourceFactory.createResource(); Assert.assertTrue(r2.isAnon()); Assert.assertTrue(!r1.equals(r2)); r1 = ResourceFactory.createResource(TestResourceFactory.uri1); Assert.assertTrue(r1.getURI().equals(TestResourceFactory.uri1)); }
public void testCreateTypedAnonResource() { final Resource r = model.createResource(RDF.Property); Assert.assertTrue(r.isAnon()); Assert.assertTrue(model.contains(r, RDF.type, RDF.Property)); }
public void testPortingBlankNodes() { final Model B = createModel(); final Resource anon = model.createResource(); final Resource bAnon = anon.inModel(B); Assert.assertTrue("moved resource should still be blank", bAnon.isAnon()); Assert.assertEquals("move resource should equal original", anon, bAnon); }
public void testCreateAnonResourceWithNull() { final Resource r = model.createResource((String) null); Assert.assertTrue(r.isAnon()); Assert.assertNull(r.getURI()); Assert.assertNull(r.getNameSpace()); Assert.assertNull(r.getLocalName()); }
public void testCreateAnonResourceWithNull() { final Resource r = model.createResource((String) null); Assert.assertTrue(r.isAnon()); Assert.assertNull(r.getURI()); Assert.assertNull(r.getNameSpace()); Assert.assertNull(r.getLocalName()); }