| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.cache.AbstractNode<K,V>
org.jboss.cache.optimistic.WorkspaceNodeImpl<K,V>
public class WorkspaceNodeImpl<K,V>
Wraps an ordinary Node and adds versioning and other meta data to it.
| Field Summary | 
|---|
| Fields inherited from class org.jboss.cache.AbstractNode | 
|---|
| children, deleted, fqn | 
| Constructor Summary | |
|---|---|
| WorkspaceNodeImpl(NodeSPI<K,V> node,
                  TransactionWorkspace workspace)Constructs with a node and workspace. | |
| Method Summary | |
|---|---|
|  Node<K,V> | addChild(Fqn f)Adds a child node with the given Fqnunder the current node. | 
|  void | addChild(WorkspaceNode child)Adds a given WorkspaceNode to the current node's child map | 
|  void | clearData()Removes all mappings from the node's data map. | 
|  NodeSPI<K,V> | createChild(java.lang.Object child_name,
            NodeSPI<K,V> parent,
            CacheSPI<K,V> cache,
            DataVersion version)Creates a child node. | 
|  int | dataSize() | 
|  V | get(K key)Returns the value to which this node maps the specified key. | 
| protected  CacheSPI<K,V> | getCache() | 
|  NodeSPI<K,V> | getChild(Fqn f)Returns the child node | 
|  NodeSPI<K,V> | getChild(java.lang.Object childName)Overrides Node.getChild(Object)to return aNodeSPIrather than aNode | 
|  java.util.Set<Node<K,V>> | getChildren()Returns an immutable set of children nodes. | 
|  java.util.Set<java.lang.Object> | getChildrenNames()Returns an immutable set of children node names. | 
|  java.util.Map<K,V> | getData()Returns a map containing the data in this Node. | 
|  Fqn | getFqn()Returns the Fqnwhich represents the location of thisNodein the cache structure. | 
|  java.util.Set<K> | getKeys()Returns a Setcontaining the data in thisNode. | 
|  java.util.List<java.util.Set<Fqn>> | getMergedChildren()Returns 2 Sets - a set of children added (first set) and a set of children removed. | 
|  java.util.Map<K,V> | getMergedData()Attempts to merge data changed during the current transaction with the data in the underlying tree. | 
|  NodeSPI<K,V> | getNode()Retrieves a reference to the underlying NodeSPIinstance. | 
|  NodeSPI<K,V> | getNodeSPI() | 
|  Node<K,V> | getParent()Returns the parent node. | 
|  TransactionWorkspace | getTransactionWorkspace()Retrieves a TransactionWorkspace instance associated with the current transaction, which the current WorkspaceNode instance lives in. | 
|  DataVersion | getVersion()Retrieves the data version of the in-memory node. | 
|  boolean | hasChild(Fqn f)Returns true if the child node denoted by the relative Fqnpassed in exists. | 
|  boolean | isChildrenModified() | 
|  boolean | isCreated() | 
|  boolean | isDirty()Returns true if this node is dirty. | 
|  boolean | isVersioningImplicit()Tests whether versioning for the WorkspaceNode instance in the current transaction is implicit (i.e., using DefaultDataVersionrather than a customDataVersionpassed in usingOption.setDataVersion(DataVersion)) | 
|  void | markAsCreated()Marks the instance as having been created in the current transaction. | 
|  V | put(K key,
    V value)Associates the specified value with the specified key for this node. | 
|  void | putAll(java.util.Map<K,V> data)Copies all of the mappings from the specified map to this node's map. | 
|  V | putIfAbsent(K k,
            V v)If the specified key is not already associated with a value, associate it with the given value, and returns the Object (if any) that occupied the space, or null. | 
|  V | remove(K key)Removes the mapping for this key from this node if it is present. | 
|  boolean | removeChild(Fqn f)Removes a child node specified by the given relative Fqn. | 
|  boolean | removeChild(java.lang.Object childName)Removes a child node specified by the given name. | 
|  V | replace(K key,
        V value)Replace entry for key only if currently mapped to some value. | 
|  boolean | replace(K key,
        V oldValue,
        V newValue)Replace entry for key only if currently mapped to given value. | 
|  void | replaceAll(java.util.Map<K,V> data)Similar to Node.putAll(java.util.Map)except that it removes any entries that exists in
 the data map first. | 
|  void | setVersion(DataVersion version)Sets the data version of this workspace node. | 
|  void | setVersioningImplicit(boolean b)Sets whether versioning for the WorkspaceNode instance in the current transaction is implicit (i.e., using DefaultDataVersionrather than a customDataVersionpassed in usingOption.setDataVersion(DataVersion)) | 
|  java.lang.String | toString() | 
| Methods inherited from class org.jboss.cache.AbstractNode | 
|---|
| equals, hashCode, isDeleted, markAsDeleted, markAsDeleted | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, finalize, getClass, notify, notifyAll, wait, wait, wait | 
| Methods inherited from interface org.jboss.cache.optimistic.WorkspaceNode | 
|---|
| isDeleted, markAsDeleted, markAsDeleted | 
| Constructor Detail | 
|---|
public WorkspaceNodeImpl(NodeSPI<K,V> node,
                         TransactionWorkspace workspace)
| Method Detail | 
|---|
public boolean isChildrenModified()
isChildrenModified in interface WorkspaceNode<K,V>public boolean isDirty()
isDirty in interface WorkspaceNode<K,V>public Fqn getFqn()
NodeFqn which represents the location of this Node in the cache structure.  The Fqn returned is absolute.
getFqn in interface Node<K,V>Fqn which represents the location of this Node in the cache structure.  The Fqn returned is absolute.public void putAll(java.util.Map<K,V> data)
NodeNode node; for (Map.Entry me : map.entrySet()) node.put(me.getKey(), me.getValue());
putAll in interface Node<K,V>data - map to copy frompublic void replaceAll(java.util.Map<K,V> data)
NodeNode.putAll(java.util.Map) except that it removes any entries that exists in
 the data map first.  Note that this happens atomically, under a single lock.  This is the analogous
 to doing a Node.clearData() followed by a Node.putAll(java.util.Map) in the same transaction.
replaceAll in interface Node<K,V>data - map to copy from
public V put(K key,
             V value)
Node
put in interface Node<K,V>key - key with which the specified value is to be associated.value - value to be associated with the specified key.
public V remove(K key)
Nodenull if the node contained no mapping for this key
remove in interface Node<K,V>key - key whose mapping is to be removed
null
         if there was no mapping for keypublic V get(K key)
Nodenull if the node contains no mapping for this key.
get in interface Node<K,V>key - key of the data to return
null if the map contains no mapping for this keypublic java.util.Set<K> getKeys()
NodeSet containing the data in this Node.
getKeys in interface Node<K,V>Set containing the data in this Node.  If there is no data, an empty Set is returned.  The Set returned is always immutable.public java.util.Set<java.lang.Object> getChildrenNames()
Node
getChildrenNames in interface Node<K,V>Set of child node names.  Empty Set if there aren't any children.public Node<K,V> getParent()
Nodenull.
getParent in interface Node<K,V>
public NodeSPI<K,V> createChild(java.lang.Object child_name,
                                NodeSPI<K,V> parent,
                                CacheSPI<K,V> cache,
                                DataVersion version)
WorkspaceNode
createChild in interface WorkspaceNode<K,V>child_name - Object name of the child to createparent - A reference to the parent nodecache - CacheSPI instance to create this node inversion - DataVersion to apply to the child.  If null, DefaultDataVersion.ZERO will be used.
public boolean isVersioningImplicit()
WorkspaceNodeDefaultDataVersion
 rather than a custom DataVersion passed in using Option.setDataVersion(DataVersion))
isVersioningImplicit in interface WorkspaceNode<K,V>public void setVersioningImplicit(boolean b)
WorkspaceNodeDefaultDataVersion
 rather than a custom DataVersion passed in using Option.setDataVersion(DataVersion))
setVersioningImplicit in interface WorkspaceNode<K,V>b - set to true if versioning is implicit, false otherwise.public NodeSPI<K,V> getChild(java.lang.Object childName)
WorkspaceNodeNode.getChild(Object) to return a NodeSPI rather than a Node
getChild in interface Node<K,V>getChild in interface WorkspaceNode<K,V>childName - name of the child
public NodeSPI<K,V> getNode()
WorkspaceNodeNodeSPI instance.
getNode in interface WorkspaceNode<K,V>public DataVersion getVersion()
WorkspaceNode
getVersion in interface WorkspaceNode<K,V>public void setVersion(DataVersion version)
WorkspaceNode
setVersion in interface WorkspaceNode<K,V>version - a DataVersion implementation.public java.util.List<java.util.Set<Fqn>> getMergedChildren()
WorkspaceNode
getMergedChildren in interface WorkspaceNode<K,V>public java.util.Map<K,V> getMergedData()
WorkspaceNode
getMergedData in interface WorkspaceNode<K,V>public TransactionWorkspace getTransactionWorkspace()
WorkspaceNode
getTransactionWorkspace in interface WorkspaceNode<K,V>public boolean isCreated()
isCreated in interface WorkspaceNode<K,V>public void markAsCreated()
WorkspaceNode
markAsCreated in interface WorkspaceNode<K,V>public java.util.Map<K,V> getData()
NodeNode.
getData in interface Node<K,V>Map containing the data in this Node.  If there is no data, an empty Map is returned.  The Map returned is always immutable.public java.lang.String toString()
toString in class java.lang.Objectpublic Node<K,V> addChild(Fqn f)
NodeFqn under the current node.  Returns the newly created node.
 
 If the child exists returns the child node anyway.  Guaranteed to return a non-null node.
 
 The Fqn passed in is relative to the current node.  The new child node will have an absolute fqn
 calculated as follows: new Fqn(getFqn(), f). See
Fqn for the operation of this constructor.
addChild in interface Node<K,V>f - Fqn of the child node, relative to the current node.
public void addChild(WorkspaceNode child)
WorkspaceNode
addChild in interface WorkspaceNode<K,V>public void clearData()
Node
clearData in interface Node<K,V>public int dataSize()
dataSize in interface Node<K,V>public NodeSPI<K,V> getChild(Fqn f)
Node
getChild in interface Node<K,V>getChild in interface WorkspaceNode<K,V>f - Fqn of the child node
public java.util.Set<Node<K,V>> getChildren()
Node
getChildren in interface Node<K,V>Set of child nodes.  Empty Set if there aren't any children.public boolean hasChild(Fqn f)
NodeFqn passed in exists.
hasChild in interface Node<K,V>f - Fqn relative to the current node of the child you are testing the existence of.
Fqn passed in exists.public NodeSPI<K,V> getNodeSPI()
public V putIfAbsent(K k,
                     V v)
Node
   if (!node.getKeys().contains(key))
     return node.put(key, value);
   else
     return node.get(key);
 
 
 except that this is atomic.
putIfAbsent in interface Node<K,V>k - key with which the specified value is to be associated.v - value to be associated with the specified key.
public V replace(K key,
                 V value)
Node
 if ((node.getKeys().contains(key))
 {
     return node.put(key, value);
 }
 else
     return null;
 
 
 except that this is atomic.
replace in interface Node<K,V>key - key with which the specified value is associated.value - value to be associated with the specified key.
public boolean replace(K key,
                       V oldValue,
                       V newValue)
Node
 if (node.get(key).equals(oldValue))
 {
     node.putAll(key, newValue);
     return true;
 }
 else
     return false;
 
 
 except that this is atomic.
replace in interface Node<K,V>key - key with which the specified value is associated.oldValue - value expected to be associated with the specified key.newValue - value to be associated with the specified key.
public boolean removeChild(Fqn f)
NodeFqn.
 
 If you wish to remove children based on absolute Fqns, use the Cache interface instead.
removeChild in interface Node<K,V>f - Fqn of the child node, relative to the current node.
public boolean removeChild(java.lang.Object childName)
Node
removeChild in interface Node<K,V>childName - name of the child node, directly under the current node.
protected CacheSPI<K,V> getCache()
| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||