org.apache.jackrabbit.core.version
Class NodeStateEx

java.lang.Object
  extended by 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
NodeStateEx(UpdatableItemStateManager stateMgr, NodeTypeRegistry ntReg, NodeId nodeId)
          Creates a new persistent node
NodeStateEx(UpdatableItemStateManager stateMgr, NodeTypeRegistry ntReg, NodeState nodeState, Name name)
          Creates a new persistent node
 
Method Summary
 NodeStateEx addNode(Name nodeName, Name nodeTypeName, NodeId id)
          Adds a new child node with the given name
 NodeStateEx addNode(Name nodeName, Name nodeTypeName, NodeId id, boolean referenceable)
          Adds a new child node with the given name
 void copyFrom(PropertyImpl prop)
          copies a property
 void copyFrom(PropertyState prop)
          copies a property
 NodeStateEx[] getChildNodes()
          returns all child nodes
 QNodeDefinition getDefinition()
          Returns the QNodeDefinition for this state
 QPropertyDefinition getDefinition(PropertyState prop)
          Returns the property definition for the property state
 EffectiveNodeType getEffectiveNodeType()
          Returns the effective (i.e. merged and resolved) node type representation of this node's primary and mixin node types.
 Name getName()
          returns the name of this node
 NodeStateEx getNode(Name name, int index)
          retrieves the child node with the given name and 1-base index or null if the node does not exist.
 NodeStateEx getNode(NodeId id)
          Returns the node with the given id.
 NodeId getNodeId()
          Returns the id of this node.
 NodeStateEx getParent()
          Returns the parent node of this node
 NodeId getParentId()
          Returns the parent id of this node
 PropertyState[] getProperties()
          Returns the properties of this node
 InternalValue getPropertyValue(Name name)
          Returns the value of the given property or null
 InternalValue[] getPropertyValues(Name name)
          Returns the values of the given property of null
 NodeState getState()
          Returns the underlaying node state.
 boolean hasAncestor(NodeId nodeId)
          Checks if this state has the inidcated ancestor
 boolean hasNode(Name name)
          checks if the given child node exists.
 boolean hasNode(NodeId id)
          Checks if the given node state exists
 boolean hasProperty(Name name)
          Checks if the given property exists
 boolean hasProperty(PropertyId id)
          Checks if the given property state exists
 NodeStateEx moveFrom(NodeStateEx src, Name name, boolean createShare)
          Moves the source node to this node using the given name.
 void reload()
          reloads the persistent state recursively
 boolean removeNode(ChildNodeEntry entry)
          removes the child node with the given child node entry
 boolean 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 index
 boolean removeNode(NodeStateEx node)
          removes the given child node
 boolean removeProperty(Name name)
          removes the property with the given name
 void setMixins(Set<Name> mixinTypeNames)
          Sets the given mixin types
 void setPropertyValue(Name name, InternalValue value)
          Sets the property value
 void setPropertyValues(Name name, int type, InternalValue[] values)
          Sets the property values
 PropertyState setPropertyValues(Name name, int type, InternalValue[] values, boolean multiple)
          Sets the property values
 void store()
          stores the persistent state recursively
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeStateEx

public NodeStateEx(UpdatableItemStateManager stateMgr,
                   NodeTypeRegistry ntReg,
                   NodeState nodeState,
                   Name name)
Creates a new persistent node

Parameters:
stateMgr - state manager
ntReg - node type registry
nodeState - underlying node state
name - name (can be null)

NodeStateEx

public NodeStateEx(UpdatableItemStateManager stateMgr,
                   NodeTypeRegistry ntReg,
                   NodeId nodeId)
            throws RepositoryException
Creates a new persistent node

Parameters:
stateMgr - state manager
ntReg - node type registry
nodeId - 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 of null

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 or null

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 property
value - 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 property
type - property type
values - 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 property
type - type of the values
values - values to set
multiple - 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:
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 hte 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 node
index - 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 or null if the node does not exist.

Parameters:
name - name of hte child node
index - index of thechild 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 node
nodeTypeName - node type name
id - id of the new node
Returns:
the node state
Throws:
NoSuchNodeTypeException - if the node type does not exist
ConstraintViolationException - if there is a constraint violation
RepositoryException - 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 node
nodeTypeName - node type name
id - id of the new node
referenceable - if true, a UUID property is created
Returns:
the node state
Throws:
NoSuchNodeTypeException - if the node type does not exist
ConstraintViolationException - if there is a constraint violation
RepositoryException - 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 node
name - name of new node
createShare - if true 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

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 inidcated ancestor

Parameters:
nodeId - the node id of the ancestor
Returns:
true if it has the inidicated ancestor
Throws:
RepositoryException - if an error occurs


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.