TurtleUtil { public static String decodeString(String s) { int backSlashIdx = s.indexOf('\\'); if (backSlashIdx == -1) { return s; } int startIdx = 0; int sLength = s.length(); StringBuilder sb = new StringBuilder(sLength); while (backSlashIdx != -1) { sb.append(s.substring(startIdx, backSlashIdx)); if (backSlashIdx + 1 >= sLength) { throw new IllegalArgumentException("Unescaped backslash in: " + s); } char c = s.charAt(backSlashIdx + 1); if (c == 't') { sb.append('\t'); startIdx = backSlashIdx + 2; } else if (c == 'b') { sb.append('\b'); startIdx = backSlashIdx + 2; } else if (c == 'n') { sb.append('\n'); startIdx = backSlashIdx + 2; } else if (c == 'r') { sb.append('\r'); startIdx = backSlashIdx + 2; } else if (c == 'f') { sb.append('\f'); startIdx = backSlashIdx + 2; } else if (c == '"') { sb.append('"'); startIdx = backSlashIdx + 2; } else if (c == '\'') { sb.append('\''); startIdx = backSlashIdx + 2; } else if (c == '>') { sb.append('>'); startIdx = backSlashIdx + 2; } else if (c == '\\') { sb.append('\\'); startIdx = backSlashIdx + 2; } else if (c == 'u') { if (backSlashIdx + 5 >= sLength) { throw new IllegalArgumentException("Incomplete Unicode escape sequence in: " + s); } String xx = s.substring(backSlashIdx + 2, backSlashIdx + 6); try { final int codePoint = Integer.parseInt(xx, 16); sb.append(Character.toChars(codePoint)); startIdx = backSlashIdx + 6; } catch (NumberFormatException e) { throw new IllegalArgumentException("Illegal Unicode escape sequence '\\u" + xx + "' in: " + s); } } else if (c == 'U') { if (backSlashIdx + 9 >= sLength) { throw new IllegalArgumentException("Incomplete Unicode escape sequence in: " + s); } String xx = s.substring(backSlashIdx + 2, backSlashIdx + 10); try { final int codePoint = Integer.parseInt(xx, 16); sb.append(Character.toChars(codePoint)); startIdx = backSlashIdx + 10; } catch (NumberFormatException e) { throw new IllegalArgumentException("Illegal Unicode escape sequence '\\U" + xx + "' in: " + s); } } else { throw new IllegalArgumentException("Unescaped backslash in: " + s); } backSlashIdx = s.indexOf('\\', startIdx); } sb.append(s.substring(startIdx)); return sb.toString(); }  static int findURISplitIndex(String uri); static boolean isWhitespace(int codePoint); static boolean isPN_CHARS_BASE(int codePoint); static boolean isPN_CHARS_U(int codePoint); static boolean isPN_CHARS(int codePoint); static boolean isPrefixStartChar(int codePoint); static boolean isBLANK_NODE_LABEL_StartChar(int codePoint); static boolean isBLANK_NODE_LABEL_Char(int codePoint); static boolean isBLANK_NODE_LABEL_EndChar(int codePoint); static boolean isNameStartChar(int codePoint); static boolean isNameChar(int codePoint); static boolean isNameEndChar(int codePoint); static boolean isLocalEscapedChar(int codePoint); static boolean isPrefixChar(int codePoint); static boolean isLanguageStartChar(int codePoint); static boolean isLanguageChar(int codePoint); static boolean isPN_PREFIX(String prefix); static boolean isPLX_START(String name); static boolean isPERCENT(String name); static boolean isPLX_INTERNAL(String name); static boolean isPN_LOCAL_ESC(String name); static boolean isPN_LOCAL(String name); static String encodeString(String s); static String encodeLongString(String s); @Deprecated static String encodeURIString(String s); static String decodeString(String s); static final char[] LOCAL_ESCAPED_CHARS; }
@Ignore("TODO: Implement me") @Test public final void testDecodeString() { }