@Test public void testParseStringUnicode() { DocViewProperty p = DocViewProperty.parse("foo", "{String}he\\u000fllo"); assertEquals(p, false, PropertyType.STRING, "he\u000fllo"); }
public static DocViewProperty parse(String name, String value) { boolean isMulti = false; boolean isBinaryRef = false; int type = PropertyType.UNDEFINED; int pos = 0; char state = 'b'; List<String> vals = null; StringBuffer tmp = new StringBuffer(); int unicode = 0; int unicodePos = 0; while (pos < value.length()) { char c = value.charAt(pos++); switch (state) { case 'b': if (c == '{') { state = 't'; } else if (c == '[') { isMulti = true; state = 'v'; } else if (c == '\\') { state = 'e'; } else { tmp.append(c); state = 'v'; } break; case 'a': if (c == '[') { isMulti = true; state = 'v'; } else if (c == '\\') { state = 'e'; } else { tmp.append(c); state = 'v'; } break; case 't': if (c == '}') { if (BINARY_REF.equals(tmp.toString())) { type = PropertyType.BINARY; isBinaryRef = true; } else { type = PropertyType.valueFromName(tmp.toString()); } tmp.setLength(0); state = 'a'; } else { tmp.append(c); } break; case 'v': if (c == '\\') { state = 'e'; } else if (c == ',' && isMulti) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); tmp.setLength(0); } else if (c == ']' && isMulti && pos == value.length()) { if (tmp.length() > 0 || vals != null) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); tmp.setLength(0); } } else { tmp.append(c); } break; case 'e': if (c == 'u') { state = 'u'; unicode = 0; unicodePos = 0; } else if (c == '0') { state = 'v'; if (vals == null) { vals = new LinkedList<String>(); } } else { state = 'v'; tmp.append(c); } break; case 'u': unicode = (unicode << 4) + Character.digit(c, 16); if (++unicodePos == 4) { tmp.appendCodePoint(unicode); state = 'v'; } break; } } String[] values; if (isMulti) { if (tmp.length() > 0) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); } if (vals == null) { values = Constants.EMPTY_STRING_ARRAY; } else { values = vals.toArray(new String[vals.size()]); } } else { values = new String[]{tmp.toString()}; } return new DocViewProperty(name, values, isMulti, type, isBinaryRef); }
DocViewProperty { public static DocViewProperty parse(String name, String value) { boolean isMulti = false; boolean isBinaryRef = false; int type = PropertyType.UNDEFINED; int pos = 0; char state = 'b'; List<String> vals = null; StringBuffer tmp = new StringBuffer(); int unicode = 0; int unicodePos = 0; while (pos < value.length()) { char c = value.charAt(pos++); switch (state) { case 'b': if (c == '{') { state = 't'; } else if (c == '[') { isMulti = true; state = 'v'; } else if (c == '\\') { state = 'e'; } else { tmp.append(c); state = 'v'; } break; case 'a': if (c == '[') { isMulti = true; state = 'v'; } else if (c == '\\') { state = 'e'; } else { tmp.append(c); state = 'v'; } break; case 't': if (c == '}') { if (BINARY_REF.equals(tmp.toString())) { type = PropertyType.BINARY; isBinaryRef = true; } else { type = PropertyType.valueFromName(tmp.toString()); } tmp.setLength(0); state = 'a'; } else { tmp.append(c); } break; case 'v': if (c == '\\') { state = 'e'; } else if (c == ',' && isMulti) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); tmp.setLength(0); } else if (c == ']' && isMulti && pos == value.length()) { if (tmp.length() > 0 || vals != null) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); tmp.setLength(0); } } else { tmp.append(c); } break; case 'e': if (c == 'u') { state = 'u'; unicode = 0; unicodePos = 0; } else if (c == '0') { state = 'v'; if (vals == null) { vals = new LinkedList<String>(); } } else { state = 'v'; tmp.append(c); } break; case 'u': unicode = (unicode << 4) + Character.digit(c, 16); if (++unicodePos == 4) { tmp.appendCodePoint(unicode); state = 'v'; } break; } } String[] values; if (isMulti) { if (tmp.length() > 0) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); } if (vals == null) { values = Constants.EMPTY_STRING_ARRAY; } else { values = vals.toArray(new String[vals.size()]); } } else { values = new String[]{tmp.toString()}; } return new DocViewProperty(name, values, isMulti, type, isBinaryRef); } }
DocViewProperty { public static DocViewProperty parse(String name, String value) { boolean isMulti = false; boolean isBinaryRef = false; int type = PropertyType.UNDEFINED; int pos = 0; char state = 'b'; List<String> vals = null; StringBuffer tmp = new StringBuffer(); int unicode = 0; int unicodePos = 0; while (pos < value.length()) { char c = value.charAt(pos++); switch (state) { case 'b': if (c == '{') { state = 't'; } else if (c == '[') { isMulti = true; state = 'v'; } else if (c == '\\') { state = 'e'; } else { tmp.append(c); state = 'v'; } break; case 'a': if (c == '[') { isMulti = true; state = 'v'; } else if (c == '\\') { state = 'e'; } else { tmp.append(c); state = 'v'; } break; case 't': if (c == '}') { if (BINARY_REF.equals(tmp.toString())) { type = PropertyType.BINARY; isBinaryRef = true; } else { type = PropertyType.valueFromName(tmp.toString()); } tmp.setLength(0); state = 'a'; } else { tmp.append(c); } break; case 'v': if (c == '\\') { state = 'e'; } else if (c == ',' && isMulti) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); tmp.setLength(0); } else if (c == ']' && isMulti && pos == value.length()) { if (tmp.length() > 0 || vals != null) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); tmp.setLength(0); } } else { tmp.append(c); } break; case 'e': if (c == 'u') { state = 'u'; unicode = 0; unicodePos = 0; } else if (c == '0') { state = 'v'; if (vals == null) { vals = new LinkedList<String>(); } } else { state = 'v'; tmp.append(c); } break; case 'u': unicode = (unicode << 4) + Character.digit(c, 16); if (++unicodePos == 4) { tmp.appendCodePoint(unicode); state = 'v'; } break; } } String[] values; if (isMulti) { if (tmp.length() > 0) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); } if (vals == null) { values = Constants.EMPTY_STRING_ARRAY; } else { values = vals.toArray(new String[vals.size()]); } } else { values = new String[]{tmp.toString()}; } return new DocViewProperty(name, values, isMulti, type, isBinaryRef); } DocViewProperty(String name, String[] values, boolean multi, int type);  DocViewProperty(String name, String[] values, boolean multi, int type, boolean isRef); }
DocViewProperty { public static DocViewProperty parse(String name, String value) { boolean isMulti = false; boolean isBinaryRef = false; int type = PropertyType.UNDEFINED; int pos = 0; char state = 'b'; List<String> vals = null; StringBuffer tmp = new StringBuffer(); int unicode = 0; int unicodePos = 0; while (pos < value.length()) { char c = value.charAt(pos++); switch (state) { case 'b': if (c == '{') { state = 't'; } else if (c == '[') { isMulti = true; state = 'v'; } else if (c == '\\') { state = 'e'; } else { tmp.append(c); state = 'v'; } break; case 'a': if (c == '[') { isMulti = true; state = 'v'; } else if (c == '\\') { state = 'e'; } else { tmp.append(c); state = 'v'; } break; case 't': if (c == '}') { if (BINARY_REF.equals(tmp.toString())) { type = PropertyType.BINARY; isBinaryRef = true; } else { type = PropertyType.valueFromName(tmp.toString()); } tmp.setLength(0); state = 'a'; } else { tmp.append(c); } break; case 'v': if (c == '\\') { state = 'e'; } else if (c == ',' && isMulti) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); tmp.setLength(0); } else if (c == ']' && isMulti && pos == value.length()) { if (tmp.length() > 0 || vals != null) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); tmp.setLength(0); } } else { tmp.append(c); } break; case 'e': if (c == 'u') { state = 'u'; unicode = 0; unicodePos = 0; } else if (c == '0') { state = 'v'; if (vals == null) { vals = new LinkedList<String>(); } } else { state = 'v'; tmp.append(c); } break; case 'u': unicode = (unicode << 4) + Character.digit(c, 16); if (++unicodePos == 4) { tmp.appendCodePoint(unicode); state = 'v'; } break; } } String[] values; if (isMulti) { if (tmp.length() > 0) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); } if (vals == null) { values = Constants.EMPTY_STRING_ARRAY; } else { values = vals.toArray(new String[vals.size()]); } } else { values = new String[]{tmp.toString()}; } return new DocViewProperty(name, values, isMulti, type, isBinaryRef); } DocViewProperty(String name, String[] values, boolean multi, int type);  DocViewProperty(String name, String[] values, boolean multi, int type, boolean isRef); static DocViewProperty parse(String name, String value); static String format(Property prop); static String format(Property prop, boolean sort, boolean useBinaryReferences); static boolean isAmbiguous(Property prop); boolean apply(Node node); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); }
DocViewProperty { public static DocViewProperty parse(String name, String value) { boolean isMulti = false; boolean isBinaryRef = false; int type = PropertyType.UNDEFINED; int pos = 0; char state = 'b'; List<String> vals = null; StringBuffer tmp = new StringBuffer(); int unicode = 0; int unicodePos = 0; while (pos < value.length()) { char c = value.charAt(pos++); switch (state) { case 'b': if (c == '{') { state = 't'; } else if (c == '[') { isMulti = true; state = 'v'; } else if (c == '\\') { state = 'e'; } else { tmp.append(c); state = 'v'; } break; case 'a': if (c == '[') { isMulti = true; state = 'v'; } else if (c == '\\') { state = 'e'; } else { tmp.append(c); state = 'v'; } break; case 't': if (c == '}') { if (BINARY_REF.equals(tmp.toString())) { type = PropertyType.BINARY; isBinaryRef = true; } else { type = PropertyType.valueFromName(tmp.toString()); } tmp.setLength(0); state = 'a'; } else { tmp.append(c); } break; case 'v': if (c == '\\') { state = 'e'; } else if (c == ',' && isMulti) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); tmp.setLength(0); } else if (c == ']' && isMulti && pos == value.length()) { if (tmp.length() > 0 || vals != null) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); tmp.setLength(0); } } else { tmp.append(c); } break; case 'e': if (c == 'u') { state = 'u'; unicode = 0; unicodePos = 0; } else if (c == '0') { state = 'v'; if (vals == null) { vals = new LinkedList<String>(); } } else { state = 'v'; tmp.append(c); } break; case 'u': unicode = (unicode << 4) + Character.digit(c, 16); if (++unicodePos == 4) { tmp.appendCodePoint(unicode); state = 'v'; } break; } } String[] values; if (isMulti) { if (tmp.length() > 0) { if (vals == null) { vals = new LinkedList<String>(); } vals.add(tmp.toString()); } if (vals == null) { values = Constants.EMPTY_STRING_ARRAY; } else { values = vals.toArray(new String[vals.size()]); } } else { values = new String[]{tmp.toString()}; } return new DocViewProperty(name, values, isMulti, type, isBinaryRef); } DocViewProperty(String name, String[] values, boolean multi, int type);  DocViewProperty(String name, String[] values, boolean multi, int type, boolean isRef); static DocViewProperty parse(String name, String value); static String format(Property prop); static String format(Property prop, boolean sort, boolean useBinaryReferences); static boolean isAmbiguous(Property prop); boolean apply(Node node); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); final String name; final String[] values; final boolean isMulti; final int type; final boolean isReferenceProperty; }