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 NodeStateExaddNode(Name nodeName, Name nodeTypeName, NodeId id)Adds a new child node with the given nameNodeStateExaddNode(Name nodeName, Name nodeTypeName, NodeId id, boolean referenceable)Adds a new child node with the given namevoidcopyFrom(PropertyImpl prop)copies a propertyvoidcopyFrom(PropertyState prop)copies a propertyNodeStateEx[]getChildNodes()returns all child nodesQNodeDefinitiongetDefinition()Returns the QNodeDefinition for this stateQPropertyDefinitiongetDefinition(PropertyState prop)Returns the property definition for the property stateEffectiveNodeTypegetEffectiveNodeType()Returns the effective (i.e.NamegetName()returns the name of this nodeNodeStateExgetNode(NodeId id)Returns the node with the given id.NodeStateExgetNode(Name name, int index)retrieves the child node with the given name and 1-base index ornullif the node does not exist.NodeIdgetNodeId()Returns the id of this node.NodeStateExgetParent()Returns the parent node of this nodeNodeIdgetParentId()Returns the parent id of this nodePropertyState[]getProperties()Returns the properties of this nodeInternalValuegetPropertyValue(Name name)Returns the value of the given property ornullInternalValue[]getPropertyValues(Name name)Returns the values of the given property ornullNodeStategetState()Returns the underlaying node state.booleanhasAncestor(NodeId nodeId)Checks if this state has the indicated ancestorbooleanhasNode(NodeId id)Checks if the given node state existsbooleanhasNode(Name name)checks if the given child node exists.booleanhasProperty(PropertyId id)Checks if the given property state existsbooleanhasProperty(Name name)Checks if the given property existsNodeStateExmoveFrom(NodeStateEx src, Name name, boolean createShare)Moves the source node to this node using the given name.voidreload()reloads the persistent state recursivelybooleanremoveNode(ChildNodeEntry entry)removes the child node with the given child node entrybooleanremoveNode(NodeStateEx node)removes the given child nodebooleanremoveNode(Name name)removes the (first) child node with the given name.booleanremoveNode(Name name, int index)removes the child node with the given name and 1-based indexbooleanremoveProperty(Name name)removes the property with the given namevoidsetMixins(Set<Name> mixinTypeNames)Sets the given mixin typesvoidsetPropertyValue(Name name, InternalValue value)Sets the property valuevoidsetPropertyValues(Name name, int type, InternalValue[] values)Sets the property valuesPropertyStatesetPropertyValues(Name name, int type, InternalValue[] values, boolean multiple)Sets the property valuesvoidstore()stores the persistent state recursivelyvoidstore(boolean recursively)Stores the persistent state and depending on therecursivelyflag 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
nullif 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:
trueif 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-truefor 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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 ornullif 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:
trueif the node state exists
-
hasProperty
public boolean hasProperty(PropertyId id)
Checks if the given property state exists- Parameters:
id- property id- Returns:
trueif 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- iftruea 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 RepositoryExceptionstores the persistent state recursively- Throws:
RepositoryException- if an error occurs
-
store
public void store(boolean recursively) throws RepositoryExceptionStores the persistent state and depending on therecursivelyflag 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 RepositoryExceptionreloads 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:
trueif it has the indicated ancestor- Throws:
RepositoryException- if an error occurs
-
-