@Test public void parseValidResourceParsesBlankNode() throws Exception { assertThat(NTuplesParserUtils.parseValidResource("_:abc"), is((Resource) VF.createBNode("abc"))); assertThat(NTuplesParserUtils.parseValidResource("_:a_b-c "), is((Resource) VF.createBNode("a_b-c"))); assertThat(NTuplesParserUtils.parseValidResource("_:abc.."), is((Resource) VF.createBNode("abc"))); }
public static Resource parseValidResource(String str) throws RDFParseException { int length = str.length(); if (length < 3) { throw new RDFParseException("String '" + str + "' is not a valid URI nor blank node"); } char firstChar = str.charAt(0); if (firstChar == '<') { int endIndex = str.indexOf('>', 1); if (endIndex < 0) { throw new RDFParseException("Expected '>' but none found in '" + str + "'"); } String uri = str.substring(1, endIndex); return VF.createURI(uri); } else if (firstChar == '_' && str.charAt(1) == ':') { int endIndex = 2; while (endIndex < length && str.charAt(endIndex) != ' ' && str.charAt(endIndex) != '\t') { endIndex++; } while (str.charAt(endIndex - 1) == '.') { endIndex--; } String nodeId = str.substring(2, endIndex); return VF.createBNode(nodeId); } else { throw new RDFParseException(String.format("Expected '>' or '_:' but found '%s' in '%s'", str.charAt(0), str)); } }
NTuplesParserUtils { public static Resource parseValidResource(String str) throws RDFParseException { int length = str.length(); if (length < 3) { throw new RDFParseException("String '" + str + "' is not a valid URI nor blank node"); } char firstChar = str.charAt(0); if (firstChar == '<') { int endIndex = str.indexOf('>', 1); if (endIndex < 0) { throw new RDFParseException("Expected '>' but none found in '" + str + "'"); } String uri = str.substring(1, endIndex); return VF.createURI(uri); } else if (firstChar == '_' && str.charAt(1) == ':') { int endIndex = 2; while (endIndex < length && str.charAt(endIndex) != ' ' && str.charAt(endIndex) != '\t') { endIndex++; } while (str.charAt(endIndex - 1) == '.') { endIndex--; } String nodeId = str.substring(2, endIndex); return VF.createBNode(nodeId); } else { throw new RDFParseException(String.format("Expected '>' or '_:' but found '%s' in '%s'", str.charAt(0), str)); } } }
NTuplesParserUtils { public static Resource parseValidResource(String str) throws RDFParseException { int length = str.length(); if (length < 3) { throw new RDFParseException("String '" + str + "' is not a valid URI nor blank node"); } char firstChar = str.charAt(0); if (firstChar == '<') { int endIndex = str.indexOf('>', 1); if (endIndex < 0) { throw new RDFParseException("Expected '>' but none found in '" + str + "'"); } String uri = str.substring(1, endIndex); return VF.createURI(uri); } else if (firstChar == '_' && str.charAt(1) == ':') { int endIndex = 2; while (endIndex < length && str.charAt(endIndex) != ' ' && str.charAt(endIndex) != '\t') { endIndex++; } while (str.charAt(endIndex - 1) == '.') { endIndex--; } String nodeId = str.substring(2, endIndex); return VF.createBNode(nodeId); } else { throw new RDFParseException(String.format("Expected '>' or '_:' but found '%s' in '%s'", str.charAt(0), str)); } }  }
NTuplesParserUtils { public static Resource parseValidResource(String str) throws RDFParseException { int length = str.length(); if (length < 3) { throw new RDFParseException("String '" + str + "' is not a valid URI nor blank node"); } char firstChar = str.charAt(0); if (firstChar == '<') { int endIndex = str.indexOf('>', 1); if (endIndex < 0) { throw new RDFParseException("Expected '>' but none found in '" + str + "'"); } String uri = str.substring(1, endIndex); return VF.createURI(uri); } else if (firstChar == '_' && str.charAt(1) == ':') { int endIndex = 2; while (endIndex < length && str.charAt(endIndex) != ' ' && str.charAt(endIndex) != '\t') { endIndex++; } while (str.charAt(endIndex - 1) == '.') { endIndex--; } String nodeId = str.substring(2, endIndex); return VF.createBNode(nodeId); } else { throw new RDFParseException(String.format("Expected '>' or '_:' but found '%s' in '%s'", str.charAt(0), str)); } }  static boolean hasMatchingRecord(NTuplesParser parser, Value comparedFirstValue); static boolean skipLessThan(NTuplesParser parser, Value comparedFirstValue, Comparator<Value> valueComparator); static Resource parseValidResource(String str); }
NTuplesParserUtils { public static Resource parseValidResource(String str) throws RDFParseException { int length = str.length(); if (length < 3) { throw new RDFParseException("String '" + str + "' is not a valid URI nor blank node"); } char firstChar = str.charAt(0); if (firstChar == '<') { int endIndex = str.indexOf('>', 1); if (endIndex < 0) { throw new RDFParseException("Expected '>' but none found in '" + str + "'"); } String uri = str.substring(1, endIndex); return VF.createURI(uri); } else if (firstChar == '_' && str.charAt(1) == ':') { int endIndex = 2; while (endIndex < length && str.charAt(endIndex) != ' ' && str.charAt(endIndex) != '\t') { endIndex++; } while (str.charAt(endIndex - 1) == '.') { endIndex--; } String nodeId = str.substring(2, endIndex); return VF.createBNode(nodeId); } else { throw new RDFParseException(String.format("Expected '>' or '_:' but found '%s' in '%s'", str.charAt(0), str)); } }  static boolean hasMatchingRecord(NTuplesParser parser, Value comparedFirstValue); static boolean skipLessThan(NTuplesParser parser, Value comparedFirstValue, Comparator<Value> valueComparator); static Resource parseValidResource(String str); static final ValueComparator VALUE_COMPARATOR; }