Search in sources :

Example 16 with JsopTokenizer

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;
}
Also used : JsonObject(org.apache.jackrabbit.oak.commons.json.JsonObject) JsopTokenizer(org.apache.jackrabbit.oak.commons.json.JsopTokenizer)

Example 17 with JsopTokenizer

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);
        }
    }
}
Also used : JsopTokenizer(org.apache.jackrabbit.oak.commons.json.JsopTokenizer)

Example 18 with JsopTokenizer

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);
}
Also used : JsopTokenizer(org.apache.jackrabbit.oak.commons.json.JsopTokenizer)

Example 19 with JsopTokenizer

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 '-'.");
    }
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) JsopTokenizer(org.apache.jackrabbit.oak.commons.json.JsopTokenizer)

Aggregations

JsopTokenizer (org.apache.jackrabbit.oak.commons.json.JsopTokenizer)19 JsopReader (org.apache.jackrabbit.oak.commons.json.JsopReader)5 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)3 JsonObject (org.apache.jackrabbit.oak.commons.json.JsonObject)3 Nonnull (javax.annotation.Nonnull)2 Blob (org.apache.jackrabbit.oak.api.Blob)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Node (javax.jcr.Node)1 Tree (org.apache.jackrabbit.oak.api.Tree)1 JsopBuilder (org.apache.jackrabbit.oak.commons.json.JsopBuilder)1 ReferencedBlob (org.apache.jackrabbit.oak.plugins.blob.ReferencedBlob)1 DocumentStoreException (org.apache.jackrabbit.oak.plugins.document.DocumentStoreException)1 RDBJSONSupport.appendJsonString (org.apache.jackrabbit.oak.plugins.document.rdb.RDBJSONSupport.appendJsonString)1 Utils.unshareString (org.apache.jackrabbit.oak.plugins.document.util.Utils.unshareString)1