private void writeBNode(BNode bNode) throws IOException { String nextId = bNode.getID(); writer.append("_:"); if (nextId.isEmpty()) { writer.append("genid"); writer.append(Integer.toHexString(bNode.hashCode())); } else { if (!NTriplesUtil.isLetter(nextId.charAt(0))) { writer.append("genid"); writer.append(Integer.toHexString(nextId.charAt(0))); } for (int i = 0; i < nextId.length(); i++) { if (NTriplesUtil.isLetterOrNumber(nextId.charAt(i))) { writer.append(nextId.charAt(i)); } else { // Append the character as its hex representation writer.append(Integer.toHexString(nextId.charAt(i))); } } } }
/** * Checks whether the supplied character is valid character as per N-Triples specification. * See <a href="https://www.w3.org/TR/n-triples/#BNodes">https://www.w3.org/TR/n-triples/#BNodes</a>. * */ public static boolean isValidCharacterForBNodeLabel(int c) { return isLetterOrNumber(c) || isLiberalCharactersButNotDot(c) || isDot(c); }
public static void append(BNode bNode, Appendable appendable) throws IOException { String nextId = bNode.getID(); appendable.append("_:"); if (nextId.isEmpty()) { appendable.append("genid"); appendable.append(Integer.toHexString(bNode.hashCode())); } else { if (!isLetter(nextId.charAt(0))) { appendable.append("genid"); appendable.append(Integer.toHexString(nextId.charAt(0))); } for (int i = 0; i < nextId.length(); i++) { if (isLetterOrNumber(nextId.charAt(i))) { appendable.append(nextId.charAt(i)); } else { // Append the character as its hex representation appendable.append(Integer.toHexString(nextId.charAt(i))); } } } }
public static void append(BNode bNode, Appendable appendable) throws IOException { String nextId = bNode.getID(); appendable.append("_:"); if (nextId.isEmpty()) { appendable.append("genid"); appendable.append(Integer.toHexString(bNode.hashCode())); } else { if (!isLetter(nextId.charAt(0))) { appendable.append("genid"); appendable.append(Integer.toHexString(nextId.charAt(0))); } for (int i = 0; i < nextId.length(); i++) { if (isLetterOrNumber(nextId.charAt(i))) { appendable.append(nextId.charAt(i)); } else { // Append the character as its hex representation appendable.append(Integer.toHexString(nextId.charAt(i))); } } } }
/** * Checks whether the supplied character is valid character as per N-Triples specification. * See <a href="https://www.w3.org/TR/n-triples/#BNodes">https://www.w3.org/TR/n-triples/#BNodes</a>. * */ public static boolean isValidCharacterForBNodeLabel(int c) { return isLetterOrNumber(c) || isLiberalCharactersButNotDot(c) || isDot(c); }
private void writeBNode(BNode bNode) throws IOException { String nextId = bNode.getID(); writer.append("_:"); if (nextId.isEmpty()) { writer.append("genid"); writer.append(Integer.toHexString(bNode.hashCode())); } else { if (!NTriplesUtil.isLetter(nextId.charAt(0))) { writer.append("genid"); writer.append(Integer.toHexString(nextId.charAt(0))); } for (int i = 0; i < nextId.length(); i++) { if (NTriplesUtil.isLetterOrNumber(nextId.charAt(i))) { writer.append(nextId.charAt(i)); } else { // Append the character as its hex representation writer.append(Integer.toHexString(nextId.charAt(i))); } } } }
throwEOFException(); else if (!NTriplesUtil.isLetterOrNumber(c) && !NTriplesUtil.isUnderscore(c)) { reportError( "Expected a letter or number or underscore, found: " + new String(Character.toChars(c)),
throwEOFException(); else if (!NTriplesUtil.isLetterOrNumber(c) && !NTriplesUtil.isUnderscore(c)) { reportError( "Expected a letter or number or underscore, found: " + new String(Character.toChars(c)),