diff --git modeshape-jcr/src/main/java/org/modeshape/jcr/federation/spi/DocumentChanges.java modeshape-jcr/src/main/java/org/modeshape/jcr/federation/spi/DocumentChanges.java new file mode 100644 index 0000000..f1e014b --- /dev/null +++ modeshape-jcr/src/main/java/org/modeshape/jcr/federation/spi/DocumentChanges.java @@ -0,0 +1,166 @@ +/* + * ModeShape (http://www.modeshape.org) + * See the COPYRIGHT.txt file distributed with this work for information + * regarding copyright ownership. Some portions may be licensed + * to Red Hat, Inc. under one or more contributor license agreements. + * See the AUTHORS.txt file in the distribution for a full listing of + * individual contributors. + * + * ModeShape is free software. Unless otherwise indicated, all code in ModeShape + * is licensed to you under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * ModeShape is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.modeshape.jcr.federation.spi; + +import java.util.List; +import java.util.Set; +import org.infinispan.schematic.document.Changes; +import org.modeshape.jcr.cache.CachedNode.ReferenceType; +import org.modeshape.jcr.cache.ChildReference; +import org.modeshape.jcr.cache.ChildReferences; +import org.modeshape.jcr.cache.NodeKey; +import org.modeshape.jcr.value.Name; + +/** + * + */ +public interface DocumentChanges { + + List getDocumentChanges(); + + PropertyChanges getPropertyChanges(); + + MixinChanges getMixinChanges(); + + ReferrerChanges getReferrerChanges(); + + ParentChanges getParentChanges(); + + ChildrenChanges getChildChanges(); + + public interface ChildrenChanges { + + /** + * Return whether there are any changes to the child references. + * + * @return true if there are no changes, or false if there are some additions, insertions, or removals. + */ + boolean isEmpty(); + + boolean hasInserted(); + + boolean hasAppended(); + + Iterable getInsertions(); + + Iterable getAppended(); + } + + /** + * A representation of the child references that were inserted before some other node. + */ + public interface ChildInsertions extends ChildReferences.ChildInsertions { + } + + public interface PropertyChanges { + /** + * Return whether there are any changes to the mixin types. + * + * @return true if there are no changes, or false if there are some additions or removals. + */ + boolean isEmpty(); + + Set getChangedPropertyNames(); + + Set getRemovedPropertyNames(); + } + + public interface MixinChanges { + /** + * Return whether there are any changes to the mixin types. + * + * @return true if there are no changes, or false if there are some additions or removals. + */ + boolean isEmpty(); + + /** + * Get the names of the node types that were added as mixins. + * + * @return the set of node type names that were added to the mixin types; never null but possibly empty + */ + Set getAdded(); + + /** + * Get the names of the node types that were removed as mixins. + * + * @return the set of node type names that were removed from the mixin types; never null but possibly empty + */ + Set getRemoved(); + } + + public interface ParentChanges { + + /** + * Return whether there are any changes to the parents. + * + * @return true if there are no changes, or false if there are some additions or removals. + */ + boolean isEmpty(); + + boolean hasNewParent(); + + NodeKey getNewParent(); + + /** + * Get the keys for the nodes that were added as additional parents. + * + * @return the set keys for the new additional parents; never null but possible empty + */ + Set getAddedParents(); + + /** + * Get the keys for the nodes that were removed as additional parents. + * + * @return the set keys for the removed additional parents; never null but possible empty + */ + Set getRemovedParents(); + } + + public interface ReferrerChanges { + + /** + * Return whether there are any changes to the referrers. + * + * @return true if there are no changes, or false if there are some additions or removals to/from the referrers. + */ + boolean isEmpty(); + + /** + * Get the keys for the nodes that were added as referers to this node. + * + * @param type the type of reference; may not be null + * @return the ordered list of new referrers of the given reference type + */ + List getAddedReferrers( ReferenceType type ); + + /** + * Get the keys for the nodes that were removed as referers to this node. + * + * @param type the type of reference; may not be null + * @return the ordered list of removed referrers of the given reference type + */ + List getRemovedReferrers( ReferenceType type ); + } + +}