org.jboss.cache
Class UnversionedNode<K,V>

java.lang.Object
  extended by org.jboss.cache.AbstractNode<K,V>
      extended by org.jboss.cache.UnversionedNode<K,V>
All Implemented Interfaces:
InternalNode<K,V>
Direct Known Subclasses:
PessimisticUnversionedNode

public class UnversionedNode<K,V>
extends AbstractNode<K,V>
implements InternalNode<K,V>

Basic data node class. Throws UnsupportedOperationException for version-specific methods like AbstractNode.getVersion() and AbstractNode.setVersion(org.jboss.cache.optimistic.DataVersion), defined in NodeSPI.

Since:
2.0.0
Author:
Manik Surtani (manik AT jboss DOT org)

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jboss.cache.AbstractNode
AbstractNode.NodeFlags
 
Field Summary
protected  CacheSPI<K,V> cache
           
protected  Map<K,V> data
          Map of general data keys to values.
protected  NodeSPI<K,V> delegate
           
protected static org.apache.commons.logging.Log log
          Debug log.
protected static boolean trace
           
 
Fields inherited from class org.jboss.cache.AbstractNode
children, flags, fqn
 
Constructor Summary
UnversionedNode()
          Constructs a new node with an FQN of Root.
UnversionedNode(Fqn fqn)
          Constructs a new node a given Fqn
UnversionedNode(Fqn fqn, CacheSPI<K,V> cache, boolean lockForChildInsertRemove)
           
UnversionedNode(Fqn fqn, CacheSPI<K,V> cache, boolean lockForChildInsertRemove, Map<K,V> data)
           
 
Method Summary
 void addChild(InternalNode<K,V> child)
           
 void addChild(InternalNode<K,V> child, boolean safe)
          Same as above, except that if safe is true, any Fqn ancestry checking is skipped.
 void addChild(Object nodeName, InternalNode<K,V> nodeToAdd)
           
 void clear()
           
 boolean containsKey(K key)
           
 InternalNode<K,V> copy()
          Creates a new instance of the same type and copies internal state.
protected  Map copyDataMap(Map<? extends K,? extends V> toCopyFrom)
           
protected  void copyInternals(UnversionedNode n)
           
protected  void downgradeDataMapIfNeeded()
           
 V get(K key)
           
 CacheSPI<K,V> getCache()
           
 InternalNode<K,V> getChild(Fqn f)
           
 InternalNode<K,V> getChild(Object childName)
           
 Set<InternalNode<K,V>> getChildren()
           
 Set<InternalNode<K,V>> getChildren(boolean includeMarkedForRemoval)
           
 ConcurrentMap<Object,InternalNode<K,V>> getChildrenMap()
           
 Set<Object> getChildrenNames()
           
 Map<K,V> getData()
           
 NodeSPI<K,V> getDelegate()
           
 Fqn getFqn()
          Returns the name of this node.
 Map getInternalState(boolean onlyInternalState)
           
 Set<K> getKeys()
           
 NodeSPI<K,V> getParent()
          Returns a parent by checking the TreeMap by name.
 boolean hasChildren()
           
protected  void initFlags()
          This method initialises flags on the node, by setting DATA_LOADED to true and VALID to true and all other flags to false.
 boolean isChildrenLoaded()
           
 boolean isDataLoaded()
          Returns true if the data was loaded from the cache loader.
 boolean isLockForChildInsertRemove()
           
 boolean isValid()
           
 void markAsRemoved(boolean marker, boolean recursive)
           
 void printDetails(StringBuilder sb, int indent)
           
protected  void printDetailsInMap(StringBuilder sb, int indent)
          Adds details of the node into a map as strings.
protected  void printIndent(StringBuilder sb, int indent)
           
 V put(K key, V value)
           
 void putAll(Map<? extends K,? extends V> data)
           
 void releaseObjectReferences(boolean recursive)
           
 V remove(K key)
           
 boolean removeChild(Fqn f)
           
 boolean removeChild(Object childName)
           
 void removeChildren()
           
 void setChildrenLoaded(boolean childrenLoaded)
           
 void setChildrenMap(ConcurrentMap<Object,InternalNode<K,V>> children)
           
 void setDataLoaded(boolean dataLoaded)
          Sets if the data was loaded from the cache loader.
 void setDelegate(NodeSPI<K,V> delegate)
           
 void setFqn(Fqn fqn)
          Sets the node's Fqn
 void setInternalState(Map state)
           
 void setLockForChildInsertRemove(boolean lockForChildInsertRemove)
           
 void setValid(boolean valid, boolean recursive)
           
 String toString()
          Returns a debug string.
protected  void upgradeDataMap()
           
 
Methods inherited from class org.jboss.cache.AbstractNode
addChildDirect, addChildDirect, addChildDirect, addChildDirect, addChildDirect, equals, getChildDirect, getChildDirect, getChildrenDirect, getChildrenDirect, getChildrenMapDirect, getLock, getOrCreateChild, getVersion, hashCode, isFlagSet, isRemoved, isResident, setChildrenMapDirect, setFlag, setFlag, setRemoved, setResident, setVersion, unsetFlag
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.cache.InternalNode
addChildDirect, addChildDirect, addChildDirect, addChildDirect, addChildDirect, getChildDirect, getChildDirect, getChildrenDirect, getChildrenDirect, getChildrenMapDirect, getLock, getOrCreateChild, getVersion, isRemoved, isResident, setChildrenMapDirect, setRemoved, setResident, setVersion
 

Field Detail

log

protected static org.apache.commons.logging.Log log
Debug log.


trace

protected static final boolean trace

data

protected Map<K,V> data
Map of general data keys to values.


delegate

protected NodeSPI<K,V> delegate

cache

protected CacheSPI<K,V> cache
Constructor Detail

UnversionedNode

public UnversionedNode()
Constructs a new node with an FQN of Root.


UnversionedNode

public UnversionedNode(Fqn fqn)
Constructs a new node a given Fqn

Parameters:
fqn - fqn of the node

UnversionedNode

public UnversionedNode(Fqn fqn,
                       CacheSPI<K,V> cache,
                       boolean lockForChildInsertRemove)

UnversionedNode

public UnversionedNode(Fqn fqn,
                       CacheSPI<K,V> cache,
                       boolean lockForChildInsertRemove,
                       Map<K,V> data)
Method Detail

initFlags

protected void initFlags()
This method initialises flags on the node, by setting DATA_LOADED to true and VALID to true and all other flags to false. The flags are defined in the AbstractNode.NodeFlags enum.


getDelegate

public NodeSPI<K,V> getDelegate()

setDelegate

public void setDelegate(NodeSPI<K,V> delegate)

getParent

public NodeSPI<K,V> getParent()
Returns a parent by checking the TreeMap by name.

Specified by:
getParent in interface InternalNode<K,V>

getCache

public CacheSPI<K,V> getCache()
Specified by:
getCache in interface InternalNode<K,V>

isChildrenLoaded

public boolean isChildrenLoaded()
Specified by:
isChildrenLoaded in interface InternalNode<K,V>

setChildrenLoaded

public void setChildrenLoaded(boolean childrenLoaded)
Specified by:
setChildrenLoaded in interface InternalNode<K,V>

get

public V get(K key)
Specified by:
get in interface InternalNode<K,V>

getData

public Map<K,V> getData()
Specified by:
getData in interface InternalNode<K,V>

put

public V put(K key,
             V value)
Specified by:
put in interface InternalNode<K,V>

getChild

public InternalNode<K,V> getChild(Fqn f)
Specified by:
getChild in interface InternalNode<K,V>
Overrides:
getChild in class AbstractNode<K,V>

getChild

public InternalNode<K,V> getChild(Object childName)
Specified by:
getChild in interface InternalNode<K,V>
Overrides:
getChild in class AbstractNode<K,V>

getChildren

public Set<InternalNode<K,V>> getChildren()
Specified by:
getChildren in interface InternalNode<K,V>
Overrides:
getChildren in class AbstractNode<K,V>

getChildren

public Set<InternalNode<K,V>> getChildren(boolean includeMarkedForRemoval)
Specified by:
getChildren in interface InternalNode<K,V>
Overrides:
getChildren in class AbstractNode<K,V>

getChildrenMap

public ConcurrentMap<Object,InternalNode<K,V>> getChildrenMap()
Specified by:
getChildrenMap in interface InternalNode<K,V>
Overrides:
getChildrenMap in class AbstractNode<K,V>

setChildrenMap

public void setChildrenMap(ConcurrentMap<Object,InternalNode<K,V>> children)
Specified by:
setChildrenMap in interface InternalNode<K,V>
Overrides:
setChildrenMap in class AbstractNode<K,V>

addChild

public void addChild(Object nodeName,
                     InternalNode<K,V> nodeToAdd)
Specified by:
addChild in interface InternalNode<K,V>
Overrides:
addChild in class AbstractNode<K,V>

addChild

public void addChild(InternalNode<K,V> child)
Specified by:
addChild in interface InternalNode<K,V>
Overrides:
addChild in class AbstractNode<K,V>

addChild

public void addChild(InternalNode<K,V> child,
                     boolean safe)
Description copied from interface: InternalNode
Same as above, except that if safe is true, any Fqn ancestry checking is skipped. Don't set safe to true unless you really know what you are doing!

Specified by:
addChild in interface InternalNode<K,V>
Overrides:
addChild in class AbstractNode<K,V>
Parameters:
child - child to add
safe - safety flag

remove

public V remove(K key)
Specified by:
remove in interface InternalNode<K,V>

printDetails

public void printDetails(StringBuilder sb,
                         int indent)
Specified by:
printDetails in interface InternalNode<K,V>

toString

public String toString()
Returns a debug string.

Overrides:
toString in class Object

clear

public void clear()
Specified by:
clear in interface InternalNode<K,V>

getChildrenNames

public Set<Object> getChildrenNames()
Specified by:
getChildrenNames in interface InternalNode<K,V>

getKeys

public Set<K> getKeys()
Specified by:
getKeys in interface InternalNode<K,V>

containsKey

public boolean containsKey(K key)
Specified by:
containsKey in interface InternalNode<K,V>

removeChild

public boolean removeChild(Object childName)
Specified by:
removeChild in interface InternalNode<K,V>

removeChild

public boolean removeChild(Fqn f)
Specified by:
removeChild in interface InternalNode<K,V>

putAll

public void putAll(Map<? extends K,? extends V> data)
Specified by:
putAll in interface InternalNode<K,V>

upgradeDataMap

protected final void upgradeDataMap()

downgradeDataMapIfNeeded

protected final void downgradeDataMapIfNeeded()

removeChildren

public void removeChildren()
Specified by:
removeChildren in interface InternalNode<K,V>

markAsRemoved

public void markAsRemoved(boolean marker,
                          boolean recursive)
Specified by:
markAsRemoved in interface InternalNode<K,V>
Specified by:
markAsRemoved in class AbstractNode<K,V>

printIndent

protected final void printIndent(StringBuilder sb,
                                 int indent)

getFqn

public Fqn getFqn()
Returns the name of this node.

Specified by:
getFqn in interface InternalNode<K,V>
Returns:
the node's Fqn

setFqn

public void setFqn(Fqn fqn)
Description copied from interface: InternalNode
Sets the node's Fqn

Specified by:
setFqn in interface InternalNode<K,V>
Parameters:
fqn - Fqn to set to

hasChildren

public boolean hasChildren()
Specified by:
hasChildren in interface InternalNode<K,V>

printDetailsInMap

protected void printDetailsInMap(StringBuilder sb,
                                 int indent)
Adds details of the node into a map as strings.


isDataLoaded

public boolean isDataLoaded()
Returns true if the data was loaded from the cache loader.

Specified by:
isDataLoaded in interface InternalNode<K,V>

setDataLoaded

public void setDataLoaded(boolean dataLoaded)
Sets if the data was loaded from the cache loader.

Specified by:
setDataLoaded in interface InternalNode<K,V>

isValid

public boolean isValid()
Specified by:
isValid in interface InternalNode<K,V>

setValid

public void setValid(boolean valid,
                     boolean recursive)
Specified by:
setValid in interface InternalNode<K,V>

isLockForChildInsertRemove

public boolean isLockForChildInsertRemove()
Specified by:
isLockForChildInsertRemove in interface InternalNode<K,V>

setLockForChildInsertRemove

public void setLockForChildInsertRemove(boolean lockForChildInsertRemove)
Specified by:
setLockForChildInsertRemove in interface InternalNode<K,V>

copy

public InternalNode<K,V> copy()
Description copied from interface: InternalNode
Creates a new instance of the same type and copies internal state. Note that a shallow copy is made for all fields except the data map, where a new map is created.

Specified by:
copy in interface InternalNode<K,V>
Returns:
a copy.

copyInternals

protected void copyInternals(UnversionedNode n)

setInternalState

public void setInternalState(Map state)
Specified by:
setInternalState in interface InternalNode<K,V>

copyDataMap

protected final Map copyDataMap(Map<? extends K,? extends V> toCopyFrom)

getInternalState

public Map getInternalState(boolean onlyInternalState)
Specified by:
getInternalState in interface InternalNode<K,V>

releaseObjectReferences

public void releaseObjectReferences(boolean recursive)
Specified by:
releaseObjectReferences in interface InternalNode<K,V>


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.