Package org.apache.jackrabbit.mk.json

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


        @Override
        public JsopReader getNodesStream(String path, String revisionId, int depth, long offset, int count, String filter) {
            String json = wrapped.getNodes(
                    path, revisionId, depth, offset, count, filter);
            if (json != null) {
                return new JsopTokenizer(json);
            } else {
                return null;
            }
        }
View Full Code Here


            }
        }

        @Override
        public JsopReader getRevisionsStream(long since, int maxEntries, String path) {
            return new JsopTokenizer(wrapped.getRevisionHistory(since, maxEntries, path));
        }
View Full Code Here

            return new JsopTokenizer(wrapped.getRevisionHistory(since, maxEntries, path));
        }

        @Override
        public JsopReader diffStream(String fromRevisionId, String toRevisionId, String path) {
            return new JsopTokenizer(wrapped.diff(fromRevisionId, toRevisionId, path));
        }
View Full Code Here

        pairs[index + 1] = StringCache.cache(value);
        return pairs;
    }

    public static NodeImpl parse(String json) {
        JsopTokenizer t = new JsopTokenizer(json);
        t.read('{');
        NodeMap map = new NodeMap();
        return NodeImpl.parse(map, t, 0);
    }
View Full Code Here

        }
        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;
    }
View Full Code Here

    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

            this.propFilter = propFilter;
        }

        static NodeFilter parse(String json) {
            // parse json format filter
            JsopTokenizer t = new JsopTokenizer(json);
            t.read('{');

            NameFilter nodeFilter = null, propFilter = null;

            do {
                String type = t.readRawValue();
                t.read(':');
                String[] globs = parseArray(t);
                if (type.equals("nodes")) {
                    nodeFilter = new NameFilter(globs);
                } else if (type.equals("properties")) {
                    propFilter = new NameFilter(globs);
                } else {
                    throw new IllegalArgumentException("illegal filter format");
                }
            } while (t.matches(','));
            t.read('}');

            return new NodeFilter(nodeFilter, propFilter);
        }
View Full Code Here

    }

    @Override
    public void addOrRemoveProperty(String nodePath, String propertyName,
            String value, boolean add) {
        JsopTokenizer t = new JsopTokenizer(value);
        if (t.matches(JsopReader.STRING)) {
            String v = t.getToken();
            if (v.startsWith(prefix)) {
                addOrRemove(nodePath, propertyName, v, add);
            }
        } else if (t.matches('[')) {
            if (!t.matches(']')) {
                do {
                    if (t.matches(JsopReader.STRING)) {
                        String v = t.getToken();
                        if (v.startsWith(prefix)) {
                            addOrRemove(nodePath, propertyName, v, add);
                        }
                    } else if (t.matches(JsopReader.FALSE)) {
                        // ignore
                    } else if (t.matches(JsopReader.TRUE)) {
                        // ignore
                    } else if (t.matches(JsopReader.NULL)) {
                        // ignore
                    } else if (t.matches(JsopReader.NUMBER)) {
                        // ignore
                    }
                } while (t.matches(','));
                t.read(']');
            }
        }
    }
View Full Code Here

        String head = mk.getHeadRevision();
        if (mk.nodeExists(MOUNT, head)) {
            String mounts = mk.getNodes(MOUNT, head, 1, 0, -1, null);
            NodeMap map = new NodeMap();
            JsopReader t = new JsopTokenizer(mounts);
            t.read('{');
            NodeImpl n = NodeImpl.parse(map, t, 0);
            for (long pos = 0;; pos++) {
                String childName = n.getChildNodeName(pos);
                if (childName == null) {
                    break;
View Full Code Here

                }
            }
            revision = mk.commit("/", jsop.toString(), revision, null);
        } else {
            String node = mk.getNodes(indexRootNode, revision, 0, 0, Integer.MAX_VALUE, null);
            JsopTokenizer t = new JsopTokenizer(node);
            t.read('{');
            HashMap<String, String> map = new HashMap<String, String>();
            do {
                String key = t.readString();
                t.read(':');
                t.read();
                String value = t.getToken();
                map.put(key, value);
            } while (t.matches(','));
            String rev = map.get("rev");
            if (rev != null) {
                readRevision = rev;
            }
            for (String k : map.keySet()) {
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.mk.json.JsopTokenizer

Copyright © 2018 www.massapicom. 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.