private synchronized void init() {
if (properties == null) {
String json = kernel.getNodes(
path, revision, 0, 0, MAX_CHILD_NODE_NAMES, null);
JsopReader reader = new JsopTokenizer(json);
reader.read('{');
properties = new LinkedHashMap<String, PropertyState>();
childNodes = new LinkedHashMap<String, NodeState>();
do {
String name = reader.readString();
reader.read(':');
if (":childNodeCount".equals(name)) {
childNodeCount =
Long.valueOf(reader.read(JsopTokenizer.NUMBER));
} else if (reader.matches('{')) {
reader.read('}');
String childPath = path + '/' + name;
if ("/".equals(path)) {
childPath = '/' + name;
}
childNodes.put(name, new KernelNodeState(
kernel, childPath, revision));
} else if (reader.matches(JsopTokenizer.NUMBER)) {
properties.put(name, new KernelPropertyState(
name, ScalarImpl.numberScalar(reader.getToken())));
} else if (reader.matches(JsopTokenizer.STRING)) {
properties.put(name, new KernelPropertyState(
name, ScalarImpl.stringScalar(reader.getToken())));
} else if (reader.matches(JsopTokenizer.TRUE)) {
properties.put(name, new KernelPropertyState(
name, ScalarImpl.booleanScalar(true)));
} else if (reader.matches(JsopTokenizer.FALSE)) {
properties.put(name, new KernelPropertyState(
name, ScalarImpl.booleanScalar(false)));
} else if (reader.matches('[')) {
properties.put(name, new KernelPropertyState(
name, readArray(reader)));
} else {
throw new IllegalArgumentException("Unexpected token: " + reader.getToken());
}
} while (reader.matches(','));
reader.read('}');
reader.read(JsopTokenizer.END);
}
}