Examples of ValueFactories


Examples of org.modeshape.jcr.value.ValueFactories

    protected final void internalSetValue( Value[] values )
        throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
        assert values != null;

        Object[] literals = new Object[values.length];
        ValueFactories factories = null;
        for (int i = 0; i < values.length; i++) {
            Value value = values[i];
            if (value != null) {
                JcrValue jcrValue = null;
                int type = getType();
View Full Code Here

Examples of org.modeshape.jcr.value.ValueFactories

    SystemContent( SessionCache systemCache ) {
        this.system = systemCache;
        ExecutionContext context = systemCache.getContext();
        this.propertyFactory = context.getPropertyFactory();
        ValueFactories factories = context.getValueFactories();
        this.booleans = factories.getBooleanFactory();
        this.strings = factories.getStringFactory();
        this.names = factories.getNameFactory();
        this.referenceFactory = factories.getReferenceFactory();
        this.jcrValues = new JcrValueFactory(context);
    }
View Full Code Here

Examples of org.modeshape.jcr.value.ValueFactories

            throw new RuntimeException(e);
        }
    }

    protected Node valueToNode( Object value ) throws RepositoryException {
        ValueFactories factories = context().getValueFactories();
        try {
            if (value instanceof Reference) {
                NodeKey key = null;
                if (value instanceof NodeKeyReference) {
                    // REFERENCE and WEAKREFERENCE values are node keys ...
                    key = ((NodeKeyReference)value).getNodeKey();
                } else {
                    throw new IllegalArgumentException("Unknown reference type: " + value.getClass().getSimpleName());
                }
                return session().node(key, null);
            }
            // STRING, PATH and NAME values will be convertable to a Path object ...
            Path path = factories.getPathFactory().create(value);
            return path.isAbsolute() ? session().node(path) : session().node(getParent().node(), path);
        } catch (org.modeshape.jcr.value.ValueFormatException e) {
            throw new ValueFormatException(e.getMessage(), e);
        }
        catch (PathNotFoundException pathNotFound) {
View Full Code Here

Examples of org.modeshape.jcr.value.ValueFactories

        public void visit( Literal literal ) {
            if (literal instanceof LiteralValue) {
                LiteralValue literalValue = (LiteralValue)literal;
                Value value = literalValue.getLiteralValue();
                String typeName = null;
                ValueFactories factories = context.getValueFactories();
                switch (value.getType()) {
                    case PropertyType.UNDEFINED:
                    case PropertyType.STRING:
                        append(SINGLE_QUOTE);
                        String str = factories.getStringFactory().create(literalValue.value());
                        append(str);
                        append(SINGLE_QUOTE);
                        return;
                    case PropertyType.PATH:
                        append("CAST(");
                        append(factories.getPathFactory().create(literalValue.value()));
                        append(" AS ").append(PropertyType.TYPENAME_PATH.toUpperCase()).append(')');
                        return;
                    case PropertyType.NAME:
                        append("CAST(");
                        append(factories.getNameFactory().create(literalValue.value()));
                        append(" AS ").append(PropertyType.TYPENAME_NAME.toUpperCase()).append(')');
                        return;
                    case PropertyType.REFERENCE:
                        typeName = PropertyType.TYPENAME_REFERENCE;
                        break;
                    case PropertyType.WEAKREFERENCE:
                        typeName = PropertyType.TYPENAME_WEAKREFERENCE;
                        break;
                    case org.modeshape.jcr.api.PropertyType.SIMPLE_REFERENCE:
                        typeName = org.modeshape.jcr.api.PropertyType.TYPENAME_SIMPLE_REFERENCE;
                        break;
                    case PropertyType.BINARY:
                        typeName = PropertyType.TYPENAME_BINARY;
                        break;
                    case PropertyType.BOOLEAN:
                        typeName = PropertyType.TYPENAME_BOOLEAN;
                        break;
                    case PropertyType.DATE:
                        typeName = PropertyType.TYPENAME_DATE;
                        break;
                    case PropertyType.DECIMAL:
                        typeName = PropertyType.TYPENAME_DECIMAL;
                        break;
                    case PropertyType.DOUBLE:
                        typeName = PropertyType.TYPENAME_DOUBLE;
                        break;
                    case PropertyType.LONG:
                        typeName = PropertyType.TYPENAME_LONG;
                        break;
                    case PropertyType.URI:
                        typeName = PropertyType.TYPENAME_URI;
                        break;
                }
                assert typeName != null;
                String str = factories.getStringFactory().create(literalValue.value());
                append("CAST('").append(str).append("' AS ").append(typeName.toUpperCase()).append(')');
            } else {
                Object value = literal.value();
                String typeName = null;
                ValueFactories factories = context.getValueFactories();
                if (value instanceof String || value instanceof Character) {
                    append(SINGLE_QUOTE);
                    String str = factories.getStringFactory().create(value);
                    append(str);
                    append(SINGLE_QUOTE);
                    return;
                }
                if (value instanceof Path) {
                    append("CAST(");
                    append(factories.getPathFactory().create(value));
                    append(" AS ").append(PropertyType.TYPENAME_PATH.toUpperCase()).append(')');
                    return;
                }
                if (value instanceof Name) {
                    append("CAST(");
                    append(factories.getNameFactory().create(value));
                    append(" AS ").append(PropertyType.TYPENAME_NAME.toUpperCase()).append(')');
                    return;
                }
                if (value instanceof Reference) {
                    typeName = ((Reference)value).isWeak() ? PropertyType.TYPENAME_WEAKREFERENCE.toUpperCase() : PropertyType.TYPENAME_REFERENCE.toUpperCase();
                } else if (value instanceof Binary) {
                    typeName = PropertyType.TYPENAME_BINARY.toUpperCase();
                } else if (value instanceof Boolean) {
                    typeName = PropertyType.TYPENAME_BOOLEAN.toUpperCase();
                } else if (value instanceof DateTime) {
                    typeName = PropertyType.TYPENAME_DATE.toUpperCase();
                } else if (value instanceof BigDecimal) {
                    typeName = PropertyType.TYPENAME_DECIMAL.toUpperCase();
                } else if (value instanceof Double || value instanceof Float) {
                    typeName = PropertyType.TYPENAME_DOUBLE.toUpperCase();
                } else if (value instanceof Long || value instanceof Integer || value instanceof Short) {
                    typeName = PropertyType.TYPENAME_LONG.toUpperCase();
                } else if (value instanceof URI) {
                    typeName = PropertyType.TYPENAME_URI.toUpperCase();
                }
                assert typeName != null;
                String str = factories.getStringFactory().create(value);
                append("CAST('").append(str).append("' AS ").append(typeName.toUpperCase()).append(')');
            }
        }
View Full Code Here

Examples of org.modeshape.jcr.value.ValueFactories

                             Supplier<DB> onheapDbSupplier ) {
        offheap = new DbHolder(offheapDbSupplier);
        onheap = new DbHolder(onheapDbSupplier);

        // Create the serializers ...
        ValueFactories factories = context.getValueFactories();
        serializers = MapDB.serializers(factories);
    }
View Full Code Here

Examples of org.modeshape.jcr.value.ValueFactories

            addAttribute(atts, prop, skipBinary, true);
        }

        // Special case to stub in name for root node as per JCR 1.0 Spec - 6.4.2.2
        Name name = null;
        ValueFactories valueFactories = executionContext.getValueFactories();
        if (node.getDepth() == 0) {
            name = JcrLexicon.ROOT;
        } else {
            name = valueFactories.getNameFactory().create(node.getName());
        }

        // Write out the element ...
        startElement(contentHandler, name, atts);
        if (!noRecurse) {
View Full Code Here

Examples of org.modeshape.jcr.value.ValueFactories

                                    WorkspaceCache sharedWorkspaceCache,
                                    SessionEnvironment sessionContext ) {
        this.context = context;
        this.sharedWorkspaceCache = sharedWorkspaceCache;
        this.workspaceCache.set(sharedWorkspaceCache);
        ValueFactories factories = this.context.getValueFactories();
        this.nameFactory = factories.getNameFactory();
        this.pathFactory = factories.getPathFactory();
        this.rootPath = this.pathFactory.createRootPath();
        this.sessionContext = sessionContext;
        assert this.sessionContext != null;
        checkForTransaction();
    }
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.