Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 166   Methods: 0
NCLOC: 30   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
WorkspaceNode.java - - - -
coverage
 1    /*
 2    * JBoss, Home of Professional Open Source
 3    *
 4    * Distributable under LGPL license.
 5    * See terms of license at gnu.org.
 6    */
 7    package org.jboss.cache.optimistic;
 8   
 9    import org.jboss.cache.CacheSPI;
 10    import org.jboss.cache.Fqn;
 11    import org.jboss.cache.Node;
 12    import org.jboss.cache.NodeSPI;
 13   
 14    import java.util.List;
 15    import java.util.Map;
 16    import java.util.Set;
 17   
 18    /**
 19    * Represents a type of {@link org.jboss.cache.Node} that is to be copied into a {@link TransactionWorkspace} for optimistically locked
 20    * nodes. Adds versioning and dirty flags over conventional Nodes.
 21    * <p/>
 22    * Typically used when the cache mode configured is {@link org.jboss.cache.config.Configuration.NodeLockingScheme#OPTIMISTIC}
 23    *
 24    * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik@jboss.org</a>)
 25    * @author Steve Woodcock (<a href="mailto:stevew@jofti.com">stevew@jofti.com</a>)
 26    * @since 1.3.0
 27    */
 28    public interface WorkspaceNode<K, V> extends Node<K, V>
 29    {
 30    /**
 31    * Returns 2 Sets - a set of children added (first set) and a set of children removed.
 32    *
 33    * @return a merged map of child names and Nodes
 34    */
 35    List<Set<Fqn>> getMergedChildren();
 36   
 37    /**
 38    * Retrieves the data version of the in-memory node.
 39    *
 40    * @return A data version
 41    */
 42    DataVersion getVersion();
 43   
 44    /**
 45    * Sets the data version of this workspace node.
 46    *
 47    * @param version a {@link org.jboss.cache.optimistic.DataVersion} implementation.
 48    */
 49    void setVersion(DataVersion version);
 50   
 51    /**
 52    * Returns true if this node needs to be merged when the transaction commits. A node is considered dirty if it
 53    * has just been created, deleted or it's data map has changed. If children are added or removed, the node is not
 54    * considered dirty - instead, see {@link #isChildrenModified()}.
 55    *
 56    * @return true if needs merging, false otherwise.
 57    */
 58    boolean isDirty();
 59   
 60    /**
 61    * Attempts to merge data changed during the current transaction with the data in the underlying tree.
 62    *
 63    * @return a merged map of key/value pairs.
 64    */
 65    Map<K, V> getMergedData();
 66   
 67    /**
 68    * Retrieves a reference to the underlying {@link NodeSPI} instance.
 69    *
 70    * @return a node
 71    */
 72    NodeSPI<K, V> getNode();
 73   
 74    /**
 75    * Retrieves a TransactionWorkspace instance associated with the current transaction, which the current WorkspaceNode instance
 76    * lives in.
 77    *
 78    * @return a TransactionWorkspace.
 79    */
 80    TransactionWorkspace getTransactionWorkspace();
 81   
 82    /**
 83    * @return true if the instance was created in the current transaction; i.e., it did not exist in the underlying data tree.
 84    */
 85    boolean isCreated();
 86   
 87    /**
 88    * Marks the instance as having been created in the current transaction.
 89    */
 90    void markAsCreated();
 91   
 92    /**
 93    * Creates a child node.
 94    *
 95    * @param child_name Object name of the child to create
 96    * @param parent A reference to the parent node
 97    * @param cache CacheSPI instance to create this node in
 98    * @param version DataVersion to apply to the child. If null, {@link DefaultDataVersion#ZERO} will be used.
 99    * @return a NodeSPI pointing to the newly created child.
 100    */
 101    NodeSPI createChild(Object child_name, NodeSPI<K, V> parent, CacheSPI<K, V> cache, DataVersion version);
 102   
 103    /**
 104    * Tests whether versioning for the WorkspaceNode instance in the current transaction is implicit (i.e., using {@link org.jboss.cache.optimistic.DefaultDataVersion}
 105    * rather than a custom {@link org.jboss.cache.optimistic.DataVersion} passed in using {@link org.jboss.cache.config.Option#setDataVersion(DataVersion)})
 106    *
 107    * @return true if versioning is implicit.
 108    */
 109    boolean isVersioningImplicit();
 110   
 111    /**
 112    * Sets whether versioning for the WorkspaceNode instance in the current transaction is implicit (i.e., using {@link org.jboss.cache.optimistic.DefaultDataVersion}
 113    * rather than a custom {@link org.jboss.cache.optimistic.DataVersion} passed in using {@link org.jboss.cache.config.Option#setDataVersion(DataVersion)})
 114    *
 115    * @param b set to true if versioning is implicit, false otherwise.
 116    */
 117    void setVersioningImplicit(boolean b);
 118   
 119    /**
 120    * @return true if the instance has been deleted in the current transaction.
 121    */
 122    boolean isDeleted();
 123   
 124    /**
 125    * Marks the node as being deleted (or not) in the current transaction. This is not recursive, child nodes are not affected.
 126    *
 127    * @param marker true if the node has been deleted, false if not.
 128    */
 129    void markAsDeleted(boolean marker);
 130   
 131    /**
 132    * Same as {@link #markAsDeleted(boolean)} except that the option to recurse into children is provided.
 133    *
 134    * @param marker true if the node has been deleted, false if not.
 135    * @param recursive if true, child nodes (and their children) are marked as well.
 136    */
 137    void markAsDeleted(boolean marker, boolean recursive);
 138   
 139    /**
 140    * Overrides {@link Node#getChild(Object)} to return a {@link org.jboss.cache.NodeSPI} rather than a {@link org.jboss.cache.Node}
 141    *
 142    * @param o node name
 143    * @return a child node
 144    */
 145    NodeSPI<K, V> getChild(Object o);
 146   
 147    /**
 148    * Overrides {@link Node#getChild(Fqn)} to return a {@link org.jboss.cache.NodeSPI} rather than a {@link org.jboss.cache.Node}
 149    *
 150    * @param f node fqn
 151    * @return a child node
 152    */
 153    NodeSPI<K, V> getChild(Fqn f);
 154   
 155    /**
 156    * Adds a given WorkspaceNode to the current node's child map
 157    *
 158    * @param workspaceNode
 159    */
 160    void addChild(WorkspaceNode workspaceNode);
 161   
 162    /**
 163    * @return true if children have been added to or removed from this node. Not the same as 'dirty'.
 164    */
 165    boolean isChildrenModified();
 166    }