Package org.apache.jackrabbit.oak.api

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


                String lowerBound = p.getLowerBound();
                String upperBound = p.getUpperBound();
                if (lowerBound == null && upperBound == null) {
                    // ignore
                } else {
                    CoreValueFactory vf = query.getValueFactory();
                    if (lowerBound != null) {
                        operand1.apply(f, Operator.GREATER_OR_EQUAL, vf.createValue(lowerBound));
                    }
                    if (upperBound != null) {
                        operand1.apply(f, Operator.LESS_OR_EQUAL, vf.createValue(upperBound));
                    }
                }
            } else {
                operand1.apply(f, operator, v);
            }
View Full Code Here


        // re-use existing code if possible
        int sourceType = v.getType();
        if (sourceType == targetType) {
            return v;
        }
        CoreValueFactory vf = query.getValueFactory();
        switch (sourceType) {
        case PropertyType.STRING:
            switch(targetType) {
            case PropertyType.BINARY:
                try {
                    byte[] data = v.getString().getBytes("UTF-8");
                    return vf.createValue(new ByteArrayInputStream(data));
                } catch (IOException e) {
                    // I don't know in what case that could really occur
                    // except if UTF-8 isn't supported
                    throw new IllegalArgumentException(v.getString(), e);
                }
            }
            return vf.createValue(v.getString(), targetType);
        }
        switch (targetType) {
        case PropertyType.STRING:
            return vf.createValue(v.getString());
        case PropertyType.BOOLEAN:
            return vf.createValue(v.getBoolean());
        case PropertyType.DATE:
            return vf.createValue(v.getString(), PropertyType.DATE);
        case PropertyType.LONG:
            return vf.createValue(v.getLong());
        case PropertyType.DOUBLE:
            return vf.createValue(v.getDouble());
        case PropertyType.DECIMAL:
            return vf.createValue(v.getString(), PropertyType.DECIMAL);
        case PropertyType.NAME:
            return vf.createValue(getOakPath(v.getString()), PropertyType.NAME);
        case PropertyType.PATH:
            return vf.createValue(v.getString(), PropertyType.PATH);
        case PropertyType.REFERENCE:
            return vf.createValue(v.getString(), PropertyType.REFERENCE);
        case PropertyType.WEAKREFERENCE:
            return vf.createValue(v.getString(), PropertyType.WEAKREFERENCE);
        case PropertyType.URI:
            return vf.createValue(v.getString(), PropertyType.URI);
        case PropertyType.BINARY:
            try {
                byte[] data = v.getString().getBytes("UTF-8");
                return vf.createValue(new ByteArrayInputStream(data));
            } catch (IOException e) {
                // I don't know in what case that could really occur
                // except if UTF-8 isn't supported
                throw new IllegalArgumentException(v.getString(), e);
            }
View Full Code Here

                String lowerBound = p.getLowerBound();
                String upperBound = p.getUpperBound();
                if (lowerBound == null && upperBound == null) {
                    // ignore
                } else {
                    CoreValueFactory vf = query.getValueFactory();
                    if (lowerBound != null) {
                        operand1.apply(f, Operator.GREATER_OR_EQUAL, vf.createValue(lowerBound));
                    }
                    if (upperBound != null) {
                        operand1.apply(f, Operator.LESS_OR_EQUAL, vf.createValue(upperBound));
                    }
                }
            } else {
                operand1.apply(f, operator, v);
            }
View Full Code Here

     * @param propertyValue JSON property value
     * @return the core value
     */
    protected CoreValue getCoreValue(String propertyValue) {
        // TODO data type mapping
        CoreValueFactory vf = query.getValueFactory();
        JsopReader r = new JsopTokenizer(propertyValue);
        if (r.matches('[')) {
            // TODO support arrays, but only for comparisons
            throw new IllegalArgumentException("Arrays are currently not supported: " + propertyValue);
        }
View Full Code Here

        String lockOwner = sessionDelegate.getOakPathOrThrow(JCR_LOCK_OWNER);
        String lockIsDeep = sessionDelegate.getOakPathOrThrow(JCR_LOCK_IS_DEEP);
        try {
            ContentSession session = sessionDelegate.getContentSession();
            CoreValueFactory factory = session.getCoreValueFactory();
            Root root = session.getCurrentRoot();
            Tree tree = root.getTree(dlg.getPath());
            tree.setProperty(lockOwner, factory.createValue(userID));
            tree.setProperty(lockIsDeep, factory.createValue(isDeep));
            root.commit(DefaultConflictHandler.OURS); // TODO: fail instead?
        } catch (CommitFailedException e) {
            throw new RepositoryException("Unable to lock " + this, e);
        }
View Full Code Here

                post(value, child);
            } else {
                if (tree.hasChild(name)) {
                    tree.removeChild(name);
                }
                CoreValueFactory vf = MemoryValueFactory.INSTANCE;
                if (value.isNull()) {
                    tree.removeProperty(name);
                } else if (value.isBoolean()) {
                    tree.setProperty(name, vf.createValue(value.asBoolean()));
                } else if (value.isLong()) {
                    tree.setProperty(name, vf.createValue(value.asLong()));
                } else if (value.isDouble()) {
                    tree.setProperty(name, vf.createValue(value.asDouble()));
                } else if (value.isBigDecimal()) {
                    tree.setProperty(name, vf.createValue(value.decimalValue()));
                } else {
                    tree.setProperty(name, vf.createValue(value.asText()));
                }
            }
        }
    }
View Full Code Here

            } else {
                Tree child = tree.getChild(name);
                if (child != null) {
                    child.remove();
                }
                CoreValueFactory vf = MemoryValueFactory.INSTANCE;
                if (value.isNull()) {
                    tree.removeProperty(name);
                } else if (value.isBoolean()) {
                    tree.setProperty(name, vf.createValue(value.asBoolean()));
                } else if (value.isLong()) {
                    tree.setProperty(name, vf.createValue(value.asLong()));
                } else if (value.isDouble()) {
                    tree.setProperty(name, vf.createValue(value.asDouble()));
                } else if (value.isBigDecimal()) {
                    tree.setProperty(name, vf.createValue(value.decimalValue()));
                } else {
                    tree.setProperty(name, vf.createValue(value.asText()));
                }
            }
        }
    }
View Full Code Here

        } else if (target != null && tree.getChild(target) == null) {
            throw new ItemNotFoundException("Not a child: " + target);
        } else {
            List<CoreValue> order = new ArrayList<CoreValue>();
            Set<String> added = new HashSet<String>();
            CoreValueFactory factory =
                    sessionDelegate.getContentSession().getCoreValueFactory();

            PropertyState property = tree.getProperty(PropertyState.OAK_CHILD_ORDER);
            if (property != null) {
                for (CoreValue value : property.getValues()) {
                    String name = value.getString();
                    if (!name.equals(source) && !added.contains(property)
                            && !name.startsWith(":")) {
                        if (name.equals(target)) {
                            order.add(factory.createValue(source));
                            added.add(source);
                        }
                        order.add(factory.createValue(name));
                        added.add(name);
                    }
                }
            }

            if (!added.contains(source)) {
                order.add(factory.createValue(source));
            }
            if (target != null && !added.contains(target)) {
                order.add(factory.createValue(source));
            }

            tree.setProperty(PropertyState.OAK_CHILD_ORDER, order);
        }
    }
View Full Code Here

        String lockOwner = sessionDelegate.getOakPathOrThrow(JCR_LOCK_OWNER);
        String lockIsDeep = sessionDelegate.getOakPathOrThrow(JCR_LOCK_IS_DEEP);
        try {
            ContentSession session = sessionDelegate.getContentSession();
            CoreValueFactory factory = session.getCoreValueFactory();
            Root root = session.getCurrentRoot();
            Tree tree = root.getTree(dlg.getPath());
            if (tree == null) {
                throw new ItemNotFoundException();
            }
            tree.setProperty(lockOwner, factory.createValue(userID));
            tree.setProperty(lockIsDeep, factory.createValue(isDeep));
            root.commit(DefaultConflictHandler.OURS); // TODO: fail instead?
        } catch (CommitFailedException e) {
            throw new RepositoryException("Unable to lock " + this, e);
        }
View Full Code Here

                        "Node type " + jcrName + " already exists");
            }
        }
        type = types.addChild(oakName);

        CoreValueFactory factory = session.getCoreValueFactory();
        NodeUtil node = new NodeUtil(factory, mapper, type);
        node.setName("jcr:nodeTypeName", jcrName);
        node.setNames("jcr:supertypes", ntd.getDeclaredSupertypeNames());
        node.setBoolean("jcr:isAbstract", ntd.isAbstract());
        node.setBoolean("jcr:isQueryable", ntd.isQueryable());
View Full Code Here

TOP

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

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.