public class NodeState extends ItemState
NodeState
represents the state of a Node
.overlayedState, status, STATUS_EXISTING, STATUS_EXISTING_MODIFIED, STATUS_EXISTING_REMOVED, STATUS_NEW, STATUS_STALE_DESTROYED, STATUS_UNDEFINED
Constructor and Description |
---|
NodeState(NodeId id,
Name 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.
|
Modifier and Type | Method and Description |
---|---|
ChildNodeEntry |
addChildNodeEntry(Name nodeName,
NodeId id)
Adds a new
ChildNodeEntry . |
void |
addPropertyName(Name propName)
Adds a property name entry.
|
boolean |
addShare(NodeId parentId)
Add a parent to the shared set.
|
long |
calculateMemoryFootprint()
Returns an estimate of the memory size of this node state.
|
boolean |
containsShare(NodeId parentId)
Return a flag whether the given parent id appears in the shared set.
|
void |
copy(ItemState state,
boolean syncModCount)
Copy state information from another state into this state
|
List<ChildNodeEntry> |
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<Name> |
getAddedPropertyNames()
Returns a set of
Name s denoting those properties that
do not exist in the overlayed node state but have been added to
this node state. |
Set<NodeId> |
getAddedShares()
Returns a set of shares that were added.
|
List<ChildNodeEntry> |
getChildNodeEntries()
Returns a list of
ChildNodeEntry objects denoting the
child nodes of this node. |
List<ChildNodeEntry> |
getChildNodeEntries(Name nodeName)
Returns a list of
ChildNodeEntry s with the specified name. |
ChildNodeEntry |
getChildNodeEntry(Name nodeName,
int index)
Returns the
ChildNodeEntry with the specified name and index
or null if there's no matching entry. |
ChildNodeEntry |
getChildNodeEntry(NodeId id)
Returns the
ChildNodeEntry with the specified NodeId or
null if there's no matching entry. |
ItemId |
getId()
Returns the identifier of this item.
|
Set<Name> |
getMixinTypeNames()
Returns the names of this node's mixin types.
|
NodeId |
getNodeId()
Returns the identifier of this node.
|
Name |
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. |
Set<Name> |
getPropertyNames()
Returns the names of this node's properties as a set of
QNames objects. |
List<ChildNodeEntry> |
getRemovedChildNodeEntries()
Returns a list of child node entries, that exist in the overlayed node state
but have been removed from this node state.
|
Set<Name> |
getRemovedPropertyNames()
Returns a set of
Name s denoting those properties that
exist in the overlayed node state but have been removed from
this node state. |
Set<NodeId> |
getRemovedShares()
Returns a set of shares that were removed.
|
List<ChildNodeEntry> |
getRenamedChildNodeEntries()
Returns a list of child node entries that exist both in this node
state and in the overlayed node state but have been renamed.
|
List<ChildNodeEntry> |
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.
|
Set<NodeId> |
getSharedSet()
Return the shared set as an unmodifiable collection.
|
boolean |
hasChildNodeEntries()
Determines if there are any child node entries.
|
boolean |
hasChildNodeEntry(Name name)
Determines if there is a
ChildNodeEntry with the
specified name . |
boolean |
hasChildNodeEntry(Name name,
int index)
Determines if there is a
ChildNodeEntry with the
specified name and index . |
boolean |
hasChildNodeEntry(NodeId id)
Determines if there is a
ChildNodeEntry with the
specified NodeId . |
boolean |
hasPropertyName(Name propName)
Determines if there is a property entry with the specified
Name . |
boolean |
isNode()
Determines if this item state represents a node.
|
boolean |
isShareable()
Return a flag indicating whether this state is shareable, i.e.
|
protected void |
notifyNodeAdded(ChildNodeEntry added)
Notify the listeners that a child node entry has been added
|
protected void |
notifyNodeRemoved(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
ChildNodeEntry s. |
void |
removeAllPropertyNames()
Removes all property name entries.
|
boolean |
removeChildNodeEntry(Name nodeName,
int index)
Removes a
ChildNodeEntry . |
boolean |
removeChildNodeEntry(NodeId id)
Removes a
ChildNodeEntry . |
boolean |
removePropertyName(Name propName)
Removes a property name entry.
|
int |
removeShare(NodeId parentId)
Remove a parent from the shared set.
|
boolean |
renameChildNodeEntry(Name oldName,
int index,
Name newName)
Renames a
ChildNodeEntry by removing the old entry and
appending the new entry to the end of the list. |
boolean |
renameChildNodeEntry(NodeId id,
Name newName)
Renames a
ChildNodeEntry by removing the old entry and
appending the new entry to the end of the list. |
boolean |
replaceChildNodeEntry(NodeId oldId,
Name newName,
NodeId newId)
Replaces the
ChildNodeEntry identified by oldId
with a new entry. |
void |
setChildNodeEntries(List<ChildNodeEntry> nodeEntries)
Sets the list of
ChildNodeEntry objects denoting the
child nodes of this node. |
void |
setContainer(ItemStateListener listener)
Set the parent container that will receive notifications about changes to this state.
|
void |
setMixinTypeNames(Set<Name> names)
Sets the names of this node's mixin types.
|
void |
setNodeTypeName(Name nodeTypeName)
Set the node type name.
|
void |
setParentId(NodeId parentId)
Sets the id of this node's parent.
|
void |
setPropertyNames(Set<Name> propNames)
Sets the set of
Name objects denoting the
properties of this node. |
void |
setSharedSet(Set<NodeId> set)
Set the shared set of this state to the shared set of another state.
|
connect, discard, disconnect, getContainer, getModCount, getOverlayedState, getStatus, hasOverlayedState, isConnected, isStale, isTransient, notifyStateCreated, notifyStateDestroyed, notifyStateDiscarded, notifyStateUpdated, reconnect, setModCount, setStatus
public NodeState(NodeState overlayedState, int initialStatus, boolean isTransient)
overlayedState
- the backing node state being overlayedinitialStatus
- the initial status of the node state objectisTransient
- flag indicating whether this state is transient or notpublic NodeState(NodeId id, Name nodeTypeName, NodeId parentId, int initialStatus, boolean isTransient)
id
- id of this nodenodeTypeName
- node type of this nodeparentId
- id of the parent nodeinitialStatus
- the initial status of the node state objectisTransient
- flag indicating whether this state is transient or notpublic void copy(ItemState state, boolean syncModCount)
public final boolean isNode()
public NodeId getParentId()
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.getParentId
in class ItemState
NodeState
's Idpublic ItemId getId()
public NodeId getNodeId()
public void setParentId(NodeId parentId)
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.public Name getNodeTypeName()
public Set<Name> getMixinTypeNames()
public void setMixinTypeNames(Set<Name> names)
names
- set of names of mixin typespublic boolean hasChildNodeEntries()
true
if there are child node entries,
false
otherwise.public boolean hasChildNodeEntry(Name name)
ChildNodeEntry
with the
specified name
.name
- Name
object specifying a node nametrue
if there is a ChildNodeEntry
with
the specified name
.public boolean hasChildNodeEntry(NodeId id)
ChildNodeEntry
with the
specified NodeId
.id
- the id of the child nodetrue
if there is a ChildNodeEntry
with
the specified name
.public boolean hasChildNodeEntry(Name name, int index)
ChildNodeEntry
with the
specified name
and index
.name
- Name
object specifying a node nameindex
- 1-based index if there are same-name child node entriestrue
if there is a ChildNodeEntry
with
the specified name
and index
.public boolean hasPropertyName(Name propName)
Name
.propName
- Name
object specifying a property nametrue
if there is a property entry with the specified
Name
.public ChildNodeEntry getChildNodeEntry(Name nodeName, int index)
ChildNodeEntry
with the specified name and index
or null
if there's no matching entry.nodeName
- Name
object specifying a node nameindex
- 1-based index if there are same-name child node entriesChildNodeEntry
with the specified name and index
or null
if there's no matching entry.public ChildNodeEntry getChildNodeEntry(NodeId id)
ChildNodeEntry
with the specified NodeId
or
null
if there's no matching entry.id
- the id of the child nodeChildNodeEntry
with the specified NodeId
or
null
if there's no matching entry.addChildNodeEntry(org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.core.id.NodeId)
,
removeChildNodeEntry(org.apache.jackrabbit.spi.Name, int)
public List<ChildNodeEntry> getChildNodeEntries()
ChildNodeEntry
objects denoting the
child nodes of this node.ChildNodeEntry
objectsaddChildNodeEntry(org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.core.id.NodeId)
,
removeChildNodeEntry(org.apache.jackrabbit.spi.Name, int)
public List<ChildNodeEntry> getChildNodeEntries(Name nodeName)
ChildNodeEntry
s with the specified name.nodeName
- name of the child node entries that should be returnedChildNodeEntry
objectsaddChildNodeEntry(org.apache.jackrabbit.spi.Name, org.apache.jackrabbit.core.id.NodeId)
,
removeChildNodeEntry(org.apache.jackrabbit.spi.Name, int)
public ChildNodeEntry addChildNodeEntry(Name nodeName, NodeId id)
ChildNodeEntry
.nodeName
- Name
object specifying the name of the new entry.id
- the id the new entry is refering to.ChildNodeEntry
public boolean renameChildNodeEntry(Name oldName, int index, Name newName)
ChildNodeEntry
by removing the old entry and
appending the new entry to the end of the list.oldName
- Name
object specifying the entry's old nameindex
- 1-based index if there are same-name child node entriesnewName
- Name
object specifying the entry's new nametrue
if the entry was successfully renamed;
otherwise false
public boolean renameChildNodeEntry(NodeId id, Name newName)
ChildNodeEntry
by removing the old entry and
appending the new entry to the end of the list.id
- id the entry to be renamed is refering to.newName
- Name
object specifying the entry's new nametrue
if the entry was successfully renamed;
otherwise false
public boolean replaceChildNodeEntry(NodeId oldId, Name newName, NodeId newId)
ChildNodeEntry
identified by oldId
with a new entry. Note that the entry will overwrite the old
entry at the same relative position within the child node entries list.oldId
- id the entry to be replaced is referring to.newName
- Name
object specifying the entry's new namenewId
- the id the new entry is referring to.true
if the entry was successfully replaced;
otherwise false
public boolean removeChildNodeEntry(Name nodeName, int index)
ChildNodeEntry
.nodeName
- ChildNodeEntry
object specifying a node nameindex
- 1-based index if there are same-name child node entriestrue
if the specified child node entry was found
in the list of child node entries and could be removed.public boolean removeChildNodeEntry(NodeId id)
ChildNodeEntry
.id
- the id of the entry to be removedtrue
if the specified child node entry was found
in the list of child node entries and could be removed.public void removeAllChildNodeEntries()
ChildNodeEntry
s.public void setChildNodeEntries(List<ChildNodeEntry> nodeEntries)
ChildNodeEntry
objects denoting the
child nodes of this node.nodeEntries
- list of ChildNodeEntry
spublic Set<Name> getPropertyNames()
QNames
objects.QNames
objectsaddPropertyName(org.apache.jackrabbit.spi.Name)
,
removePropertyName(org.apache.jackrabbit.spi.Name)
public void addPropertyName(Name propName)
propName
- Name
object specifying the property namepublic boolean removePropertyName(Name propName)
propName
- Name
object specifying the property nametrue
if the specified property name was found
in the list of property name entries and could be removed.public void removeAllPropertyNames()
public void setPropertyNames(Set<Name> propNames)
Name
objects denoting the
properties of this node.propNames
- set of Name
s.public void setNodeTypeName(Name nodeTypeName)
nodeTypeName
- node type namepublic boolean isShareable()
true
if this state is shareable.public boolean addShare(NodeId parentId)
parentId
- parent id to add to the shared settrue
if the parent was successfully added;
false
otherwisepublic boolean containsShare(NodeId parentId)
parentId
- parent idtrue
if the parent id appears in the shared set;
false
otherwise.public Set<NodeId> getSharedSet()
public void setSharedSet(Set<NodeId> set)
set
- shared setpublic int removeShare(NodeId parentId)
0
,
the shared set is empty, i.e. there are no more parent items
referencing this item and the state is free floating.parentId
- parent id to remove from the shared setpublic Set<Name> getAddedPropertyNames()
Name
s denoting those properties that
do not exist in the overlayed node state but have been added to
this node state.Name
s denoting the properties that have
been added.public List<ChildNodeEntry> getAddedChildNodeEntries()
public Set<Name> getRemovedPropertyNames()
Name
s denoting those properties that
exist in the overlayed node state but have been removed from
this node state.Name
s denoting the properties that have
been removed.public List<ChildNodeEntry> getRemovedChildNodeEntries()
public List<ChildNodeEntry> getRenamedChildNodeEntries()
public List<ChildNodeEntry> getReorderedChildNodeEntries()
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 + node3After reorder:
+ node2 + node3 + node1All 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).public Set<NodeId> getAddedShares()
NodeId
s.public Set<NodeId> getRemovedShares()
NodeId
s.public void setContainer(ItemStateListener listener)
If the listener passed is at the same time a NodeStateListener
we remember it as well.
setContainer
in class ItemState
listener
- container to be informed on modificationspublic long calculateMemoryFootprint()
calculateMemoryFootprint
in class ItemState
protected void notifyNodeAdded(ChildNodeEntry added)
added
- the entry that was addedprotected void notifyNodesReplaced()
protected void notifyNodeRemoved(ChildNodeEntry removed)
removed
- the entry that was removedCopyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.