Package org.infinispan.schematic.internal.document

Examples of org.infinispan.schematic.internal.document.MutableDocument


        if (metadata != null) {
            if (metadata instanceof EditableDocument) metadata = ((EditableDocument)metadata).unwrap();

            // Copy all the metadata into the entry's metadata ...
            Document existingMetadata = getMetadata();
            MutableDocument newMetadata = new BasicDocument(metadata.size() + 1);
            newMetadata.put(FieldName.ID, existingMetadata.get(FieldName.ID));
            for (Field field : metadata.fields()) {
                String fieldName = field.getName();
                if (fieldName.equals(FieldName.ID)) continue;
                newMetadata.put(fieldName, field.getValue());
            }

            // Now record the change ...
            value.put(FieldName.METADATA, newMetadata);
        }
View Full Code Here


                                     AdvancedCache<String, SchematicEntry> cache,
                                     AdvancedCache<String, SchematicEntry> lockingCache ) {
        if (lockingCache != null) {
            lockingCache.lock(key);
        }
        MutableDocument copy = (MutableDocument)value.clone();
        SchematicEntryLiteral newEntry = new SchematicEntryLiteral(copy);
        cache.put(getKey(), newEntry);
        return new DocumentEditor((MutableDocument)newEntry.getContent());
    }
View Full Code Here

            output.writeObject(literal.data());
        }

        @Override
        public SchematicEntryLiteral readObject( ObjectInput input ) throws IOException, ClassNotFoundException {
            MutableDocument doc = (MutableDocument)input.readObject();
            return new SchematicEntryLiteral(doc);
        }
View Full Code Here

        public void apply( Changes changes,
                           Observer observer ) {
            if (changes.isEmpty()) {
                return;
            }
            MutableDocument mutable = asMutableDocument();
            for (Operation operation : (DocumentChanges)changes) {
                operation.replay(mutable);
                if (observer != null) {
                    if (operation instanceof SetValueOperation) {
                        SetValueOperation op = (SetValueOperation)operation;
View Full Code Here

                if (o != null) {
                    operations.add(o);
                }
            }
        };
        MutableDocument mutable = null;
        if (document instanceof MutableDocument) mutable = (MutableDocument)document;
        else if (document instanceof DocumentEditor) mutable = ((DocumentEditor)document).asMutableDocument();
        return new EditorImpl(mutable, observer, operations);
    }
View Full Code Here

        }
    }

    @Override
    public void replay( MutableDocument delegate ) {
        MutableDocument parent = mutableParent(delegate);
        assert parent != null;
        removed = parent.remove(fieldName) != null;
    }
View Full Code Here

        return absent;
    }

    @Override
    public void rollback( MutableDocument delegate ) {
        MutableDocument parent = mutableParent(delegate);
        assert parent != null;
        if (absent) {
            parent.remove(fieldName);
        }
    }
View Full Code Here

        }
    }

    @Override
    public void replay( MutableDocument delegate ) {
        MutableDocument parent = mutableParent(delegate);
        assert parent != null;
        if (!parent.containsField(fieldName)) {
            parent.put(fieldName, newValue);
            absent = true;
        }
    }
View Full Code Here

    public Path getParentPath() {
        return parentPath;
    }

    protected MutableDocument mutableParent( MutableDocument delegate ) {
        MutableDocument 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 = (MutableDocument)parent.getDocument(fieldName);
        }
        return parent;
    }
View Full Code Here

        return fieldName;
    }

    @Override
    public void rollback( MutableDocument delegate ) {
        MutableDocument parent = mutableParent(delegate);
        assert parent != null;
        if (oldValue == null) {
            parent.remove(fieldName);
        } else {
            parent.put(fieldName, oldValue);
        }
    }
View Full Code Here

TOP

Related Classes of org.infinispan.schematic.internal.document.MutableDocument

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.