Package org.modeshape.jcr.value

Examples of org.modeshape.jcr.value.ValueFactories


        }
    }

    @SuppressWarnings( "deprecation" )
    private void initializeDescriptors() {
        ValueFactories factories = new ExecutionContext().getValueFactories();

        descriptors.put(Repository.LEVEL_1_SUPPORTED, valueFor(factories, true));
        descriptors.put(Repository.LEVEL_2_SUPPORTED, valueFor(factories, true));
        descriptors.put(Repository.OPTION_LOCKING_SUPPORTED, valueFor(factories, true));
        descriptors.put(Repository.OPTION_OBSERVATION_SUPPORTED, valueFor(factories, true));
View Full Code Here


    protected void refreshWorkspaces() {
        RunningState running = runningState();
        if (running != null) {
            Set<String> workspaceNames = running.repositoryCache().getWorkspaceNames();
            ValueFactories factories = running.context().getValueFactories();
            JcrValue[] values = new JcrValue[workspaceNames.size()];
            int i = 0;
            for (String workspaceName : workspaceNames) {
                values[i++] = valueFor(factories, workspaceName);
            }
View Full Code Here

        WorkspaceCache workspace = repositoryCache.getWorkspaceCache(workspaceName);
        NodeKey rootKey = workspace.getRootKey();

        // Now create a specific reference factories that know about the root node key ...
        TextDecoder decoder = context.getDecoder();
        ValueFactories factories = context.getValueFactories();
        ReferenceFactory rootKeyAwareStrongRefFactory = NodeIdentifierReferenceFactory.newInstance(rootKey, decoder, factories,
                                                                                                   false, false);
        ReferenceFactory rootKeyAwareWeakRefFactory = NodeIdentifierReferenceFactory.newInstance(rootKey, decoder, factories,
                                                                                                 true, false);
        ReferenceFactory rootKeyAwareSimpleRefFactory = NodeIdentifierReferenceFactory.newInstance(rootKey, decoder, factories,
View Full Code Here

                                                            NodeTypes nodeTypes ) {
        JcrPropertyDefinition definition = null;
        int propertyType = PropertyTypeUtil.jcrPropertyTypeFor(property);

        // If single-valued ...
        ValueFactories factories = context().getValueFactories();
        if (isSingle) {
            // Create a value for the ModeShape property value ...
            Object value = property.getFirstValue();
            Value jcrValue = new JcrValue(factories, propertyType, value);
            definition = nodeTypes.findPropertyDefinition(session, primaryTypeNameOfParent, mixinTypeNamesOfParent,
View Full Code Here

                                 Object[] values ) {
        /*
         * Null values in the array are "compacted" (read: ignored) as per section 7.1.6 in the JCR 1.0.1 specification.
         */
        int len = values.length;
        ValueFactories factories = context().getValueFactories();
        List<JcrValue> results = new ArrayList<JcrValue>(len);
        for (int i = 0; i != len; ++i) {
            if (values[i] != null) results.add(new JcrValue(factories, propertyType, values[i]));
        }
        return results.toArray(new JcrValue[results.size()]);
View Full Code Here

    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

    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

            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

        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

                             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

TOP

Related Classes of org.modeshape.jcr.value.ValueFactories

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.