Class NodeState
- java.lang.Object
-
- org.apache.jackrabbit.jcr2spi.state.ItemState
-
- org.apache.jackrabbit.jcr2spi.state.NodeState
-
public class NodeState extends ItemState
NodeState
represents the state of aNode
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.jackrabbit.jcr2spi.state.ItemState
ItemState.MergeResult, ItemState.SimpleMergeResult
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
NodeState(NodeEntry entry, Name nodeTypeName, Name[] mixinTypeNames, ItemStateFactory isf, QNodeDefinition definition, ItemDefinitionProvider definitionProvider)
Constructs a NEW NodeStateprotected
NodeState(NodeEntry entry, NodeInfo nInfo, ItemStateFactory isf, ItemDefinitionProvider definitionProvider)
Constructs an EXISTING NodeState
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Name[]
getAllNodeTypeNames()
TODO: clarify usage In case the status of the given node state is notStatus.EXISTING
the transiently added mixin types are taken into account as well.NodeState
getChildNodeState(Name nodeName, int index)
Utility Returns the childNodeState
with the specified name and index.QNodeDefinition
getDefinition()
Returns thedefinition
defined for this node state.ItemId
getId()
Utility method: Returns the identifier of this item state.Name[]
getMixinTypeNames()
Returns the names of this node's mixin types.NodeEntry
getNodeEntry()
NodeId
getNodeId()
Returns the id of this node state.Iterator<PropertyId>
getNodeReferences(Name propertyName, boolean weak)
Returns the identifiers of all reference properties that point to this node.Name
getNodeTypeName()
Returns the name of this node's node type.Name[]
getNodeTypeNames()
Return all nodetype names that are defined to thisNodeState
including the primary nodetype and the mixins.PropertyState
getPropertyState(Name propertyName)
Utility method that returns the property state with the given name or throws anItemNotFoundException
if no matching, valid property could be found.String
getUniqueID()
ItemId
getWorkspaceId()
Utility method: Returns the identifier of this item state.boolean
hasChildNodeEntry(Name name, int index)
Utility Determines if there is a validNodeEntry
with the specifiedname
andindex
.boolean
hasDefinition()
Returns true if the definition of this state has already been calculated.boolean
hasPropertyName(Name propName)
Utilityboolean
isNode()
Determines if this item state represents a node.boolean
isRoot()
Returns true, if thisNodeState
represent the root node.ItemState.MergeResult
merge(ItemState another, boolean keepChanges)
Merge all data from the given state into this state.boolean
revert()
Revert all transient modifications made to this ItemState.void
setMixinTypeNames(Name[] mixinTypeNames)
Used by NodeEntryImpl and NodeState only-
Methods inherited from class org.apache.jackrabbit.jcr2spi.state.ItemState
addListener, getHierarchyEntry, getListeners, getName, getParent, getPath, getStatus, invalidate, isValid, removeListener, setStatus
-
-
-
-
Constructor Detail
-
NodeState
protected NodeState(NodeEntry entry, Name nodeTypeName, Name[] mixinTypeNames, ItemStateFactory isf, QNodeDefinition definition, ItemDefinitionProvider definitionProvider)
Constructs a NEW NodeState- Parameters:
entry
-nodeTypeName
-mixinTypeNames
-isf
-definition
-definitionProvider
-
-
NodeState
protected NodeState(NodeEntry entry, NodeInfo nInfo, ItemStateFactory isf, ItemDefinitionProvider definitionProvider)
Constructs an EXISTING NodeState- Parameters:
entry
-nInfo
-isf
-definitionProvider
-
-
-
Method Detail
-
isNode
public final boolean isNode()
Determines if this item state represents a node.- Specified by:
isNode
in classItemState
- Returns:
- always true
- See Also:
ItemState.isNode()
-
getId
public ItemId getId() throws RepositoryException
Utility method: Returns the identifier of this item state. Shortcut for calling 'getId' on thehierarchy entry
.- Specified by:
getId
in classItemState
- Returns:
- the identifier of this item state..
- Throws:
RepositoryException
- See Also:
ItemState.getId()
-
getWorkspaceId
public ItemId getWorkspaceId() throws RepositoryException
Utility method: Returns the identifier of this item state. Shortcut for calling 'getWorkspaceId' on the NodeEntry or PropertyEntry respectively.- Specified by:
getWorkspaceId
in classItemState
- Returns:
- the identifier of this item state..
- Throws:
RepositoryException
- See Also:
ItemState.getWorkspaceId()
-
merge
public ItemState.MergeResult merge(ItemState another, boolean keepChanges)
Description copied from class:ItemState
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.- Specified by:
merge
in classItemState
- Returns:
- a MergeResult instance which represent the result of the merge operation
- See Also:
ItemState.merge(ItemState, boolean)
-
revert
public boolean revert()
Description copied from class:ItemState
Revert all transient modifications made to this ItemState.- Specified by:
revert
in classItemState
- Returns:
- Always returns false unless the definition has been modified along with a move operation.
- See Also:
ItemState.revert()
-
getNodeEntry
public NodeEntry getNodeEntry()
- Returns:
- The
NodeEntry
associated with this state.
-
getNodeId
public NodeId getNodeId() throws RepositoryException
Returns the id of this node state.- Returns:
- the id of this node state.
- Throws:
RepositoryException
-
getUniqueID
public String getUniqueID()
- Returns:
- the unique ID of this node state or
null
if this node cannot be identified with a unique ID.
-
isRoot
public boolean isRoot()
Returns true, if thisNodeState
represent the root node.- Returns:
- true if this
NodeState
represent the root node.
-
getNodeTypeName
public Name getNodeTypeName()
Returns the name of this node's node type.- Returns:
- the name of this node's node type.
-
getMixinTypeNames
public Name[] 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(Name[] mixinTypeNames)
Used by NodeEntryImpl and NodeState only- Parameters:
mixinTypeNames
-
-
getNodeTypeNames
public Name[] getNodeTypeNames()
Return all nodetype names that are defined to thisNodeState
including the primary nodetype and the mixins.- Returns:
- array of NodeType names
-
getAllNodeTypeNames
public Name[] getAllNodeTypeNames()
TODO: clarify usage In case the status of the given node state is notStatus.EXISTING
the transiently added mixin types are taken into account as well.- Returns:
-
hasDefinition
public boolean hasDefinition() throws RepositoryException
Returns true if the definition of this state has already been calculated. False otherwise.- Returns:
- true if definition has already been calculated.
- Throws:
RepositoryException
-
getDefinition
public QNodeDefinition getDefinition() throws RepositoryException
Returns thedefinition
defined for this node state. Note, that the definition has been set upon creation or upon move.- Returns:
- definition of this state
- Throws:
RepositoryException
-
getNodeReferences
public Iterator<PropertyId> getNodeReferences(Name propertyName, boolean weak)
Returns the identifiers of all reference properties that point to this node.- Parameters:
propertyName
- name filter of referring properties to be returned; ifnull
then all references are returned.weak
- Boolean flag indicating whether weak references should be returned or not.- Returns:
- reference property identifiers
-
hasChildNodeEntry
public boolean hasChildNodeEntry(Name name, int index)
Utility Determines if there is a validNodeEntry
with the specifiedname
andindex
.- Parameters:
name
-Name
object specifying a node name.index
- 1-based index if there are same-name child node entries.- Returns:
true
if there is aNodeEntry
with the specifiedname
andindex
.
-
getChildNodeState
public NodeState getChildNodeState(Name nodeName, int index) throws ItemNotFoundException, RepositoryException
Utility Returns the childNodeState
with the specified name and index. ThrowsItemNotFoundException
if there's no matching, valid entry.- Parameters:
nodeName
-Name
object specifying a node name.index
- 1-based index if there are same-name child node entries.- Returns:
- The
NodeState
with the specified name and index - Throws:
ItemNotFoundException
RepositoryException
-
hasPropertyName
public boolean hasPropertyName(Name propName)
Utility- Parameters:
propName
-Name
object specifying a property name- Returns:
true
if there is a valid property entry with the specifiedName
.
-
getPropertyState
public PropertyState getPropertyState(Name propertyName) throws ItemNotFoundException, RepositoryException
Utility method that returns the property state with the given name or throws anItemNotFoundException
if no matching, valid property could be found.- Parameters:
propertyName
- The name of the property state to return.- Throws:
ItemNotFoundException
- If there is no (valid) property state with the given name.RepositoryException
- If an error occurs while retrieving the property state.- See Also:
NodeEntry.getPropertyEntry(Name, boolean)
,PropertyEntry.getPropertyState()
-
-