Package org.infinispan.schematic.document

Examples of org.infinispan.schematic.document.Path


        Set<String> propertiesWithSchemas = new HashSet<String>();
        if (properties != null && properties.size() != 0) {
            for (Field field : properties.fields()) {
                String name = field.getName();
                Object value = field.getValue();
                Path path = Paths.path(parentPath, "properties", name);
                if (!(value instanceof Document)) {
                    problems.recordError(path, "Expected a nested object");
                }
                Document propertySchema = (Document)value;
                Validator propertyValidator = create(propertySchema, path);
                if (propertyValidator != null) {
                    validators.add(new PropertyValidator(name, propertyValidator));
                }
                propertiesWithSchemas.add(name);
            }
        }

        // Check the additional properties ...
        boolean additionalPropertiesAllowed = parent.getBoolean("additionalProperties", true);
        if (!additionalPropertiesAllowed) {
            validators.add(new NoOtherAllowedPropertiesValidator(propertiesWithSchemas));
        } else {
            Document additionalSchema = parent.getDocument("additionalProperties");
            if (additionalSchema != null) {
                Path path = parentPath.with("additionalProperties");
                Validator additionalValidator = create(additionalSchema, path);
                if (additionalValidator != null) {
                    validators.add(new AllowedPropertiesValidator(propertiesWithSchemas, additionalValidator));
                }
            }
View Full Code Here


        Document properties = parent.getDocument("patternProperties");
        if (properties != null && properties.size() != 0) {
            for (Field field : properties.fields()) {
                String name = field.getName();
                Object value = field.getValue();
                Path path = Paths.path(parentPath, "patternProperties", name);
                if (!(value instanceof Document)) {
                    problems.recordError(path, "Expected a nested object");
                }
                Document propertySchema = (Document)value;
                try {
View Full Code Here

                                          Problems problems,
                                          CompositeValidator validators ) {
        Object items = parent.get("items");
        if (Null.matches(items)) return;

        Path path = parentPath.with("items");
        String requiredName = parentPath.getLast();
        if (requiredName == null) return;

        // Either a schema or an array of schemas ...
        if (items instanceof Document) {
            Document schema = (Document)items;
            Validator validator = create(schema, path);
            if (validator != null) {
                validators.add(new AllItemsMatchValidator(requiredName, validator));
            }
        } else if (items instanceof List<?>) {
            // This is called "tuple typing" in the spec, and can also have 'additionalItems' ...
            List<?> array = (List<?>)items;
            List<Validator> itemValidators = new ArrayList<Validator>(array.size());
            for (Object item : array) {
                if (item instanceof Document) {
                    Validator validator = create((Document)item, path);
                    if (validator != null) {
                        itemValidators.add(validator);
                    }
                }
            }
            // Check the additional items ...
            boolean additionalItemsAllowed = parent.getBoolean("additionalItems", true);
            Validator additionalItemsValidator = null;
            if (!additionalItemsAllowed) {
                additionalItemsValidator = new NotValidValidator();
            } else {
                // additional items are allowed, but check whether there is a schema for the additional items ...
                Document additionalItems = parent.getDocument("additionalItems");
                if (additionalItems != null) {
                    Path additionalItemsPath = parentPath.with("additionalItems");
                    additionalItemsValidator = create(additionalItems, additionalItemsPath);
                }
            }

            if (!itemValidators.isEmpty()) {
View Full Code Here

            if (fieldValue != null) {
                Type actual = Type.typeFor(fieldValue);
                if (!type.isEquivalent(actual)) {
                    // See if the value is convertable ...
                    Object converted = type.convertValueFrom(fieldValue, actual);
                    Path pathToField = fieldName != null ? pathToDocument.with(fieldName) : pathToDocument;
                    String reason = "Field value for '" + pathToField + "' expected to be of type " + type + " but was of type "
                                    + actual;
                    if (converted != null) {
                        // We could convert the value, so record this as a special error ...
                        problems.recordTypeMismatch(pathToField, reason, actual, fieldValue, type, converted);
View Full Code Here

            output.writeObject(put.values);
        }

        @Override
        public RetainAllValuesOperation readObject( ObjectInput input ) throws IOException, ClassNotFoundException {
            Path path = (Path)input.readObject();
            Collection<?> values = (Collection<?>)input.readObject();
            return new RetainAllValuesOperation(path, values);
        }
View Full Code Here

            output.writeObject(put.newValue);
        }

        @Override
        public PutOperation readObject( ObjectInput input ) throws IOException, ClassNotFoundException {
            Path path = (Path)input.readObject();
            String fieldName = input.readUTF();
            Object newValue = input.readObject();
            return new PutOperation(path, fieldName, null, newValue);
        }
View Full Code Here

            output.writeObject(put.value);
        }

        @Override
        public AddValueIfAbsentOperation readObject( ObjectInput input ) throws IOException, ClassNotFoundException {
            Path path = (Path)input.readObject();
            Object value = input.readObject();
            return new AddValueIfAbsentOperation(path, value);
        }
View Full Code Here

    }

    @Override
    protected MutableArray mutableParent( MutableDocument delegate ) {
        Document parent = delegate;
        Path parentPath = getParentPath();
        for (String fieldName : parentPath) {
            assert parent != null : "Unexpected to find path " + parentPath + " in " + delegate + ". Unable to apply operation "
                                    + this;
            parent = parent.getDocument(fieldName);
        }
View Full Code Here

            output.writeObject(put.index);
        }

        @Override
        public RemoveAtIndexOperation readObject( ObjectInput input ) throws IOException, ClassNotFoundException {
            Path path = (Path)input.readObject();
            int index = input.readInt();
            return new RemoveAtIndexOperation(path, index);
        }
View Full Code Here

            output.writeObject(put.value);
        }

        @Override
        public SetValueOperation readObject( ObjectInput input ) throws IOException, ClassNotFoundException {
            Path path = (Path)input.readObject();
            int index = input.readInt();
            Object value = input.readObject();
            return new SetValueOperation(path, value, index);
        }
View Full Code Here

TOP

Related Classes of org.infinispan.schematic.document.Path

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.