Class NodeState
- java.lang.Object
-
- org.apache.jackrabbit.jcr2spi.state.ItemState
-
- org.apache.jackrabbit.jcr2spi.state.NodeState
-
public class NodeState extends ItemState
NodeStaterepresents 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 protectedNodeState(NodeEntry entry, Name nodeTypeName, Name[] mixinTypeNames, ItemStateFactory isf, QNodeDefinition definition, ItemDefinitionProvider definitionProvider)Constructs a NEW NodeStateprotectedNodeState(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.EXISTINGthe transiently added mixin types are taken into account as well.NodeStategetChildNodeState(Name nodeName, int index)Utility Returns the childNodeStatewith the specified name and index.QNodeDefinitiongetDefinition()Returns thedefinitiondefined for this node state.ItemIdgetId()Utility method: Returns the identifier of this item state.Name[]getMixinTypeNames()Returns the names of this node's mixin types.NodeEntrygetNodeEntry()NodeIdgetNodeId()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.NamegetNodeTypeName()Returns the name of this node's node type.Name[]getNodeTypeNames()Return all nodetype names that are defined to thisNodeStateincluding the primary nodetype and the mixins.PropertyStategetPropertyState(Name propertyName)Utility method that returns the property state with the given name or throws anItemNotFoundExceptionif no matching, valid property could be found.StringgetUniqueID()ItemIdgetWorkspaceId()Utility method: Returns the identifier of this item state.booleanhasChildNodeEntry(Name name, int index)Utility Determines if there is a validNodeEntrywith the specifiednameandindex.booleanhasDefinition()Returns true if the definition of this state has already been calculated.booleanhasPropertyName(Name propName)UtilitybooleanisNode()Determines if this item state represents a node.booleanisRoot()Returns true, if thisNodeStaterepresent the root node.ItemState.MergeResultmerge(ItemState another, boolean keepChanges)Merge all data from the given state into this state.booleanrevert()Revert all transient modifications made to this ItemState.voidsetMixinTypeNames(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:
isNodein 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:
getIdin 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:
getWorkspaceIdin 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:ItemStateMerge 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:
mergein 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:ItemStateRevert all transient modifications made to this ItemState.- Specified by:
revertin 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
NodeEntryassociated 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
nullif this node cannot be identified with a unique ID.
-
isRoot
public boolean isRoot()
Returns true, if thisNodeStaterepresent the root node.- Returns:
- true if this
NodeStaterepresent 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 thisNodeStateincluding 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.EXISTINGthe transiently added mixin types are taken into account as well.- Returns:
-
hasDefinition
public boolean hasDefinition() throws RepositoryExceptionReturns 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 thedefinitiondefined 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; ifnullthen 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 validNodeEntrywith the specifiednameandindex.- Parameters:
name-Nameobject specifying a node name.index- 1-based index if there are same-name child node entries.- Returns:
trueif there is aNodeEntrywith the specifiednameandindex.
-
getChildNodeState
public NodeState getChildNodeState(Name nodeName, int index) throws ItemNotFoundException, RepositoryException
Utility Returns the childNodeStatewith the specified name and index. ThrowsItemNotFoundExceptionif there's no matching, valid entry.- Parameters:
nodeName-Nameobject specifying a node name.index- 1-based index if there are same-name child node entries.- Returns:
- The
NodeStatewith the specified name and index - Throws:
ItemNotFoundExceptionRepositoryException
-
hasPropertyName
public boolean hasPropertyName(Name propName)
Utility- Parameters:
propName-Nameobject specifying a property name- Returns:
trueif 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 anItemNotFoundExceptionif 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()
-
-