}
return json.toString();
}
public static NodeImpl fromString(NodeMap map, String s) {
JsopTokenizer t = new JsopTokenizer(s);
NodeImpl node = new NodeImpl(map, 0);
if (!t.matches('{')) {
node.id = map.parseId(t.readRawValue());
t.read('=');
t.read('{');
}
boolean descendantCountSet = false;
if (!t.matches('}')) {
do {
String key = t.readString();
t.read(':');
String value = t.readRawValue();
if (key.length() > 0 && key.charAt(0) == ':') {
if (key.equals(CHILDREN)) {
node.childNodes = NodeListTrie.read(t, map, value);
} else if (key.equals(DESCENDANT_COUNT)) {
node.descendantCount = Long.parseLong(value);
descendantCountSet = true;
} else if (key.equals(HASH)) {
node.id.setHash(StringUtils.convertHexToBytes(JsopTokenizer.decodeQuoted(value)));
} else {
node.setProperty(key, value);
}
} else if (map.isId(value)) {
if (node.childNodes == null) {
node.childNodes = new NodeListSmall();
}
NodeId id = map.parseId(value);
node.childNodes.add(key, id);
if (!descendantCountSet) {
node.descendantCount++;
}
if (id.isInline()) {
if (!descendantCountSet) {
node.descendantCount += id.getNode(map).descendantCount;
}
node.descendantInlineCount += 1 + id.getNode(map).descendantInlineCount;
}
} else {
node.setProperty(key, value);
}
} while (t.matches(','));
t.read('}');
}
return node;
}