org.apache.jackrabbit.core.state
Class NodeState

java.lang.Object
  extended byorg.apache.jackrabbit.core.state.ItemState
      extended byorg.apache.jackrabbit.core.state.NodeState
All Implemented Interfaces:
ItemStateListener, Serializable
Direct Known Subclasses:
VirtualNodeState

public class NodeState
extends ItemState

NodeState represents the state of a Node.

See Also:
Serialized Form

Nested Class Summary
static class NodeState.ChildNodeEntry
          ChildNodeEntry specifies the name, index (in the case of same-name siblings) and the UUID of a child node entry.
 
Field Summary
 
Fields inherited from class org.apache.jackrabbit.core.state.ItemState
overlayedState, status, STATUS_EXISTING, STATUS_EXISTING_MODIFIED, STATUS_EXISTING_REMOVED, STATUS_NEW, STATUS_STALE_DESTROYED, STATUS_STALE_MODIFIED, STATUS_UNDEFINED
 
Constructor Summary
NodeState(NodeId id, QName nodeTypeName, NodeId parentId, int initialStatus, boolean isTransient)
          Constructs a new node state that is not connected.
NodeState(NodeState overlayedState, int initialStatus, boolean isTransient)
          Constructs a new node state that is initially connected to an overlayed state.
 
Method Summary
 NodeState.ChildNodeEntry addChildNodeEntry(QName nodeName, NodeId id)
          Adds a new ChildNodeEntry.
 void addListener(ItemStateListener listener)
          Add an ItemStateListener

If the listener passed is at the same time a NodeStateListener we add it to our list of specialized listeners.

 void addPropertyName(QName propName)
          Adds a property name entry.
protected  void copy(ItemState state)
          Copy state information from another state into this state
 List getAddedChildNodeEntries()
          Returns a list of child node entries that do not exist in the overlayed node state but have been added to this node state.
 Set getAddedPropertyNames()
          Returns a set of QNames denoting those properties that do not exist in the overlayed node state but have been added to this node state.
 List getChildNodeEntries()
          Returns a list of ChildNodeEntry objects denoting the child nodes of this node.
 List getChildNodeEntries(QName nodeName)
          Returns a list of ChildNodeEntrys with the specified name.
 NodeState.ChildNodeEntry getChildNodeEntry(NodeId id)
          Returns the ChildNodeEntry with the specified NodeId or null if there's no matching entry.
 NodeState.ChildNodeEntry getChildNodeEntry(QName nodeName, int index)
          Returns the ChildNodeEntry with the specified name and index or null if there's no matching entry.
 NodeDefId getDefinitionId()
          Returns the id of the definition applicable to this node state.
 ItemId getId()
          Returns the identifier of this item.
 Set getMixinTypeNames()
          Returns the names of this node's mixin types.
 NodeId getNodeId()
          Returns the identifier of this node.
 QName getNodeTypeName()
          Returns the name of this node's node type.
 NodeId getParentId()
          Returns the NodeId of the parent NodeState or null if either this item state represents the root node or this item state is 'free floating', i.e. not attached to the repository's hierarchy.
 Set getPropertyNames()
          Returns the names of this node's properties as a set of QNames objects.
 List getRemovedChildNodeEntries()
          Returns a list of child node entries, that exist in the overlayed node state but have been removed from this node state.
 Set getRemovedPropertyNames()
          Returns a set of QNames denoting those properties that exist in the overlayed node state but have been removed from this node state.
 List getReorderedChildNodeEntries()
          Returns a list of child node entries that exist both in this node state and in the overlayed node state but have been reordered.
 boolean hasChildNodeEntries()
          Determines if there are any child node entries.
 boolean hasChildNodeEntry(NodeId id)
          Determines if there is a ChildNodeEntry with the specified NodeId.
 boolean hasChildNodeEntry(QName name)
          Determines if there is a ChildNodeEntry with the specified name.
 boolean hasChildNodeEntry(QName name, int index)
          Determines if there is a ChildNodeEntry with the specified name and index.
 boolean hasPropertyName(QName propName)
          Determines if there is a property entry with the specified QName.
 boolean isNode()
          Determines if this item state represents a node.
protected  void notifyNodeAdded(NodeState.ChildNodeEntry added)
          Notify the listeners that a child node entry has been added
protected  void notifyNodeRemoved(NodeState.ChildNodeEntry removed)
          Notify the listeners that a child node entry has been removed
protected  void notifyNodesReplaced()
          Notify the listeners that the child node entries have been replaced
 void removeAllChildNodeEntries()
          Removes all ChildNodeEntrys.
 void removeAllPropertyNames()
          Removes all property name entries.
 boolean removeChildNodeEntry(NodeId id)
          Removes a ChildNodeEntry.
 boolean removeChildNodeEntry(QName nodeName, int index)
          Removes a ChildNodeEntry.
 void removeListener(ItemStateListener listener)
          Remove an ItemStateListener

If the listener passed is at the same time a NodeStateListener we remove it from our list of specialized listeners.

 boolean removePropertyName(QName propName)
          Removes a property name entry.
 boolean renameChildNodeEntry(QName oldName, int index, QName newName)
          Renames a new ChildNodeEntry.
 void setChildNodeEntries(List nodeEntries)
          Sets the list of ChildNodeEntry objects denoting the child nodes of this node.
 void setDefinitionId(NodeDefId defId)
          Sets the id of the definition applicable to this node state.
 void setMixinTypeNames(Set names)
          Sets the names of this node's mixin types.
 void setNodeTypeName(QName nodeTypeName)
          Set the node type name.
 void setParentId(NodeId parentId)
          Sets the id of this node's parent.
 void setPropertyNames(Set propNames)
          Sets the set of QName objects denoting the properties of this node.
 
Methods inherited from class org.apache.jackrabbit.core.state.ItemState
connect, discard, disconnect, getModCount, getOverlayedState, getStatus, hasOverlayedState, isStale, isTransient, notifyStateCreated, notifyStateDestroyed, notifyStateDiscarded, notifyStateUpdated, reconnect, setModCount, setStatus, stateCreated, stateDestroyed, stateDiscarded, stateModified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeState

public NodeState(NodeState overlayedState,
                 int initialStatus,
                 boolean isTransient)
Constructs a new node state that is initially connected to an overlayed state.

Parameters:
overlayedState - the backing node state being overlayed
initialStatus - the initial status of the node state object
isTransient - flag indicating whether this state is transient or not

NodeState

public NodeState(NodeId id,
                 QName nodeTypeName,
                 NodeId parentId,
                 int initialStatus,
                 boolean isTransient)
Constructs a new node state that is not connected.

Parameters:
id - id of this node
nodeTypeName - node type of this node
parentId - id of the parent node
initialStatus - the initial status of the node state object
isTransient - flag indicating whether this state is transient or not
Method Detail

copy

protected void copy(ItemState state)
Copy state information from another state into this state

Specified by:
copy in class ItemState
Parameters:
state - source state information

isNode

public final boolean isNode()
Determines if this item state represents a node.

Specified by:
isNode in class ItemState
Returns:
always true

getParentId

public NodeId getParentId()
Returns the NodeId of the parent NodeState or null if either this item state represents the root node or this item state is 'free floating', i.e. not attached to the repository's hierarchy.

Specified by:
getParentId in class ItemState
Returns:
the parent NodeState's Id

getId

public ItemId getId()
Returns the identifier of this item.

Specified by:
getId in class ItemState
Returns:
the id of this item.

getNodeId

public NodeId getNodeId()
Returns the identifier of this node.

Returns:
the id of this node.

setParentId

public void setParentId(NodeId parentId)
Sets the id of this node's parent.

Parameters:
parentId - the parent node's id or null if either this node state should represent the root node or this node state should be 'free floating', i.e. detached from the workspace's hierarchy.

getNodeTypeName

public QName getNodeTypeName()
Returns the name of this node's node type.

Returns:
the name of this node's node type.

getMixinTypeNames

public Set getMixinTypeNames()
Returns the names of this node's mixin types.

Returns:
a set of the names of this node's mixin types.

setMixinTypeNames

public void setMixinTypeNames(Set names)
Sets the names of this node's mixin types.

Parameters:
names - set of names of mixin types

getDefinitionId

public NodeDefId getDefinitionId()
Returns the id of the definition applicable to this node state.

Returns:
the id of the definition

setDefinitionId

public void setDefinitionId(NodeDefId defId)
Sets the id of the definition applicable to this node state.

Parameters:
defId - the id of the definition

hasChildNodeEntries

public boolean hasChildNodeEntries()
Determines if there are any child node entries.

Returns:
true if there are child node entries, false otherwise.

hasChildNodeEntry

public boolean hasChildNodeEntry(QName name)
Determines if there is a ChildNodeEntry with the specified name.

Parameters:
name - QName object specifying a node name
Returns:
true if there is a ChildNodeEntry with the specified name.

hasChildNodeEntry

public boolean hasChildNodeEntry(NodeId id)
Determines if there is a ChildNodeEntry with the specified NodeId.

Parameters:
id - the id of the child node
Returns:
true if there is a ChildNodeEntry with the specified name.

hasChildNodeEntry

public boolean hasChildNodeEntry(QName name,
                                 int index)
Determines if there is a ChildNodeEntry with the specified name and index.

Parameters:
name - QName object specifying a node name
index - 1-based index if there are same-name child node entries
Returns:
true if there is a ChildNodeEntry with the specified name and index.

hasPropertyName

public boolean hasPropertyName(QName propName)
Determines if there is a property entry with the specified QName.

Parameters:
propName - QName object specifying a property name
Returns:
true if there is a property entry with the specified QName.

getChildNodeEntry

public NodeState.ChildNodeEntry getChildNodeEntry(QName nodeName,
                                                  int index)
Returns the ChildNodeEntry with the specified name and index or null if there's no matching entry.

Parameters:
nodeName - QName object specifying a node name
index - 1-based index if there are same-name child node entries
Returns:
the ChildNodeEntry with the specified name and index or null if there's no matching entry.

getChildNodeEntry

public NodeState.ChildNodeEntry getChildNodeEntry(NodeId id)
Returns the ChildNodeEntry with the specified NodeId or null if there's no matching entry.

Parameters:
id - the id of the child node
Returns:
the ChildNodeEntry with the specified NodeId or null if there's no matching entry.
See Also:
addChildNodeEntry(org.apache.jackrabbit.name.QName, org.apache.jackrabbit.core.NodeId), removeChildNodeEntry(org.apache.jackrabbit.name.QName, int)

getChildNodeEntries

public List getChildNodeEntries()
Returns a list of ChildNodeEntry objects denoting the child nodes of this node.

Returns:
list of ChildNodeEntry objects
See Also:
addChildNodeEntry(org.apache.jackrabbit.name.QName, org.apache.jackrabbit.core.NodeId), removeChildNodeEntry(org.apache.jackrabbit.name.QName, int)

getChildNodeEntries

public List getChildNodeEntries(QName nodeName)
Returns a list of ChildNodeEntrys with the specified name.

Parameters:
nodeName - name of the child node entries that should be returned
Returns:
list of ChildNodeEntry objects
See Also:
addChildNodeEntry(org.apache.jackrabbit.name.QName, org.apache.jackrabbit.core.NodeId), removeChildNodeEntry(org.apache.jackrabbit.name.QName, int)

addChildNodeEntry

public NodeState.ChildNodeEntry addChildNodeEntry(QName nodeName,
                                                  NodeId id)
Adds a new ChildNodeEntry.

Parameters:
nodeName - QName object specifying the name of the new entry.
id - the id the new entry is refering to.
Returns:
the newly added ChildNodeEntry

renameChildNodeEntry

public boolean renameChildNodeEntry(QName oldName,
                                    int index,
                                    QName newName)
Renames a new ChildNodeEntry.

Parameters:
oldName - QName object specifying the entry's old name
index - 1-based index if there are same-name child node entries
newName - QName object specifying the entry's new name
Returns:
true if the entry was sucessfully renamed; otherwise false

removeChildNodeEntry

public boolean removeChildNodeEntry(QName nodeName,
                                    int index)
Removes a ChildNodeEntry.

Parameters:
nodeName - ChildNodeEntry object specifying a node name
index - 1-based index if there are same-name child node entries
Returns:
true if the specified child node entry was found in the list of child node entries and could be removed.

removeChildNodeEntry

public boolean removeChildNodeEntry(NodeId id)
Removes a ChildNodeEntry.

Parameters:
id - the id of the entry to be removed
Returns:
true if the specified child node entry was found in the list of child node entries and could be removed.

removeAllChildNodeEntries

public void removeAllChildNodeEntries()
Removes all ChildNodeEntrys.


setChildNodeEntries

public void setChildNodeEntries(List nodeEntries)
Sets the list of ChildNodeEntry objects denoting the child nodes of this node.


getPropertyNames

public Set getPropertyNames()
Returns the names of this node's properties as a set of QNames objects.

Returns:
set of QNames objects
See Also:
addPropertyName(org.apache.jackrabbit.name.QName), removePropertyName(org.apache.jackrabbit.name.QName)

addPropertyName

public void addPropertyName(QName propName)
Adds a property name entry.

Parameters:
propName - QName object specifying the property name

removePropertyName

public boolean removePropertyName(QName propName)
Removes a property name entry.

Parameters:
propName - QName object specifying the property name
Returns:
true if the specified property name was found in the list of property name entries and could be removed.

removeAllPropertyNames

public void removeAllPropertyNames()
Removes all property name entries.


setPropertyNames

public void setPropertyNames(Set propNames)
Sets the set of QName objects denoting the properties of this node.


setNodeTypeName

public void setNodeTypeName(QName nodeTypeName)
Set the node type name. Needed for deserialization and should therefore not change the internal status.

Parameters:
nodeTypeName - node type name

getAddedPropertyNames

public Set getAddedPropertyNames()
Returns a set of QNames denoting those properties that do not exist in the overlayed node state but have been added to this node state.

Returns:
set of QNames denoting the properties that have been added.

getAddedChildNodeEntries

public List getAddedChildNodeEntries()
Returns a list of child node entries that do not exist in the overlayed node state but have been added to this node state.

Returns:
list of added child node entries

getRemovedPropertyNames

public Set getRemovedPropertyNames()
Returns a set of QNames denoting those properties that exist in the overlayed node state but have been removed from this node state.

Returns:
set of QNames denoting the properties that have been removed.

getRemovedChildNodeEntries

public List getRemovedChildNodeEntries()
Returns a list of child node entries, that exist in the overlayed node state but have been removed from this node state.

Returns:
list of removed child node entries

getReorderedChildNodeEntries

public List getReorderedChildNodeEntries()
Returns a list of child node entries that exist both in this node state and in the overlayed node state but have been reordered.

The list may include only the minimal set of nodes that have been reordered. That is, even though a certain number of nodes have changed their absolute position the list may include less that this number of nodes.

Example:
Initial state:

  + node1
  + node2
  + node3
 
After reorder:
  + node2
  + node3
  + node1
 
All nodes have changed their absolute position. The returned list however may only return that node1 has been reordered (from the first position to the end).

Returns:
list of reordered child node enties.

addListener

public void addListener(ItemStateListener listener)
Add an ItemStateListener

If the listener passed is at the same time a NodeStateListener we add it to our list of specialized listeners.

Overrides:
addListener in class ItemState
Parameters:
listener - the new listener to be informed on modifications

removeListener

public void removeListener(ItemStateListener listener)
Remove an ItemStateListener

If the listener passed is at the same time a NodeStateListener we remove it from our list of specialized listeners.

Overrides:
removeListener in class ItemState
Parameters:
listener - an existing listener

notifyNodeAdded

protected void notifyNodeAdded(NodeState.ChildNodeEntry added)
Notify the listeners that a child node entry has been added


notifyNodesReplaced

protected void notifyNodesReplaced()
Notify the listeners that the child node entries have been replaced


notifyNodeRemoved

protected void notifyNodeRemoved(NodeState.ChildNodeEntry removed)
Notify the listeners that a child node entry has been removed



Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.