Class NodeStateEx
- java.lang.Object
-
- org.apache.jackrabbit.core.version.NodeStateEx
-
public class NodeStateEx extends Object
This Class provides some basic node operations directly on the node state.
-
-
Constructor Summary
Constructors Constructor Description NodeStateEx(UpdatableItemStateManager stateMgr, NodeTypeRegistry ntReg, NodeId nodeId)
Creates a new persistent nodeNodeStateEx(UpdatableItemStateManager stateMgr, NodeTypeRegistry ntReg, NodeState nodeState, Name name)
Creates a new persistent node
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NodeStateEx
addNode(Name nodeName, Name nodeTypeName, NodeId id)
Adds a new child node with the given nameNodeStateEx
addNode(Name nodeName, Name nodeTypeName, NodeId id, boolean referenceable)
Adds a new child node with the given namevoid
copyFrom(PropertyImpl prop)
copies a propertyvoid
copyFrom(PropertyState prop)
copies a propertyNodeStateEx[]
getChildNodes()
returns all child nodesQNodeDefinition
getDefinition()
Returns the QNodeDefinition for this stateQPropertyDefinition
getDefinition(PropertyState prop)
Returns the property definition for the property stateEffectiveNodeType
getEffectiveNodeType()
Returns the effective (i.e.Name
getName()
returns the name of this nodeNodeStateEx
getNode(NodeId id)
Returns the node with the given id.NodeStateEx
getNode(Name name, int index)
retrieves the child node with the given name and 1-base index ornull
if the node does not exist.NodeId
getNodeId()
Returns the id of this node.NodeStateEx
getParent()
Returns the parent node of this nodeNodeId
getParentId()
Returns the parent id of this nodePropertyState[]
getProperties()
Returns the properties of this nodeInternalValue
getPropertyValue(Name name)
Returns the value of the given property ornull
InternalValue[]
getPropertyValues(Name name)
Returns the values of the given property ornull
NodeState
getState()
Returns the underlaying node state.boolean
hasAncestor(NodeId nodeId)
Checks if this state has the indicated ancestorboolean
hasNode(NodeId id)
Checks if the given node state existsboolean
hasNode(Name name)
checks if the given child node exists.boolean
hasProperty(PropertyId id)
Checks if the given property state existsboolean
hasProperty(Name name)
Checks if the given property existsNodeStateEx
moveFrom(NodeStateEx src, Name name, boolean createShare)
Moves the source node to this node using the given name.void
reload()
reloads the persistent state recursivelyboolean
removeNode(ChildNodeEntry entry)
removes the child node with the given child node entryboolean
removeNode(NodeStateEx node)
removes the given child nodeboolean
removeNode(Name name)
removes the (first) child node with the given name.boolean
removeNode(Name name, int index)
removes the child node with the given name and 1-based indexboolean
removeProperty(Name name)
removes the property with the given namevoid
setMixins(Set<Name> mixinTypeNames)
Sets the given mixin typesvoid
setPropertyValue(Name name, InternalValue value)
Sets the property valuevoid
setPropertyValues(Name name, int type, InternalValue[] values)
Sets the property valuesPropertyState
setPropertyValues(Name name, int type, InternalValue[] values, boolean multiple)
Sets the property valuesvoid
store()
stores the persistent state recursivelyvoid
store(boolean recursively)
Stores the persistent state and depending on therecursively
flag also stores the modified child nodes recursively.
-
-
-
Constructor Detail
-
NodeStateEx
public NodeStateEx(UpdatableItemStateManager stateMgr, NodeTypeRegistry ntReg, NodeState nodeState, Name name)
Creates a new persistent node- Parameters:
stateMgr
- state managerntReg
- node type registrynodeState
- underlying node statename
- name (can be null)
-
NodeStateEx
public NodeStateEx(UpdatableItemStateManager stateMgr, NodeTypeRegistry ntReg, NodeId nodeId) throws RepositoryException
Creates a new persistent node- Parameters:
stateMgr
- state managerntReg
- node type registrynodeId
- node id- Throws:
RepositoryException
- if the node state can't be loaded
-
-
Method Detail
-
getName
public Name getName()
returns the name of this node- Returns:
- the name of this node
-
getNodeId
public NodeId getNodeId()
Returns the id of this node.- Returns:
- the id of this node.
-
getParentId
public NodeId getParentId()
Returns the parent id of this node- Returns:
- the parent id of this node
-
getParent
public NodeStateEx getParent() throws RepositoryException
Returns the parent node of this node- Returns:
- the parent node of this node or
null
if root node - Throws:
RepositoryException
- if an error occurs
-
getState
public NodeState getState()
Returns the underlaying node state.- Returns:
- the underlaying node state.
-
getProperties
public PropertyState[] getProperties() throws ItemStateException
Returns the properties of this node- Returns:
- the properties of this node
- Throws:
ItemStateException
- if an error occurs
-
hasProperty
public boolean hasProperty(Name name)
Checks if the given property exists- Parameters:
name
- name of the property- Returns:
true
if the given property exists.
-
getPropertyValues
public InternalValue[] getPropertyValues(Name name)
Returns the values of the given property ornull
- Parameters:
name
- name of the property- Returns:
- the values of the given property.
-
getPropertyValue
public InternalValue getPropertyValue(Name name)
Returns the value of the given property ornull
- Parameters:
name
- name of the property- Returns:
- the value of the given property.
-
setPropertyValue
public void setPropertyValue(Name name, InternalValue value) throws RepositoryException
Sets the property value- Parameters:
name
- name of the propertyvalue
- value to set- Throws:
RepositoryException
- if an error occurs
-
setPropertyValues
public void setPropertyValues(Name name, int type, InternalValue[] values) throws RepositoryException
Sets the property values- Parameters:
name
- name of the propertytype
- property typevalues
- values to set- Throws:
RepositoryException
- if an error occurs
-
setPropertyValues
public PropertyState setPropertyValues(Name name, int type, InternalValue[] values, boolean multiple) throws RepositoryException
Sets the property values- Parameters:
name
- name of the propertytype
- type of the valuesvalues
- values to setmultiple
-true
for MV properties- Returns:
- the modified property state
- Throws:
RepositoryException
- if an error occurs
-
getEffectiveNodeType
public EffectiveNodeType getEffectiveNodeType() throws RepositoryException
Returns the effective (i.e. merged and resolved) node type representation of this node's primary and mixin node types.- Returns:
- the effective node type
- Throws:
RepositoryException
- if an error occurs
-
hasNode
public boolean hasNode(Name name)
checks if the given child node exists.- Parameters:
name
- name of the node- Returns:
true
if the given child exists.
-
removeNode
public boolean removeNode(Name name) throws RepositoryException
removes the (first) child node with the given name.- Parameters:
name
- name of the node- Returns:
true
if the child was removed- Throws:
RepositoryException
- if an error occurs
-
removeNode
public boolean removeNode(NodeStateEx node) throws RepositoryException
removes the given child node- Parameters:
node
- child node to remove- Returns:
true
if the child was removed- Throws:
RepositoryException
- if an error occurs
-
removeNode
public boolean removeNode(Name name, int index) throws RepositoryException
removes the child node with the given name and 1-based index- Parameters:
name
- name of the child nodeindex
- index of the child node- Returns:
true
if the child was removed.- Throws:
RepositoryException
- if an error occurs
-
removeNode
public boolean removeNode(ChildNodeEntry entry) throws RepositoryException
removes the child node with the given child node entry- Parameters:
entry
- entry to remove- Returns:
true
if the child was removed.- Throws:
RepositoryException
- if an error occurs
-
removeProperty
public boolean removeProperty(Name name) throws RepositoryException
removes the property with the given name- Parameters:
name
- name of the property- Returns:
true
if the property was removed.- Throws:
RepositoryException
- if an error occurs
-
getNode
public NodeStateEx getNode(Name name, int index) throws RepositoryException
retrieves the child node with the given name and 1-base index ornull
if the node does not exist.- Parameters:
name
- name of the child nodeindex
- index of the child node- Returns:
- the node state.
- Throws:
RepositoryException
- if an error occurs
-
getNode
public NodeStateEx getNode(NodeId id) throws RepositoryException
Returns the node with the given id.- Parameters:
id
- node id- Returns:
- the new node state
- Throws:
RepositoryException
- if an error occurs
-
hasNode
public boolean hasNode(NodeId id)
Checks if the given node state exists- Parameters:
id
- node id- Returns:
true
if the node state exists
-
hasProperty
public boolean hasProperty(PropertyId id)
Checks if the given property state exists- Parameters:
id
- property id- Returns:
true
if the property state exists
-
addNode
public NodeStateEx addNode(Name nodeName, Name nodeTypeName, NodeId id) throws NoSuchNodeTypeException, ConstraintViolationException, RepositoryException
Adds a new child node with the given name- Parameters:
nodeName
- name of the new nodenodeTypeName
- node type nameid
- id of the new node- Returns:
- the node state
- Throws:
NoSuchNodeTypeException
- if the node type does not existConstraintViolationException
- if there is a constraint violationRepositoryException
- if an error occurs
-
addNode
public NodeStateEx addNode(Name nodeName, Name nodeTypeName, NodeId id, boolean referenceable) throws NoSuchNodeTypeException, ConstraintViolationException, RepositoryException
Adds a new child node with the given name- Parameters:
nodeName
- name of the new nodenodeTypeName
- node type nameid
- id of the new nodereferenceable
- iftrue
, a UUID property is created- Returns:
- the node state
- Throws:
NoSuchNodeTypeException
- if the node type does not existConstraintViolationException
- if there is a constraint violationRepositoryException
- if an error occurs
-
setMixins
public void setMixins(Set<Name> mixinTypeNames) throws RepositoryException
Sets the given mixin types- Parameters:
mixinTypeNames
- the mixin type names- Throws:
RepositoryException
- if an error occurs
-
moveFrom
public NodeStateEx moveFrom(NodeStateEx src, Name name, boolean createShare) throws RepositoryException
Moves the source node to this node using the given name.- Parameters:
src
- shareable source nodename
- name of new nodecreateShare
- iftrue
a share is created instead.- Returns:
- child node
- Throws:
RepositoryException
- if an error occurs
-
getChildNodes
public NodeStateEx[] getChildNodes() throws RepositoryException
returns all child nodes- Returns:
- the child nodes.
- Throws:
RepositoryException
- if an error occurs
-
store
public void store() throws RepositoryException
stores the persistent state recursively- Throws:
RepositoryException
- if an error occurs
-
store
public void store(boolean recursively) throws RepositoryException
Stores the persistent state and depending on therecursively
flag also stores the modified child nodes recursively.- Parameters:
recursively
- whether to store the nodes recursively or just this single node.- Throws:
RepositoryException
- if an error occurs
-
reload
public void reload() throws RepositoryException
reloads the persistent state recursively- Throws:
RepositoryException
- if an error occurs
-
copyFrom
public void copyFrom(PropertyImpl prop) throws RepositoryException
copies a property- Parameters:
prop
- source property- Throws:
RepositoryException
- if an error occurs
-
copyFrom
public void copyFrom(PropertyState prop) throws RepositoryException
copies a property- Parameters:
prop
- source property- Throws:
RepositoryException
- if an error occurs
-
getDefinition
public QNodeDefinition getDefinition() throws RepositoryException
Returns the QNodeDefinition for this state- Returns:
- the node def
- Throws:
RepositoryException
- if an error occurs
-
getDefinition
public QPropertyDefinition getDefinition(PropertyState prop) throws RepositoryException
Returns the property definition for the property state- Parameters:
prop
- the property state- Returns:
- the prop def
- Throws:
RepositoryException
- if an error occurs
-
hasAncestor
public boolean hasAncestor(NodeId nodeId) throws RepositoryException
Checks if this state has the indicated ancestor- Parameters:
nodeId
- the node id of the ancestor- Returns:
true
if it has the indicated ancestor- Throws:
RepositoryException
- if an error occurs
-
-