protected static String anonName(AnonId id) { String name = "_:A"; String sid = id.toString(); for (int i = 0; i < sid.length(); i++) { char c = sid.charAt(i); if (c == 'X') { name = name + "XX"; } else if (Character.isLetterOrDigit(c)) { name = name + c; } else { name = name + "X" + Integer.toHexString(c) + "X"; } } return name; } }
/** * Find a name to give a resource */ public static String getNameFor(Resource r) { String label = getStringValue(r, RDFS.label); if (label != null) return label; if (r.isURIResource()) { String uri = r.getURI(); int split = uri.lastIndexOf('#'); if (split == -1) split = uri.lastIndexOf('/'); return uri.substring(split + 1); } else { return r.getId().toString(); } }
private String longAnonId(Resource r) { String rid = r.getId().toString(); return XMLChar.isValidNCName( rid ) ? rid : escapedId( rid ); }
/** * @return A name for the resource. By preference, this will be a label property * of the resource. Otherwise, a curie or localname will be used if no naming property is found. * Special cases for displaying names of nodes with no labels in Elda: * <ul> * <li>if the name would otherwise be empty, and the URI ends with `.../` or `.../-`, * use the preceding path segment</li> * <li>if the name would otherwise be empty, and the node is a bNode, use the anon-ID</li> * <li>if the name would otherwise be empty, use the full URI</li> * </ul> */ @Override public String getName() { String name = super.getName(); if (name.isEmpty() || name.matches("^\\s*$") || name.equals( getURI() )) { if (isAnon()) { name = asRDFNode().asResource().getId().toString(); } else { Matcher match = lnmatch.matcher(getURI()); if (match.matches()) { name = match.group(1); } else { name = getURI(); } } } return name; }
protected String spelling( RDFNode n ) { if (n.isURIResource()) return resourceSpelling( (Resource) n ); if (n.isLiteral()) return ((Literal) n).getLexicalForm(); String id = ((Resource) n).getId().toString(); return id; }
aTerm = ATermUtils.makeBnode(r.getId().toString());
aTerm = ATermUtils.makeBnode( node.getBlankNodeId().toString() );