Class ItemState
- java.lang.Object
-
- org.apache.jackrabbit.jcr2spi.state.ItemState
-
- Direct Known Subclasses:
NodeState
,PropertyState
public abstract class ItemState extends Object
ItemState
represents the state of anItem
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ItemState.MergeResult
A MergeResult represents the result of amerge(ItemState, boolean)
operation.protected class
ItemState.SimpleMergeResult
A SimpleMergeResult is just a holder for a modification status.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ItemState(int initialStatus, HierarchyEntry entry, ItemStateFactory isf, ItemDefinitionProvider definitionProvider)
Constructs an item stateprotected
ItemState(HierarchyEntry entry, ItemStateFactory isf, ItemDefinitionProvider definitionProvider)
Constructs an item state
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addListener(ItemStateLifeCycleListener listener)
Add anItemStateLifeCycleListener
HierarchyEntry
getHierarchyEntry()
TheHierarchyEntry
corresponding to thisItemState
.abstract ItemId
getId()
Utility method: Returns the identifier of this item state.Iterator<ItemStateLifeCycleListener>
getListeners()
Unmodifiable iterator over the listeners present on this item state.Name
getName()
Utility method: Returns the name of this state.NodeState
getParent()
Utility method: Shortcut for calling 'getParent().getNodeState()' on thehierarchy entry
.Path
getPath()
Utility method: Returns the path of this item state.int
getStatus()
Returns the status of this item.abstract ItemId
getWorkspaceId()
Utility method: Returns the identifier of this item state.void
invalidate()
Invalidates this state: set itsStatus
toStatus.INVALIDATED
if the current status isStatus.EXISTING
.abstract boolean
isNode()
Utility method: Determines if this item state represents a node.boolean
isValid()
Returnstrue
if this item state is valid and can be accessed.abstract ItemState.MergeResult
merge(ItemState another, boolean keepChanges)
Merge all data from the given state into this state.void
removeListener(ItemStateLifeCycleListener listener)
Remove anItemStateLifeCycleListener
abstract boolean
revert()
Revert all transient modifications made to this ItemState.void
setStatus(int newStatus)
Sets the new status of this item.
-
-
-
Constructor Detail
-
ItemState
protected ItemState(HierarchyEntry entry, ItemStateFactory isf, ItemDefinitionProvider definitionProvider)
Constructs an item state- Parameters:
entry
-isf
-definitionProvider
-
-
ItemState
protected ItemState(int initialStatus, HierarchyEntry entry, ItemStateFactory isf, ItemDefinitionProvider definitionProvider)
Constructs an item state- Parameters:
entry
-isf
-definitionProvider
-
-
-
Method Detail
-
getHierarchyEntry
public HierarchyEntry getHierarchyEntry()
TheHierarchyEntry
corresponding to thisItemState
.- Returns:
- The
HierarchyEntry
corresponding to thisItemState
.
-
isValid
public boolean isValid()
Returnstrue
if this item state is valid and can be accessed.- Returns:
- See Also:
Status.isValid(int)
,Status.isStale(int)
-
isNode
public abstract boolean isNode()
Utility method: Determines if this item state represents a node.- Returns:
- true if this item state represents a node, otherwise false.
-
getName
public Name getName()
Utility method: Returns the name of this state. Shortcut for calling 'getName' on thehierarchy entry
.- Returns:
- name of this state
-
getId
public abstract ItemId getId() throws RepositoryException
Utility method: Returns the identifier of this item state. Shortcut for calling 'getId' on thehierarchy entry
.- Returns:
- the identifier of this item state..
- Throws:
RepositoryException
-
getWorkspaceId
public abstract ItemId getWorkspaceId() throws RepositoryException
Utility method: Returns the identifier of this item state. Shortcut for calling 'getWorkspaceId' on the NodeEntry or PropertyEntry respectively.- Returns:
- the identifier of this item state..
- Throws:
RepositoryException
-
getPath
public Path getPath() throws RepositoryException
Utility method: Returns the path of this item state. Shortcut for calling 'getPath' on thehierarchy entry
.- Returns:
- Throws:
RepositoryException
- if an error occurs
-
getParent
public NodeState getParent() throws ItemNotFoundException, RepositoryException
Utility method: Shortcut for calling 'getParent().getNodeState()' on thehierarchy entry
.- Returns:
- Throws:
ItemNotFoundException
RepositoryException
-
getStatus
public final int getStatus()
Returns the status of this item.- Returns:
- the status of this item.
-
setStatus
public void setStatus(int newStatus)
Sets the new status of this item.- Parameters:
newStatus
- the new status
-
merge
public abstract ItemState.MergeResult merge(ItemState another, boolean keepChanges)
Merge all data from the given state into this state. If 'keepChanges
' is true, transient modifications present on this state are not touched. Otherwise this state is completely reset according to the given other state.- Parameters:
another
-keepChanges
-- Returns:
- a MergeResult instance which represent the result of the merge operation
-
revert
public abstract boolean revert()
Revert all transient modifications made to this ItemState.- Returns:
- true if this state has been modified i.e. if there was anything to revert.
-
addListener
public void addListener(ItemStateLifeCycleListener listener)
Add anItemStateLifeCycleListener
- Parameters:
listener
- the new listener to be informed on modifications
-
removeListener
public void removeListener(ItemStateLifeCycleListener listener)
Remove anItemStateLifeCycleListener
- Parameters:
listener
- an existing listener
-
getListeners
public Iterator<ItemStateLifeCycleListener> getListeners()
Unmodifiable iterator over the listeners present on this item state.- Returns:
- iterator over
ItemStateLifeCycleListener
s.
-
invalidate
public void invalidate()
Invalidates this state: set itsStatus
toStatus.INVALIDATED
if the current status isStatus.EXISTING
. Does nothing otherwise.
-
-