org.apache.jackrabbit.jcr2spi.state
Class NodeState

java.lang.Object
  extended by org.apache.jackrabbit.jcr2spi.state.ItemState
      extended by org.apache.jackrabbit.jcr2spi.state.NodeState

public class NodeState
extends ItemState

NodeState represents the state of a Node.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.jackrabbit.jcr2spi.state.ItemState
ItemState.MergeResult, ItemState.SimpleMergeResult
 
Constructor Summary
protected NodeState(NodeEntry entry, Name nodeTypeName, Name[] mixinTypeNames, ItemStateFactory isf, QNodeDefinition definition, ItemDefinitionProvider definitionProvider)
          Constructs a NEW NodeState
protected NodeState(NodeEntry entry, NodeInfo nInfo, ItemStateFactory isf, ItemDefinitionProvider definitionProvider)
          Constructs an EXISTING NodeState
 
Method Summary
 Name[] getAllNodeTypeNames()
          TODO: clarify usage In case the status of the given node state is not Status.EXISTING the transiently added mixin types are taken into account as well.
 NodeState getChildNodeState(Name nodeName, int index)
          Utility Returns the child NodeState with the specified name and index.
 QNodeDefinition getDefinition()
          Returns the definition 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 this NodeState including the primary nodetype and the mixins.
 PropertyState getPropertyState(Name propertyName)
          Utility method that returns the property state with the given name or throws an ItemNotFoundException 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 valid NodeEntry with the specified name and index.
 boolean hasDefinition()
          Returns true if the definition of this state has already been calculated.
 boolean hasPropertyName(Name propName)
          Utility
 boolean isNode()
          Determines if this item state represents a node.
 boolean isRoot()
          Returns true, if this NodeState 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 class ItemState
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 the hierarchy entry.

Specified by:
getId in class ItemState
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 class ItemState
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 class ItemState
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 class ItemState
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 this NodeState 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 this NodeState 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 not Status.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 the definition 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; if null 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 valid NodeEntry with the specified name and index.

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 a NodeEntry with the specified name and index.

getChildNodeState

public NodeState getChildNodeState(Name nodeName,
                                   int index)
                            throws ItemNotFoundException,
                                   RepositoryException
Utility Returns the child NodeState with the specified name and index. Throws ItemNotFoundException 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 specified Name.

getPropertyState

public PropertyState getPropertyState(Name propertyName)
                               throws ItemNotFoundException,
                                      RepositoryException
Utility method that returns the property state with the given name or throws an ItemNotFoundException 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()


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