Package org.apache.jackrabbit.oak.api

Examples of org.apache.jackrabbit.oak.api.CoreValue


        CoreValue[] values = row.getValues();
        for (int i = 0; i < values.length; i++) {
            if (i > 0) {
                buff.append(", ");
            }
            CoreValue v = values[i];
            buff.append(v == null ? "null" : v.getString());
        }
        return buff.toString();
    }
View Full Code Here


    }

    private Operation createAddProperty() {
        String parent = chooseNodePath();
        String name = createPropertyName();
        CoreValue value = createValue();
        return new SetProperty(parent, name, value);
    }
View Full Code Here

    private Operation createSetProperty() {
        String path = choosePropertyPath();
        if (path == null) {
            return null;
        }
        CoreValue value = createValue();
        return new SetProperty(PathUtils.getParentPath(path), PathUtils.getName(path), value);
    }
View Full Code Here

        String uuid = UUID.randomUUID().toString();
        singleValueMap.put(valueFactory.createValue(uuid, PropertyType.REFERENCE), "\"ref:" +uuid+ '\"');
        singleValueMap.put(valueFactory.createValue(uuid, PropertyType.WEAKREFERENCE), "\"wea:" +uuid+ '\"');

        CoreValue binary = valueFactory.createValue(new ByteArrayInputStream("123".getBytes()));
        singleValueMap.put(binary, "\"bin:"+ binary.getString()+ '\"');

        // multi valued properties
        mvValueMap = new HashMap<String, List<CoreValue>>();
        mvValueMap.put("[]", Collections.<CoreValue>emptyList());

        List<CoreValue> strValues = new ArrayList<CoreValue>();
        strValues.add(valueFactory.createValue("abc"));
        strValues.add(valueFactory.createValue("a:bc"));
        strValues.add(valueFactory.createValue("boo:abc"));
        strValues.add(valueFactory.createValue("str:abc"));
        strValues.add(valueFactory.createValue("str:"));
        mvValueMap.put("[\"abc\",\"a:bc\",\"str:boo:abc\",\"str:str:abc\",\"str:str:\"]", strValues);

        List<CoreValue> boValues = new ArrayList<CoreValue>();
        boValues.add(valueFactory.createValue(true));
        boValues.add(valueFactory.createValue(false));
        mvValueMap.put("[true,false]", boValues);

        List<CoreValue> longs = new ArrayList<CoreValue>();
        longs.add(valueFactory.createValue(1));
        longs.add(valueFactory.createValue(2));
        longs.add(valueFactory.createValue(3));
        mvValueMap.put("[1,2,3]", longs);

        List<CoreValue> doubles = new ArrayList<CoreValue>();
        doubles.add(valueFactory.createValue(1.23));
        mvValueMap.put("[\"dou:1.23\"]", doubles);

        List<CoreValue> decimals = new ArrayList<CoreValue>();
        decimals.add(valueFactory.createValue(decimal));
        decimals.add(valueFactory.createValue(decimal));
        mvValueMap.put("[\"dec:" + decimal.toString() + "\",\"dec:" + decimal.toString() + "\"]", decimals);

        List<CoreValue> dates = Collections.singletonList(valueFactory.createValue("2012-05-01T12:00.000:00GMT", PropertyType.DATE));
        mvValueMap.put("[\"dat:2012-05-01T12:00.000:00GMT\"]", dates);

        List<CoreValue> names = Collections.singletonList(valueFactory.createValue("jcr:primaryType", PropertyType.NAME));
        mvValueMap.put("[\"nam:jcr:primaryType\"]", names);

        List<CoreValue> paths = new ArrayList<CoreValue>();
        paths.add(valueFactory.createValue("/jcr:system", PropertyType.PATH));
        paths.add(valueFactory.createValue("../../content", PropertyType.PATH));
        mvValueMap.put("[\"pat:/jcr:system\",\"pat:../../content\"]", paths);

        List<CoreValue> uris = Collections.singletonList(valueFactory.createValue("http://jackrabbit.apache.org", PropertyType.URI));
        mvValueMap.put("[\"uri:http://jackrabbit.apache.org\"]", uris);

        List<CoreValue> refs = new ArrayList<CoreValue>();
        refs.add(valueFactory.createValue(uuid, PropertyType.REFERENCE));
        mvValueMap.put("[\"ref:" +uuid+ "\"]", refs);

        List<CoreValue> wr = new ArrayList<CoreValue>();
        wr.add(valueFactory.createValue(uuid, PropertyType.WEAKREFERENCE));
        mvValueMap.put("[\"wea:" +uuid+ "\"]", wr);

        mvValueMap.put("[\"bin:"+ binary.getString()+ "\"]", Collections.singletonList(binary));
    }
View Full Code Here

        expectedProperties.put("b", valueFactory.createValue(2));
        expectedProperties.put("c", valueFactory.createValue(3));

        Iterable<? extends PropertyState> properties = tree.getProperties();
        for (PropertyState property : properties) {
            CoreValue value = expectedProperties.remove(property.getName());
            assertNotNull(value);
            assertFalse(property.isArray());
            assertEquals(value, property.getValue());
        }
View Full Code Here

    public void setProperty() throws CommitFailedException {
        RootImpl root = new RootImpl(store, "test");
        Tree tree = root.getTree("/");

        assertFalse(tree.hasProperty("new"));
        CoreValue value = valueFactory.createValue("value");
        tree.setProperty("new", value);
        PropertyState property = tree.getProperty("new");
        assertNotNull(property);
        assertEquals("new", property.getName());
        assertEquals(value, property.getValue());
View Full Code Here

        RootImpl root = new RootImpl(store, "test");
        Tree tree = root.getTree("/");

        assertEquals(3, tree.getPropertyCount());

        CoreValue value = valueFactory.createValue("foo");
        tree.setProperty("a", value);
        assertEquals(3, tree.getPropertyCount());

        tree.removeProperty("a");
        assertEquals(2, tree.getPropertyCount());
View Full Code Here

    @Test
    public void propertyStatus() throws CommitFailedException {
        RootImpl root = new RootImpl(store, "test");
        Tree tree = root.getTree("/");
        CoreValue value1 = valueFactory.createValue("V1");
        CoreValue value2 = valueFactory.createValue("V2");

        tree.setProperty("new", value1);
        assertEquals(Status.NEW, tree.getPropertyStatus("new"));
        root.commit();
View Full Code Here

        RootImpl root1 = new RootImpl(store, "test");
        RootImpl root2 = new RootImpl(store, "test");

        checkEqual(root1.getTree("/"), root2.getTree("/"));

        CoreValue value = valueFactory.createValue("V1");
        root2.getTree("/").addChild("one").addChild("two").addChild("three")
                .setProperty("p1", value);
        root2.commit();

        root1.rebase();
View Full Code Here

     * @param reader The JSON reader.
     * @param valueFactory The factory used to create the value.
     * @return The value such as defined by the token obtained from the reader.
     */
    public static CoreValue fromJsopReader(JsopReader reader, CoreValueFactory valueFactory) {
        CoreValue value;
        if (reader.matches(JsopTokenizer.NUMBER)) {
            String number = reader.getToken();
            value = valueFactory.createValue(Long.valueOf(number));
        } else if (reader.matches(JsopTokenizer.TRUE)) {
            value = valueFactory.createValue(true);
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.api.CoreValue

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.