public class NodeEntryImpl extends Object implements NodeEntry
NodeEntryImpl
implements common functionality for child
node entry implementations.Modifier and Type | Field and Description |
---|---|
protected EntryFactory |
factory
The item state factory to create the item state.
|
protected Name |
name
The name of the target item state.
|
protected NodeEntryImpl |
parent
Hard reference to the parent
NodeEntry . |
Modifier and Type | Method and Description |
---|---|
NodeEntry |
addNewNodeEntry(Name nodeName,
String uniqueID,
Name primaryNodeType,
QNodeDefinition definition)
Adds a new, transient child
NodeEntry |
PropertyEntry |
addNewPropertyEntry(Name propName,
QPropertyDefinition definition,
QValue[] values,
int propertyType)
Add a new, transient
PropertyEntry to this NodeEntry
and return the PropertyState associated with the new entry. |
void |
calculateStatus()
Calculates the status of the underlying
ItemState : any pending
changes to the underlying ItemState are applied. |
void |
complete(Operation operation)
Clean up this entry upon
Operation.undo() or Operation.persisted() . |
boolean |
denotesNode()
Returns true.
|
NodeEntry |
getDeepNodeEntry(Path path)
Traverse the tree below this entry and return the child entry matching
the given path.
|
PropertyEntry |
getDeepPropertyEntry(Path path)
Traverse the tree below this entry and return the child entry matching
the given path.
|
long |
getGeneration()
The required generation of this
HierarchyEntry . |
NodeId |
getId() |
protected IdFactory |
getIdFactory()
Shortcut for
EntryFactory.getIdFactory() |
int |
getIndex() |
protected EntryFactory.InvalidationStrategy |
getInvalidationStrategy() |
ItemState |
getItemState()
If this
HierarchyEntry has already been resolved before
(see HierarchyEntry.isAvailable() ), that ItemState is returned. |
protected TransientItemStateFactory |
getItemStateFactory()
Shortcut for
EntryFactory.getItemStateFactory() |
Name |
getName() |
Iterator<NodeEntry> |
getNodeEntries()
Returns a unmodifiable iterator of
NodeEntry objects
denoting the the valid child NodeEntries present on this NodeEntry . |
List<NodeEntry> |
getNodeEntries(Name nodeName)
Returns a unmodifiable List of
NodeEntry s with the
specified name. |
NodeEntry |
getNodeEntry(Name nodeName,
int index)
Returns the valid
NodeEntry with the specified name
and index or null if there's no matching entry. |
NodeEntry |
getNodeEntry(Name nodeName,
int index,
boolean loadIfNotFound)
Returns the valid
NodeEntry with the specified name
and index or null if there's no matching entry. |
NodeState |
getNodeState() |
NodeEntry |
getOrAddNodeEntry(Name nodeName,
int index,
String uniqueID)
Adds a child NodeEntry to this entry if it not yet present with this
node entry.
|
PropertyEntry |
getOrAddPropertyEntry(Name propName)
Add an existing
PropertyEntry with the given name if it is
not yet contained in this NodeEntry . |
NodeEntry |
getParent()
Returns the
NodeEntry being parent to this
HierarchyEntry . |
Path |
getPath() |
protected PathFactory |
getPathFactory()
Shortcut for
EntryFactory.getPathFactory() |
Iterator<PropertyEntry> |
getPropertyEntries()
Returns an unmodifiable Iterator over those children that represent valid
PropertyEntries.
|
PropertyEntry |
getPropertyEntry(Name propName)
Returns the valid
PropertyEntry with the specified name
or null if no matching entry exists. |
PropertyEntry |
getPropertyEntry(Name propName,
boolean loadIfNotFound)
Ignores the
loadIfNotFound flag due to the fact, that
NodeInfo.getPropertyIds() returns the
complete list of property names currently available. |
int |
getStatus()
If this
HierarchyEntry provides an underlying
ItemState this method returns the status of that state,
otherwise it returns Status._UNDEFINED_ . |
String |
getUniqueID() |
NodeId |
getWorkspaceId()
Returns the ID that must be used for resolving this entry OR loading its
children entries from the persistent layer.
|
Path |
getWorkspacePath() |
boolean |
hasNodeEntry(Name nodeName)
Determines if there is a valid
NodeEntry with the
specified nodeName . |
boolean |
hasNodeEntry(Name nodeName,
int index)
Determines if there is a valid
NodeEntry with the
specified name and index . |
boolean |
hasPropertyEntry(Name propName)
Determines if there is a property entry with the specified
Name . |
void |
invalidate(boolean recursive)
Invalidates the underlying
ItemState if available and if it
is not transiently modified. |
protected void |
invalidateInternal(boolean recursive)
Invalidates the underlying
ItemState . |
boolean |
isAvailable()
Returns
true if the referenced ItemState is
available. |
boolean |
isTransientlyMoved() |
HierarchyEntry |
lookupDeepEntry(Path workspacePath)
Traverse the tree below this entry and return the child entry matching
the given 'workspacePath', i.e.
|
NodeEntry |
move(Name newName,
NodeEntry newParent,
boolean transientMove)
Moves this
NodeEntry as new child entry of the
NodeEntry identified by newParent and/or renames
it to newName . |
void |
orderBefore(NodeEntry beforeEntry)
Reorders this NodeEntry before the sibling entry specified by the given
beforeEntry . |
void |
refresh(Event childEvent)
The parent entry of a external event gets informed about the modification.
|
void |
reload(boolean recursive)
If 'recursive' is true, the complete hierarchy below this entry is
traversed and reloaded.
|
void |
remove()
Removes this
HierarchyEntry from its parent and sets the
status of the underlying ItemState to Status.REMOVED or to
Status.STALE_DESTROYED , respectively. |
void |
revert()
Calls
HierarchyEntryImpl.revert() and moves all properties from the
attic back into the properties map. |
void |
setItemState(ItemState state)
Set the ItemState this hierarchyEntry will be resolved to.
|
void |
setNodeEntries(Iterator<ChildInfo> childInfos)
Creates or updates the
ChildNodeEntries of this node. |
void |
setPropertyEntries(Collection<Name> propNames)
Adds property entries for the given
Name s. |
void |
setUniqueID(String uniqueID) |
void |
transientRemove()
Traverses the hierarchy and marks all available item states as transiently
removed.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
calculateStatus, getGeneration, getItemState, getName, getParent, getPath, getStatus, getWorkspacePath, invalidate, isAvailable, setItemState
protected Name name
protected NodeEntryImpl parent
NodeEntry
.protected final EntryFactory factory
public boolean denotesNode()
denotesNode
in interface HierarchyEntry
HierarchyEntry.denotesNode()
public void reload(boolean recursive)
reload
in interface HierarchyEntry
HierarchyEntry.reload(boolean)
public void revert() throws javax.jcr.RepositoryException
HierarchyEntryImpl.revert()
and moves all properties from the
attic back into the properties map. If this HierarchyEntry has been
transiently moved, it is in addition moved back to its old parent.
Similarly reordering of child node entries is reverted.revert
in interface HierarchyEntry
javax.jcr.RepositoryException
- if an error occurs.HierarchyEntry.revert()
public void transientRemove() throws javax.jcr.RepositoryException
Status.EXISTING_REMOVED
if
the item is existing in the persistent storage or Status.REMOVED
if the item has been transiently added before. In the latter case, the
corresponding HierarchyEntries can be removed as well from their parent.transientRemove
in interface HierarchyEntry
javax.jcr.InvalidItemStateException
- if this entry has been removed in the
mean time.javax.jcr.RepositoryException
- if an error occurs while removing any of the item
states e.g. an item state is not valid anymore.HierarchyEntry.transientRemove()
public void remove()
HierarchyEntry
HierarchyEntry
from its parent and sets the
status of the underlying ItemState to Status.REMOVED
or to
Status.STALE_DESTROYED
, respectively. If this entry is a
NodeEntry all descending ItemStates must get their status changed as well.remove
in interface HierarchyEntry
HierarchyEntry.remove()
public void complete(Operation operation) throws javax.jcr.RepositoryException
HierarchyEntry
Operation.undo()
or Operation.persisted()
.complete
in interface HierarchyEntry
javax.jcr.RepositoryException
HierarchyEntry.complete(Operation)
public NodeId getId() throws javax.jcr.InvalidItemStateException, javax.jcr.RepositoryException
getId
in interface NodeEntry
NodeId
of this child node entry.javax.jcr.InvalidItemStateException
javax.jcr.RepositoryException
NodeEntry.getId()
public NodeId getWorkspaceId() throws javax.jcr.InvalidItemStateException, javax.jcr.RepositoryException
NodeEntry
getId()
unless this entry or any of its ancestors has been
transiently moved.getWorkspaceId
in interface NodeEntry
javax.jcr.InvalidItemStateException
javax.jcr.RepositoryException
NodeEntry.getWorkspaceId()
public String getUniqueID()
getUniqueID
in interface NodeEntry
null
if the node state cannot be
identified with a unique ID.NodeEntry.getUniqueID()
public void setUniqueID(String uniqueID)
setUniqueID
in interface NodeEntry
NodeEntry.setUniqueID(String)
public int getIndex() throws javax.jcr.InvalidItemStateException, javax.jcr.RepositoryException
getIndex
in interface NodeEntry
Path.INDEX_UNDEFINED
is returned.javax.jcr.InvalidItemStateException
javax.jcr.RepositoryException
NodeEntry.getIndex()
public NodeState getNodeState() throws javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
getNodeState
in interface NodeEntry
NodeState
.javax.jcr.ItemNotFoundException
- if the NodeState
does not
exist.javax.jcr.RepositoryException
- If an error occurs while retrieving the
NodeState
.NodeEntry.getNodeState()
public NodeEntry getDeepNodeEntry(Path path) throws javax.jcr.PathNotFoundException, javax.jcr.RepositoryException
NodeEntry
getDeepNodeEntry
in interface NodeEntry
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
NodeEntry.getDeepNodeEntry(Path)
public PropertyEntry getDeepPropertyEntry(Path path) throws javax.jcr.PathNotFoundException, javax.jcr.RepositoryException
NodeEntry
getDeepPropertyEntry
in interface NodeEntry
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException
NodeEntry.getDeepPropertyEntry(Path)
public HierarchyEntry lookupDeepEntry(Path workspacePath)
NodeEntry
If no matching entry can be found, null
is return.
lookupDeepEntry
in interface NodeEntry
null
.NodeEntry.lookupDeepEntry(Path)
public boolean hasNodeEntry(Name nodeName)
NodeEntry
NodeEntry
with the
specified nodeName
.hasNodeEntry
in interface NodeEntry
nodeName
- Name
object specifying a node nametrue
if there is a NodeEntry
with
the specified nodeName
.NodeEntry.hasNodeEntry(Name)
public boolean hasNodeEntry(Name nodeName, int index)
NodeEntry
NodeEntry
with the
specified name
and index
.hasNodeEntry
in interface NodeEntry
nodeName
- Name
object specifying a node name.index
- 1-based index if there are same-name child node entries.true
if there is a NodeEntry
with
the specified name
and index
.NodeEntry.hasNodeEntry(Name, int)
public NodeEntry getNodeEntry(Name nodeName, int index) throws javax.jcr.RepositoryException
NodeEntry
NodeEntry
with the specified name
and index or null
if there's no matching entry.getNodeEntry
in interface NodeEntry
nodeName
- Name
object specifying a node name.index
- 1-based index if there are same-name child node entries.NodeEntry
with the specified name and index
or null
if there's no matching entry.javax.jcr.RepositoryException
- If an unexpected error occurs.NodeEntry.getNodeEntry(Name, int)
public NodeEntry getNodeEntry(Name nodeName, int index, boolean loadIfNotFound) throws javax.jcr.RepositoryException
NodeEntry
NodeEntry
with the specified name
and index or null
if there's no matching entry. If
loadIfNotFound
is true, the implementation must make
sure, that it's list of child entries is up to date and eventually
try to load the node entry.getNodeEntry
in interface NodeEntry
nodeName
- Name
object specifying a node name.index
- 1-based index if there are same-name child node entries.NodeEntry
with the specified name and index
or null
if there's no matching entry.javax.jcr.RepositoryException
- If an unexpected error occurs.NodeEntry.getNodeEntry(Name, int, boolean)
public Iterator<NodeEntry> getNodeEntries() throws javax.jcr.RepositoryException
NodeEntry
NodeEntry
objects
denoting the the valid child NodeEntries present on this NodeEntry
.getNodeEntries
in interface NodeEntry
NodeEntry
objectsjavax.jcr.RepositoryException
- If an unexpected error occurs.NodeEntry.getNodeEntries()
public List<NodeEntry> getNodeEntries(Name nodeName) throws javax.jcr.RepositoryException
NodeEntry
NodeEntry
s with the
specified name.getNodeEntries
in interface NodeEntry
nodeName
- name of the child node entries that should be returnedNodeEntry
objectsjavax.jcr.RepositoryException
- If an unexpected error occurs.NodeEntry.getNodeEntries(Name)
public void setNodeEntries(Iterator<ChildInfo> childInfos) throws javax.jcr.RepositoryException
NodeEntry
ChildNodeEntries
of this node.setNodeEntries
in interface NodeEntry
javax.jcr.RepositoryException
NodeEntry.setNodeEntries(Iterator)
public NodeEntry getOrAddNodeEntry(Name nodeName, int index, String uniqueID) throws javax.jcr.RepositoryException
NodeEntry
getOrAddNodeEntry
in interface NodeEntry
NodeEntry
.javax.jcr.RepositoryException
- If an unexpected error occurs.NodeEntry.getOrAddNodeEntry(Name, int, String)
public NodeEntry addNewNodeEntry(Name nodeName, String uniqueID, Name primaryNodeType, QNodeDefinition definition) throws javax.jcr.RepositoryException
NodeEntry
NodeEntry
addNewNodeEntry
in interface NodeEntry
javax.jcr.RepositoryException
- If an error occurs.NodeEntry.addNewNodeEntry(Name, String, Name, QNodeDefinition)
public boolean hasPropertyEntry(Name propName)
NodeEntry
Name
.hasPropertyEntry
in interface NodeEntry
propName
- Name
object specifying a property nametrue
if there is a property entry with the specified
Name
.NodeEntry.hasPropertyEntry(Name)
public PropertyEntry getPropertyEntry(Name propName)
NodeEntry
PropertyEntry
with the specified name
or null
if no matching entry exists.getPropertyEntry
in interface NodeEntry
propName
- Name
object specifying a property name.PropertyEntry
with the specified name or
null
if no matching entry exists.NodeEntry.getPropertyEntry(Name)
public PropertyEntry getPropertyEntry(Name propName, boolean loadIfNotFound) throws javax.jcr.RepositoryException
loadIfNotFound
flag due to the fact, that
NodeInfo.getPropertyIds()
returns the
complete list of property names currently available.getPropertyEntry
in interface NodeEntry
propName
- Name
object specifying a property name.PropertyEntry
with the specified name or
null
if no matching entry exists.javax.jcr.RepositoryException
- If an unexpected error occurs.NodeEntry.getPropertyEntry(Name, boolean)
public Iterator<PropertyEntry> getPropertyEntries()
NodeEntry
getPropertyEntries
in interface NodeEntry
NodeEntry.getPropertyEntries()
public PropertyEntry getOrAddPropertyEntry(Name propName) throws javax.jcr.ItemExistsException
NodeEntry
PropertyEntry
with the given name if it is
not yet contained in this NodeEntry
.
Please note the difference to NodeEntry.addNewPropertyEntry(Name, QPropertyDefinition, QValue[], int)
which adds a new, transient entry.getOrAddPropertyEntry
in interface NodeEntry
PropertyEntry
javax.jcr.ItemExistsException
- if a child item exists with the given nameNodeEntry.getOrAddPropertyEntry(Name)
public void setPropertyEntries(Collection<Name> propNames) throws javax.jcr.ItemExistsException, javax.jcr.RepositoryException
NodeEntry
Name
s. It depends on
the status of this NodeEntry
, how conflicts are resolved
and whether or not existing entries that are missing in the iterator
get removed.setPropertyEntries
in interface NodeEntry
javax.jcr.ItemExistsException
javax.jcr.RepositoryException
- if an unexpected error occurs.NodeEntry.setPropertyEntries(Collection)
public PropertyEntry addNewPropertyEntry(Name propName, QPropertyDefinition definition, QValue[] values, int propertyType) throws javax.jcr.ItemExistsException, javax.jcr.RepositoryException
NodeEntry
PropertyEntry
to this NodeEntry
and return the PropertyState
associated with the new entry.addNewPropertyEntry
in interface NodeEntry
javax.jcr.ItemExistsException
javax.jcr.RepositoryException
NodeEntry.addNewPropertyEntry(Name, QPropertyDefinition, QValue[], int)
public void orderBefore(NodeEntry beforeEntry) throws javax.jcr.RepositoryException
NodeEntry
beforeEntry
.orderBefore
in interface NodeEntry
beforeEntry
- the child node where to insert the node before. If
null
this entry is moved to the end of its parents child node entries.javax.jcr.RepositoryException
- If an unexpected error occurs.NodeEntry.orderBefore(NodeEntry)
public NodeEntry move(Name newName, NodeEntry newParent, boolean transientMove) throws javax.jcr.RepositoryException
NodeEntry
NodeEntry
as new child entry of the
NodeEntry
identified by newParent
and/or renames
it to newName
. If transientMove
is true, an
implementation must make sure, that reverting this modification by calling
HierarchyEntry.revert()
on the common ancestor of both parents
moves this NodeEntry back and resets the name to its original value.move
in interface NodeEntry
javax.jcr.RepositoryException
- If the entry to be moved is not a child of this
NodeEntry or if an unexpected error occurs.NodeEntry.move(Name, NodeEntry, boolean)
public boolean isTransientlyMoved()
isTransientlyMoved
in interface NodeEntry
NodeEntry
is transiently moved.NodeEntry.isTransientlyMoved()
public void refresh(Event childEvent)
NodeEntry
Event.getParentId()
of the given childEvent must point
to this NodeEntry
.refresh
in interface NodeEntry
NodeEntry.refresh(Event)
protected void invalidateInternal(boolean recursive)
ItemState
. If recursive
is
true also invalidates the underlying item states of all child entries.protected TransientItemStateFactory getItemStateFactory()
EntryFactory.getItemStateFactory()
protected PathFactory getPathFactory()
EntryFactory.getPathFactory()
protected IdFactory getIdFactory()
EntryFactory.getIdFactory()
protected EntryFactory.InvalidationStrategy getInvalidationStrategy()
public Name getName()
getName
in interface HierarchyEntry
HierarchyEntry.getName()
public Path getPath() throws javax.jcr.RepositoryException
getPath
in interface HierarchyEntry
javax.jcr.RepositoryException
HierarchyEntry.getPath()
public Path getWorkspacePath() throws javax.jcr.RepositoryException
getWorkspacePath
in interface HierarchyEntry
HierarchyEntry.getPath()
. In case of moved items this method return the
original path as it is present on the persistent layer.javax.jcr.RepositoryException
HierarchyEntry.getWorkspacePath()
public NodeEntry getParent()
HierarchyEntry
NodeEntry
being parent to this
HierarchyEntry
.getParent
in interface HierarchyEntry
HierarchyEntry
HierarchyEntry.getParent()
public int getStatus()
HierarchyEntry
HierarchyEntry
provides an underlying
ItemState
this method returns the status of that state,
otherwise it returns Status._UNDEFINED_
.getStatus
in interface HierarchyEntry
Status._UNDEFINED_
if this
entry has not been resolved yet.HierarchyEntry.getStatus()
public boolean isAvailable()
HierarchyEntry
true
if the referenced ItemState
is
available. That is, the referenced ItemState
has already
been resolved.isAvailable
in interface HierarchyEntry
true
if the ItemState
is available;
otherwise false
.HierarchyEntry.isAvailable()
public ItemState getItemState() throws javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
HierarchyEntry
has already been resolved before
(see HierarchyEntry.isAvailable()
), that ItemState
is returned.
Note however, that the validity of the State is not asserted.ItemState
or if the corresponding state has been removed in the mean time.getItemState
in interface HierarchyEntry
ItemState
.javax.jcr.ItemNotFoundException
- if the ItemState
does not
exist anymore.javax.jcr.RepositoryException
- If an error occurs while retrieving the
ItemState
.HierarchyEntry.getItemState()
public void setItemState(ItemState state)
setItemState
in interface HierarchyEntry
HierarchyEntry.setItemState(ItemState)
public void invalidate(boolean recursive)
ItemState
if available and if it
is not transiently modified. If the recursive
flag is true,
also invalidates the child entries recursively.HierarchyEntry.reload(boolean)
this method only sets the status of this item state to Status.INVALIDATED
and does not actually update it with the persistent
state in the repository.invalidate
in interface HierarchyEntry
HierarchyEntry.invalidate(boolean)
public void calculateStatus()
HierarchyEntry
ItemState
: any pending
changes to the underlying ItemState
are applied.calculateStatus
in interface HierarchyEntry
public long getGeneration()
HierarchyEntry
HierarchyEntry
. This is used by the
ItemInfoCache
to determine whether an item info in the cache is up to date or not.
That is whether the generation of the item info in the cache is the same or more recent
as the required generation of this entry.getGeneration
in interface HierarchyEntry
Copyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.