@Override public boolean equals(Object obj) { if (obj instanceof AResource) return uri.equals(((AResource) obj).getURI()); else return false; }
@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); }
@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); }
@Override public void statement(AResource sub, AResource pred, ALiteral lit) { String preduri = pred.getURI(); if (preduri.startsWith(RDFToTopicMapConverter.RTM_PREFIX)) return; if (recommend && !mappings.containsKey(preduri)) { String low = preduri.toLowerCase(); String mapsto = RDFToTopicMapConverter.RTM_OCCURRENCE; if (low.endsWith("name") || low.endsWith("title") || low.endsWith("label")) mapsto = RDFToTopicMapConverter.RTM_BASENAME; getMapping(preduri).setMapsTo(mapsto); } }
@Override public void statement(AResource sub, AResource pred, AResource obj) { String preduri = pred.getURI(); if (preduri.equals(RDFToTopicMapConverter.RTM_MAPSTO)) { getMapping(sub.getURI()).setMapsTo(obj.getURI()); return; } if (preduri.startsWith(RDFToTopicMapConverter.RTM_PREFIX)) { RDFPropertyMapping mapping = getMapping(sub.getURI()); if (preduri.equals(RDFToTopicMapConverter.RTM_IN_SCOPE)) mapping.setInScope(obj.getURI()); else if (preduri.equals(RDFToTopicMapConverter.RTM_TYPE)) mapping.setType(obj.getURI()); else if (preduri.equals(RDFToTopicMapConverter.RTM_SUBJECT_ROLE)) mapping.setSubjectRole(obj.getURI()); else if (preduri.equals(RDFToTopicMapConverter.RTM_OBJECT_ROLE)) mapping.setObjectRole(obj.getURI()); } else if (recommend && !mappings.containsKey(preduri)) { String mapsto = (String) defaults.get(preduri); if (mapsto == null) mapsto = RDFToTopicMapConverter.RTM_ASSOCIATION; getMapping(preduri).setMapsTo(mapsto); } }
@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 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 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) { if (obj.isAnonymous()) { logger.warn("Blank nodes cannot be source locators; " + "subject: " + sub.getURI() + "; " + "property: " + pred.getURI()); if (!lenient) throw new RDFMappingException("Blank nodes cannot be source 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); } TMObjectIF other = topicmap.getObjectByItemIdentifier(loc); if (other instanceof TopicIF) { TopicIF othert = (TopicIF) other; if (othert != null && !othert.equals(topic)) MergeUtils.mergeInto(othert, topic); else topic.addItemIdentifier(loc); } // else FIXME: what to do? } }
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 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; }
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; }
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; }
private Resource convert(AResource r) { if (r.isAnonymous()) return model.createResource(new StringAnonId(r.getAnonymousID())); else return model.createResource(r.getURI()); }
static private void resource(AResource r) { if (r.isAnonymous()) { print("_:j"); print(escapeNTriple(r.getAnonymousID())); print(" "); } else { print("<"); escapeURI(r.getURI()); print("> "); } }
static private void resource(AResource r) { if (r.isAnonymous()) { print("_:j"); print(escapeNTriple(r.getAnonymousID())); print(" "); } else { print("<"); escapeURI(r.getURI()); print("> "); } }
LocatorIF loc = new URILocator(sub.getURI()); topic = topicmap.getTopicBySubjectIdentifier(loc); if (topic == null) {