private Property convertPred(AResource r) { if (r.isAnonymous()) return model.createProperty("http://anonymous.ontopia.net/#id" + r.getAnonymousID()); else return model.createProperty(r.getURI()); }
private static Node convert(AResource r) { if (!r.isAnonymous()) return NodeFactory.createURI(r.getURI()); // String id = r.getAnonymousID(); Node rr = (Node) r.getUserData(); if (rr == null) { rr = NodeFactory.createBlankNode(); r.setUserData(rr); } return rr; }
public TopicIF getSubject(AResource sub) { try { TopicIF topic; if (sub.isAnonymous()) { if (sub.hasNodeID()) id = sub.getAnonymousID(); else id = sub.toString(); LocatorIF loc = new URILocator(sub.getURI()); topic = topicmap.getTopicBySubjectIdentifier(loc); if (topic == null) {
@Override public void statement(AResource sub, AResource pred, AResource obj) { if (obj.isAnonymous()) { logger.warn("Blank nodes cannot be subject identifiers; " + "subject: " + sub.getURI() + "; " + "property: " + pred.getURI()); throw new RDFMappingException("Blank nodes cannot be subject identifiers", sub.getURI(), pred.getURI()); } TopicIF topic = getSubject(sub); LocatorIF loc = null; try { loc = new URILocator(obj.getURI()); } catch (MalformedURLException e) { throw new OntopiaRuntimeException("INTERNAL ERROR", e); } TopicIF other = topicmap.getTopicBySubjectIdentifier(loc); if (other != null && !other.equals(topic)) MergeUtils.mergeInto(other, topic); else topic.addSubjectIdentifier(loc); } }
@Override public void endBNodeScope(AResource bnode) { Assert.assertTrue(bnode.isAnonymous()); switch (state) { case 1 : Assert.fail("Missing startRDF"); return ; case 2 : Assert.assertFalse(bnode.hasNodeID()); seen(bnode); break; case 3 : case 4 : Assert.assertTrue(bnode.hasNodeID()); seen(bnode); state = 4; break; default : Assert.fail("impossible - test logic error"); } }
@Override public boolean equals(Object obj) { if (obj instanceof AResource) return uri.equals(((AResource) obj).getURI()); else return false; }
@Override public boolean equals(Object obj) { if (obj instanceof AResource) return anonid.equals(((AResource) obj).getAnonymousID()); else return false; }
/** * @param subj */ private void seeing(AResource subj) { if (subj.isAnonymous()) anon.add(subj); Assert.assertFalse("bnode reuse?", oldAnon.contains(subj)); } /**
@Override public void statement(AResource sub, AResource pred, AResource obj) { if (obj.isAnonymous()) { logger.warn("Blank nodes cannot be subject locators; " + "subject: " + sub.getURI() + "; " + "predicate: " + pred.getURI()); throw new RDFMappingException("Blank nodes cannot be subject locators", sub.getURI(), pred.getURI()); } TopicIF topic = getSubject(sub); LocatorIF loc = null; try { loc = new URILocator(obj.getURI()); } catch (MalformedURLException e) { throw new OntopiaRuntimeException("INTERNAL ERROR", e); } TopicIF other = topicmap.getTopicBySubjectLocator(loc); if (other != null && other != topic) MergeUtils.mergeInto(other, topic); else topic.addSubjectLocator(loc); } }
@Override public void endBNodeScope(AResource bnode) { Assert.assertTrue(bnode.isAnonymous()); switch (state) { case 1 : Assert.fail("Missing startRDF"); return ; case 2 : Assert.assertFalse(bnode.hasNodeID()); seen(bnode); break; case 3 : case 4 : Assert.assertTrue(bnode.hasNodeID()); seen(bnode); state = 4; break; default : Assert.fail("impossible - test logic error"); } }
@Override public void statement(AResource sub, AResource pred, ALiteral lit) { StatementHandler handler = (StatementHandler) mappings.get(pred.getURI()); if (handler != null) handler.statement(sub, pred, lit); }
/** * @param subj */ private void seen(AResource subj) { if (!anon.contains(subj)) { if (ARPResource.DEBUG) { ((RuntimeException)subj.getUserData()).printStackTrace(); } Assert.assertFalse( "end-scope called twice for a bnode: " + subj.getAnonymousID(), oldAnon.contains(subj)); Assert.assertTrue( "end-scope for a bnode that had not been used " + subj.getAnonymousID(), anon.contains(subj)); } anon.remove(subj); oldAnon.add(subj); }
/** * @param subj */ private void seeing(AResource subj) { if (subj.isAnonymous()) anon.add(subj); Assert.assertFalse("bnode reuse?", oldAnon.contains(subj)); } /**
private Resource convert(AResource r) { if (r.isAnonymous()) return model.createResource(new StringAnonId(r.getAnonymousID())); else return model.createResource(r.getURI()); }
private static Node convert(AResource r) { if (!r.isAnonymous()) return NodeFactory.createURI(r.getURI()); // String id = r.getAnonymousID(); Node rr = (Node) r.getUserData(); if (rr == null) { rr = NodeFactory.createBlankNode(); r.setUserData(rr); } return rr; }
@Override public void statement(AResource sub, AResource pred, AResource obj) { if (obj.isAnonymous()) { logger.warn("Blank node cannot be occurrence value; " + "subject: " + sub.getURI() + "; " + "predicate: " + pred.getURI()); if (!lenient) throw new RDFMappingException("Blank node cannot be occurrence value", sub.getURI(), pred.getURI()); } String uri = obj.getURI(); if (uri == null) return; // this happens; not sure why, but it does, so we work around it try { TopicIF topic = getSubject(sub); TopicIF ourtype = type; if (ourtype == null) ourtype = getPredicate(pred); OccurrenceIF occ = builder.makeOccurrence(topic, ourtype, new URILocator(uri)); addScope(occ); } catch (MalformedURLException e) { throw new OntopiaRuntimeException(e); } }
@Override public void statement(AResource sub, AResource pred, AResource obj) { StatementHandler handler = (StatementHandler) mappings.get(pred.getURI()); if (handler != null) handler.statement(sub, pred, obj); }
/** * @param subj */ private void seen(AResource subj) { if (!anon.contains(subj)) { if (ARPResource.DEBUG) { ((RuntimeException)subj.getUserData()).printStackTrace(); } Assert.assertFalse( "end-scope called twice for a bnode: " + subj.getAnonymousID(), oldAnon.contains(subj)); Assert.assertTrue( "end-scope for a bnode that had not been used " + subj.getAnonymousID(), anon.contains(subj)); } anon.remove(subj); oldAnon.add(subj); }
static private void resource(AResource r) { if (r.isAnonymous()) { print("_:j"); print(escapeNTriple(r.getAnonymousID())); print(" "); } else { print("<"); escapeURI(r.getURI()); print("> "); } }
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); riotErrorHandler.error(msg, -1, -1); throw new RiotParseException(msg, -1, -1); } } return NodeFactory.createURI(uriStr); } // String id = r.getAnonymousID(); Node rr = (Node) r.getUserData(); if (rr == null) { rr = NodeFactory.createBlankNode(); r.setUserData(rr); } return rr; }