org.jboss.dna.jcr.cache
Class ChangedNodeInfo

java.lang.Object
  extended by org.jboss.dna.jcr.cache.ChangedNodeInfo
All Implemented Interfaces:
NodeInfo
Direct Known Subclasses:
NewNodeInfo

@NotThreadSafe
public class ChangedNodeInfo
extends Object
implements NodeInfo

The information that describes a node. This is the information that is kept in the cache.

Each instance maintains a reference to the original (usually immutable) NodeInfo representation that was probably read from the repository.


Constructor Summary
ChangedNodeInfo(NodeInfo original)
          Create an immutable NodeInfo instance.
 
Method Summary
 void addChild(Name childName, Path.Segment beforeChild, UUID childUuid, PathFactory factory)
          Add a child to the children.
 ChildNode addChild(Name childName, UUID childUuid, PathFactory factory)
          Add a child to the children.
 void addPeer(UUID peerUuid)
          Adds a peer node to this change.
 Children getChildren()
          Get the children for this node.
 NodeDefinitionId getDefinitionId()
          
 List<Name> getMixinTypeNames()
          Get the names of the mixin types for this node.
 NodeInfo getOriginal()
          Return the original node information.
 Location getOriginalLocation()
          
 UUID getParent()
          
 Collection<UUID> getPeers()
          Returns the peer nodes for this changed node.
 Name getPrimaryTypeName()
          
 PropertyInfo getProperty(Name name)
          Get this node's property that has the supplied name.
 int getPropertyCount()
          Return the number of properties on this node.
 Set<Name> getPropertyNames()
          Get the names of the properties that are owned by this node.
 Set<Name> getSingleMultiPropertyNames()
           
 UUID getUuid()
          
 Collection<UUID> getUuidsForRemovedChildren()
          Get the UUIDs for the children for this node that have been removed since the node was last persisted.
 boolean hasProperties()
          Return true of this node has at least one property.
 boolean isModified()
          Indicates whether the node represented by this NodeInfo is modified (i.e., exists in the persistent repository with different child items).
 boolean isNew()
          Indicates whether the node represented by this NodeInfo is new (i.e., does not yet exist in the persistent repository).
 ChildNode removeChild(UUID childUUID, PathFactory factory)
          Remove a child from the children.
 PropertyInfo removeProperty(Name name)
           
 boolean removeSingleMultiProperty(Name name)
           
 void setDefinitionId(NodeDefinitionId definitionId)
          Set the identifier of the node definition for this node.
 UUID setParent(UUID parent)
          Record that this node has been moved under a new parent.
 PropertyInfo setProperty(PropertyInfo newProperty, ValueFactories factories)
           
 boolean setSingleMultiProperty(Name name)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChangedNodeInfo

public ChangedNodeInfo(NodeInfo original)
Create an immutable NodeInfo instance.

Parameters:
original - the original node information, may not be null
Method Detail

getPeers

public final Collection<UUID> getPeers()
Returns the peer nodes for this changed node.

Peer nodes are nodes that must be saved with this node (e.g., the other changed node in a Session.move(String, String) operation.

Returns:
a collection of the UUIDs for any other nodes that must be saved with this node; may be null

addPeer

public void addPeer(UUID peerUuid)
Adds a peer node to this change.

Peer nodes are nodes that must be saved with this node (e.g., the other changed node in a Session.move(String, String) operation.

Parameters:
peerUuid - the UUID of the peer node

setSingleMultiProperty

public boolean setSingleMultiProperty(Name name)

removeSingleMultiProperty

public boolean removeSingleMultiProperty(Name name)

getSingleMultiPropertyNames

public Set<Name> getSingleMultiPropertyNames()

getOriginal

public NodeInfo getOriginal()
Return the original node information. May be null if this is a new node.

Returns:
the original node information

getOriginalLocation

public Location getOriginalLocation()

Specified by:
getOriginalLocation in interface NodeInfo
Returns:
location
See Also:
NodeInfo.getOriginalLocation()

getUuid

public UUID getUuid()

Specified by:
getUuid in interface NodeInfo
Returns:
uuid
See Also:
NodeInfo.getUuid()

getParent

public UUID getParent()

Specified by:
getParent in interface NodeInfo
Returns:
parent
See Also:
NodeInfo.getParent()

setParent

public UUID setParent(UUID parent)
Record that this node has been moved under a new parent. This method does not change the ChildNode references in the old or new parent.

Parameters:
parent - the new parent, or null if the original's parent should be used
Returns:
the previous parent (either the original's or the last new parent); may be null

getPrimaryTypeName

public Name getPrimaryTypeName()

Specified by:
getPrimaryTypeName in interface NodeInfo
Returns:
primaryTypeName
See Also:
NodeInfo.getPrimaryTypeName()

getMixinTypeNames

public List<Name> getMixinTypeNames()
Get the names of the mixin types for this node.

Specified by:
getMixinTypeNames in interface NodeInfo
Returns:
the unmodifiable list of mixin type names; never null but possibly empty
See Also:
NodeInfo.getMixinTypeNames()

getDefinitionId

public NodeDefinitionId getDefinitionId()

Specified by:
getDefinitionId in interface NodeInfo
Returns:
definition
See Also:
NodeInfo.getDefinitionId()

setDefinitionId

public void setDefinitionId(NodeDefinitionId definitionId)
Set the identifier of the node definition for this node. This should normally be changed by setting the DnaIntLexicon.NODE_DEFINITON property. However, since that property is not always allowed, this method provides a way to set it locally (without requiring a property).

Parameters:
definitionId - the new property definition identifier; may not be null
See Also:
setProperty(PropertyInfo, ValueFactories)

getChildren

public Children getChildren()
Get the children for this node. Generally, clients should not hold onto the returned object but instead should simply use it and discard the reference. This is because implementations are not required to return the same instance with each call (although immutable implementations are expected to always return the same instance).

Specified by:
getChildren in interface NodeInfo
Returns:
the immutable children; never null but possibly empty
See Also:
NodeInfo.getChildren()

getUuidsForRemovedChildren

public Collection<UUID> getUuidsForRemovedChildren()
Get the UUIDs for the children for this node that have been removed since the node was last persisted.

Returns:
a collection of the UUIDs of the removed children; never null but possibly empty

addChild

public ChildNode addChild(Name childName,
                          UUID childUuid,
                          PathFactory factory)
Add a child to the children. This method does nothing if the child is already in the children.

Parameters:
childName - the name of the child that is to be added; may not be null
childUuid - the UUID of the child that is to be added; may not be null
factory - the path factory that should be used to create a Path.Segment for the new ChildNode object
Returns:
the child node that was just added; never null

addChild

public void addChild(Name childName,
                     Path.Segment beforeChild,
                     UUID childUuid,
                     PathFactory factory)
Add a child to the children. This method does nothing if the child is already in the children.

Parameters:
childName - the name of the child that is to be added; may not be null
childUuid - the UUID of the child that is to be added; may not be null
beforeChild - the segment for the child that the new child should be added before; may not be null
factory - the path factory that should be used to create a Path.Segment for the new ChildNode object

removeChild

public ChildNode removeChild(UUID childUUID,
                             PathFactory factory)
Remove a child from the children. This method only uses the child's UUID to identify the contained ChildNode instance that should be removed.

Parameters:
childUUID - the UUID of the child that is to be removed; may not be null
factory - the path factory that should be used to create a Path.Segment for replacement ChildNode objects for nodes with the same name that and higher same-name-sibiling indexes.
Returns:
the child node that was removed, or null if no such child could be removed

hasProperties

public boolean hasProperties()
Return true of this node has at least one property.

Specified by:
hasProperties in interface NodeInfo
Returns:
true if there is at least one property, or false if there are none
See Also:
NodeInfo.hasProperties()

getPropertyCount

public int getPropertyCount()
Return the number of properties on this node.

Specified by:
getPropertyCount in interface NodeInfo
Returns:
the number of properties; never negative
See Also:
NodeInfo.getPropertyCount()

getPropertyNames

public Set<Name> getPropertyNames()
Get the names of the properties that are owned by this node.

Specified by:
getPropertyNames in interface NodeInfo
Returns:
the unmodifiable set of property names
See Also:
NodeInfo.getPropertyNames()

getProperty

public PropertyInfo getProperty(Name name)
Get this node's property that has the supplied name.

Specified by:
getProperty in interface NodeInfo
Parameters:
name - the property name; may not be null
Returns:
the property information, or null if this node has no property with the supplied name
See Also:
NodeInfo.getProperty(org.jboss.dna.graph.property.Name)

setProperty

public PropertyInfo setProperty(PropertyInfo newProperty,
                                ValueFactories factories)

removeProperty

public PropertyInfo removeProperty(Name name)

isNew

public boolean isNew()
Indicates whether the node represented by this NodeInfo is new (i.e., does not yet exist in the persistent repository).

Specified by:
isNew in interface NodeInfo
Returns:
true if the node represented by this NodeInfo has not yet been saved to the persistent repository.
See Also:
NodeInfo.isNew()

isModified

public boolean isModified()
Indicates whether the node represented by this NodeInfo is modified (i.e., exists in the persistent repository with different child items).

Specified by:
isModified in interface NodeInfo
Returns:
true if the immediate child items of the node represented by this NodeInfo have been modified since the last time the node was saved to the persistent repository
See Also:
NodeInfo.isModified()


Copyright © 2008-Present JBoss a division of Red Hat. All Rights Reserved.