use of org.apache.jackrabbit.oak.commons.json.JsopTokenizer in project jackrabbit-oak by apache.
the class ClusterViewTest method asJsonObject.
private JsonObject asJsonObject(final ClusterView view) {
final String json = view.asDescriptorValue();
// System.out.println(json);
JsopTokenizer t = new JsopTokenizer(json);
t.read('{');
JsonObject o = JsonObject.create(t);
return o;
}
use of org.apache.jackrabbit.oak.commons.json.JsopTokenizer in project jackrabbit-oak by apache.
the class JournalEntryTest method getChildren.
private static List<String> getChildren(String diff) {
List<String> children = Lists.newArrayList();
JsopTokenizer t = new JsopTokenizer(diff);
for (; ; ) {
int r = t.read();
switch(r) {
case '^':
{
children.add(t.readString());
t.read(':');
t.read('{');
t.read('}');
break;
}
case JsopReader.END:
{
return children;
}
default:
fail("Unexpected token: " + r);
}
}
}
use of org.apache.jackrabbit.oak.commons.json.JsopTokenizer in project jackrabbit-oak by apache.
the class NodeCounterIndexTest method parseJson.
private static JsonObject parseJson(String json) {
JsopTokenizer t = new JsopTokenizer(json);
t.read('{');
return JsonObject.create(t);
}
use of org.apache.jackrabbit.oak.commons.json.JsopTokenizer in project jackrabbit-oak by apache.
the class AbstractQueryTest method apply.
/**
* Applies the commit string to a given Root instance
*
* The commit string represents a sequence of operations, jsonp style:
*
* <p>
* / + "test": { "a": { "id": "ref:123" }, "b": { "id" : "str:123" }}
* <p>
* or
* <p>
* "/ - "test"
* </p>
*
* @param root
* @param commit the commit string
* @throws UnsupportedOperationException if the operation is not supported
*/
private static void apply(Root root, String commit) throws UnsupportedOperationException {
int index = commit.indexOf(' ');
String path = commit.substring(0, index).trim();
Tree c = root.getTree(path);
if (!c.exists()) {
// TODO create intermediary?
throw new UnsupportedOperationException("Non existing path " + path);
}
commit = commit.substring(index);
JsopTokenizer tokenizer = new JsopTokenizer(commit);
if (tokenizer.matches('-')) {
removeTree(c, tokenizer);
} else if (tokenizer.matches('+')) {
addTree(c, tokenizer);
} else {
throw new UnsupportedOperationException("Unsupported " + (char) tokenizer.read() + ". This should be either '+' or '-'.");
}
}
Aggregations