org.apache.jackrabbit.mk.model
Class AbstractNodeState

java.lang.Object
  extended by org.apache.jackrabbit.mk.model.AbstractNodeState
All Implemented Interfaces:
NodeState

public abstract class AbstractNodeState
extends Object
implements NodeState

Abstract base class for NodeState implementations. This base class contains default implementations of the equals(Object) and hashCode() methods based on the implemented interface.

This class also implements trivial (and potentially very slow) versions of the getProperty(String) and getPropertyCount() methods based on NodeState.getProperties(). The getChildNode(String) and getChildNodeCount() methods are similarly implemented based on NodeState.getChildNodeEntries(long, int). Subclasses should normally override these method with a more efficient alternatives.


Constructor Summary
AbstractNodeState()
           
 
Method Summary
 boolean equals(Object that)
          Checks whether the given object is equal to this one.
 NodeState getChildNode(String name)
          Returns the named child node.
 long getChildNodeCount()
          Returns the number of child nodes of this node.
 PropertyState getProperty(String name)
          Returns the named property.
 long getPropertyCount()
          Returns the number of properties of this node.
 int hashCode()
          Returns a hash code that's compatible with how the equals(Object) method is implemented.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jackrabbit.mk.model.NodeState
getChildNodeEntries, getProperties
 

Constructor Detail

AbstractNodeState

public AbstractNodeState()
Method Detail

getProperty

public PropertyState getProperty(String name)
Description copied from interface: NodeState
Returns the named property. The name is an opaque string and is not parsed or otherwise interpreted by this method.

The namespace of properties and child nodes is shared, so if this method returns a non-null value for a given name, then NodeState.getChildNode(String) is guaranteed to return null for the same name.

Specified by:
getProperty in interface NodeState
Parameters:
name - name of the property to return
Returns:
named property, or null if not found

getPropertyCount

public long getPropertyCount()
Description copied from interface: NodeState
Returns the number of properties of this node.

Specified by:
getPropertyCount in interface NodeState
Returns:
number of properties

getChildNode

public NodeState getChildNode(String name)
Description copied from interface: NodeState
Returns the named child node. The name is an opaque string and is not parsed or otherwise interpreted by this method.

The namespace of properties and child nodes is shared, so if this method returns a non-null value for a given name, then NodeState.getProperty(String) is guaranteed to return null for the same name.

Specified by:
getChildNode in interface NodeState
Parameters:
name - name of the child node to return
Returns:
named child node, or null if not found

getChildNodeCount

public long getChildNodeCount()
Description copied from interface: NodeState
Returns the number of child nodes of this node.

Specified by:
getChildNodeCount in interface NodeState
Returns:
number of child nodes

equals

public boolean equals(Object that)
Checks whether the given object is equal to this one. Two node states are considered equal if all their properties and child nodes match, regardless of ordering. Subclasses may override this method with a more efficient equality check if one is available.

Overrides:
equals in class Object
Parameters:
that - target of the comparison
Returns:
true if the objects are equal, false otherwise

hashCode

public int hashCode()
Returns a hash code that's compatible with how the equals(Object) method is implemented. The current implementation simply returns zero for everything since NodeState instances are not intended for use as hash keys.

Overrides:
hashCode in class Object
Returns:
hash code


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.