Examples of JsopTokenizer


Examples of org.apache.jackrabbit.mk.json.JsopTokenizer

        assertEquals("{\":rights\":\"read\",\":childNodeCount\":2,\":user\":{\":rights\":\"admin\",\":childNodeCount\":2,\"guest\":{},\"sa\":{}},\"test\":{\"data\":\"Hello\",\":childNodeCount\":0}}", mkAdmin.getNodes("/", head));
        assertEquals("{\":childNodeCount\":1,\"test\":{\"data\":\"Hello\",\":childNodeCount\":0}}", mkGuest.getNodes("/", head));
    }

    private String filterJournal(String journal) {
        JsopTokenizer t = new JsopTokenizer(journal);
        StringBuilder buff = new StringBuilder();
        t.read('[');
        boolean isNew = false;
        do {
            t.read('{');
            Assert.assertEquals("id", t.readString());
            t.read(':');
            t.readString();
            t.read(',');
            Assert.assertEquals("ts", t.readString());
            t.read(':');
            t.read(JsopReader.NUMBER);
            t.read(',');
            Assert.assertEquals("msg", t.readString());
            t.read(':');
            t.read();
            t.read(',');
            Assert.assertEquals("changes", t.readString());
            t.read(':');
            String changes = t.readString().trim();
            if (isNew) {
                if (buff.length() > 0) {
                    buff.append('\n');
                }
                buff.append(changes);
            }
            // the first revision isn't new, all others are
            isNew = true;
            t.read('}');
        } while (t.matches(','));
        return buff.toString();
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.json.JsopTokenizer

    private static void cleanRepository(MicroKernel mk) {
        String result = mk.getNodes("/", mk.getHeadRevision(), 0, 0, -1, null);
        List<String> names = new ArrayList<String>();
        List<String> properties = new ArrayList<String>();
        JsopReader t = new JsopTokenizer(result);
        t.read('{');
        if (!t.matches('}')) {
            do {
                String key = t.readString();
                t.read(':');
                if (t.matches('{')) {
                    names.add(key);
                    NodeImpl.parse(new NodeMap(), t, 0);
                } else {
                    if (!key.equals(":childNodeCount")) {
                        properties.add(key);
                    } else if (!key.equals(":hash")) {
                        properties.add(key);
                    }
                    t.readRawValue();
                }
            } while (t.matches(','));
            t.read('}');
        }
        if (!names.isEmpty()) {
            JsopBuilder buff = new JsopBuilder();
            for (String name : names) {
                buff.tag('-').value(name).newline();
View Full Code Here

Examples of org.apache.jackrabbit.mk.json.JsopTokenizer

    }

    private String getJournal() {
        if (journalRevision == null) {
            String revs = mk.getRevisionHistory(0, 1);
            JsopTokenizer t = new JsopTokenizer(revs);
            t.read('[');
            do {
                t.read('{');
                Assert.assertEquals("id", t.readString());
                t.read(':');
                journalRevision = t.readString();
                t.read(',');
                Assert.assertEquals("ts", t.readString());
                t.read(':');
                t.read(JsopReader.NUMBER);
                t.read(',');
                Assert.assertEquals("msg", t.readString());
                t.read(':');
                t.read();
                t.read('}');
            } while (t.matches(','));
        }
        String head = mk.getHeadRevision();
        String journal = mk.getJournal(journalRevision, head, null);
        JsopTokenizer t = new JsopTokenizer(journal);
        StringBuilder buff = new StringBuilder();
        t.read('[');
        boolean isNew = false;
        do {
            t.read('{');
            Assert.assertEquals("id", t.readString());
            t.read(':');
            t.readString();
            t.read(',');
            Assert.assertEquals("ts", t.readString());
            t.read(':');
            t.read(JsopReader.NUMBER);
            t.read(',');
            Assert.assertEquals("msg", t.readString());
            t.read(':');
            t.read();
            t.read(',');
            Assert.assertEquals("changes", t.readString());
            t.read(':');
            String changes = t.readString().trim();
            if (isNew) {
                if (buff.length() > 0) {
                    buff.append('\n');
                }
                buff.append(changes);
            }
            // the first revision isn't new, all others are
            isNew = true;
            t.read('}');
        } while (t.matches(','));
        journalRevision = head;
        return buff.toString();
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.json.JsopTokenizer

    private void init() {
        if (list != null) {
            return;
        }
        tokenizer = new JsopTokenizer(jsop, start);
        tokenizer.read('[');
        if (tokenizer.matches(']')) {
            list = EMPTY_LIST;
            tokenizer = null;
        } else {
View Full Code Here

Examples of org.apache.jackrabbit.mk.json.JsopTokenizer

    }

    private String getJournal() {
        if (journalRevision == null) {
            String revs = mk.getRevisionHistory(0, 1);
            JsopTokenizer t = new JsopTokenizer(revs);
            t.read('[');
            do {
                t.read('{');
                Assert.assertEquals("id", t.readString());
                t.read(':');
                journalRevision = t.readString();
                t.read(',');
                Assert.assertEquals("ts", t.readString());
                t.read(':');
                t.read(JsopReader.NUMBER);
                t.read(',');
                Assert.assertEquals("msg", t.readString());
                t.read(':');
                t.read();
                t.read('}');
            } while (t.matches(','));
        }
        String head = mk.getHeadRevision();
        String journal = mk.getJournal(journalRevision, head, null);
        JsopTokenizer t = new JsopTokenizer(journal);
        StringBuilder buff = new StringBuilder();
        t.read('[');
        boolean isNew = false;
        do {
            t.read('{');
            Assert.assertEquals("id", t.readString());
            t.read(':');
            t.readString();
            t.read(',');
            Assert.assertEquals("ts", t.readString());
            t.read(':');
            t.read(JsopReader.NUMBER);
            t.read(',');
            Assert.assertEquals("msg", t.readString());
            t.read(':');
            t.read();
            t.read(',');
            Assert.assertEquals("changes", t.readString());
            t.read(':');
            String changes = t.readString().trim();
            if (isNew) {
                if (buff.length() > 0) {
                    buff.append('\n');
                }
                buff.append(changes);
            }
            // the first revision isn't new, all others are
            isNew = true;
            t.read('}');
        } while (t.matches(','));
        journalRevision = head;
        return buff.toString();
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.json.JsopTokenizer

    private void init() {
        if (map != null) {
            return;
        }
        tokenizer = new JsopTokenizer(jsop, start);
        tokenizer.read('{');
        if (tokenizer.matches('}')) {
            map = EMPTY_MAP;
            tokenizer = null;
        } else {
View Full Code Here

Examples of org.apache.jackrabbit.mk.json.JsopTokenizer

    @Test
    public void testFromJsonValue() throws IOException {
        for (CoreValue v : singleValueMap.keySet()) {
            String json = singleValueMap.get(v);
            JsopReader reader = new JsopTokenizer(json);
            assertEquals(v, CoreValueMapper.fromJsopReader(reader, valueFactory));
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.json.JsopTokenizer

    @Test
    public void testListFromJsopReader() throws IOException {
        for (String json : mvValueMap.keySet()) {
            List<CoreValue> values = mvValueMap.get(json);
            JsopReader reader = new JsopTokenizer(json);
            if (reader.matches('[')) {
                assertEquals(values, CoreValueMapper.listFromJsopReader(reader, valueFactory));
            }
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.json.JsopTokenizer

        if (!mk.nodeExists(nodePath, lastRevision)) {
            return;
        }
        // TODO remove: support large trees
        String node = mk.getNodes(nodePath, lastRevision, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, null);
        JsopTokenizer t = new JsopTokenizer(node);
        NodeMap map = new NodeMap();
        t.read('{');
        NodeImpl n = NodeImpl.parse(map, t, 0, path);
        if (n.hasProperty(property)) {
            n.setPath(nodePath);
            for (Index index : indexes.values()) {
                index.addOrRemoveProperty(nodePath, property, n.getProperty(property), false);
View Full Code Here

Examples of org.apache.jackrabbit.mk.json.JsopTokenizer

        if (!mk.nodeExists(sourcePath, lastRevision)) {
            return;
        }
        // TODO move: support large trees
        String node = mk.getNodes(sourcePath, lastRevision, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, null);
        JsopTokenizer t = new JsopTokenizer(node);
        NodeMap map = new NodeMap();
        t.read('{');
        NodeImpl n = NodeImpl.parse(map, t, 0, sourcePath);
        if (remove) {
            addOrRemoveRecursive(n, true, false);
        }
        if (targetPath != null) {
            t = new JsopTokenizer(node);
            map = new NodeMap();
            t.read('{');
            n = NodeImpl.parse(map, t, 0, targetPath);
            addOrRemoveRecursive(n, false, true);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.