org.planx.xmlstore.koala.nodes
Class NodeProxy

java.lang.Object
  extended by org.planx.xmlstore.koala.nodes.NodeProxy
All Implemented Interfaces:
SystemNode, Node
Direct Known Subclasses:
BlockingNodeProxy, LoadableNodeProxy, XMLStoreNodeProxy

public abstract class NodeProxy
extends Object
implements SystemNode

Author:
Kasper Bøgebjerg, Henning Niss, Thomas Ambus

Field Summary
 
Fields inherited from interface org.planx.xmlstore.Node
BINARY, CHARDATA, ELEMENT
 
Method Summary
 boolean contentEquals(Node n)
          Returns true if and only if the specified node has the same type, value, and attributes as this node, and their children recursively satisfy the same predicate.
 boolean equals(Object o)
          If the argument Node is also a NodeProxy, attempts to compare the two nodes using references, otherwise the proxied node is loaded and a structural comparison is (probably) performed.
 String getAttribute(String attrName)
          Returns the attribute with the given name.
 String[] getAttributeNames()
          Returns the names of this Node's attributes.
 List<Attribute> getAttributes()
          Returns the attributes of this Node.
 byte[] getBytes()
          Returns the value of this node as bytes.
 List<SystemNode> getChildren()
          Returns the children of this Node.
 Locator getLocator()
           
 String getNodeValue()
          Returns the value of this Node.
 byte getType()
          Returns the node type of this Node.
 ValueReference getValueReference()
           
 int hashCode()
          Recursively computes a hash code based on the node type, node value, attributes, and children.
 boolean isMutable()
          Returns true if this Node is mutable, false otherwise.
 boolean isShared()
           
 void setLocator(Locator l)
           
 void setValueReference(ValueReference l)
           
 String toString()
           
 void unload()
          Unload the proxied node from memory.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

isMutable

public boolean isMutable()
Description copied from interface: Node
Returns true if this Node is mutable, false otherwise.

Specified by:
isMutable in interface Node
Returns:
true if mutable, false if immutable.

getType

public byte getType()
Description copied from interface: Node
Returns the node type of this Node.

Specified by:
getType in interface Node
Returns:
The node type

getBytes

public byte[] getBytes()
Description copied from interface: Node
Returns the value of this node as bytes. This is most useful for BINARY nodes. For CHARDATA and ELEMENT nodes the returned bytes will be Node.getNodeValue() encoded as bytes using the default character encoding.

Specified by:
getBytes in interface Node

getNodeValue

public String getNodeValue()
Description copied from interface: Node
Returns the value of this Node. When the node represents a character data node, the returned value will be the character data. When the node represents an element node, the returned value will by the tag name of the element. When the node represents binary data, the returned value will be a base64 encoding of the data.

Specified by:
getNodeValue in interface Node
Returns:
The node value.

getChildren

public List<SystemNode> getChildren()
Description copied from interface: Node
Returns the children of this Node. If the node represents character data the empty list is returned.

Specified by:
getChildren in interface SystemNode
Specified by:
getChildren in interface Node
Returns:
An immutable list of the children of this Node.

getAttributes

public List<Attribute> getAttributes()
Description copied from interface: Node
Returns the attributes of this Node. In case the node represents character data, the empty list is returned.

Specified by:
getAttributes in interface Node
Returns:
An immutable list of the attributes of this Node.

getAttribute

public String getAttribute(String attrName)
Description copied from interface: Node
Returns the attribute with the given name. In case the node represents a character data node the returned value is null.

Specified by:
getAttribute in interface Node
Returns:
The attribute named by the argument.

getAttributeNames

public String[] getAttributeNames()
Description copied from interface: Node
Returns the names of this Node's attributes. If the node represents character data the returned array is empty.

Specified by:
getAttributeNames in interface Node
Returns:
The attribute names of the node.

isShared

public boolean isShared()
Specified by:
isShared in interface SystemNode

getLocator

public Locator getLocator()
Specified by:
getLocator in interface SystemNode

setLocator

public void setLocator(Locator l)
Specified by:
setLocator in interface SystemNode

getValueReference

public ValueReference getValueReference()
Specified by:
getValueReference in interface SystemNode

setValueReference

public void setValueReference(ValueReference l)
Specified by:
setValueReference in interface SystemNode

equals

public boolean equals(Object o)
If the argument Node is also a NodeProxy, attempts to compare the two nodes using references, otherwise the proxied node is loaded and a structural comparison is (probably) performed.

Specified by:
equals in interface Node
Overrides:
equals in class Object

contentEquals

public boolean contentEquals(Node n)
Description copied from interface: Node
Returns true if and only if the specified node has the same type, value, and attributes as this node, and their children recursively satisfy the same predicate.

Specified by:
contentEquals in interface Node

hashCode

public int hashCode()
Description copied from interface: Node
Recursively computes a hash code based on the node type, node value, attributes, and children.

Specified by:
hashCode in interface Node
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

unload

public void unload()
Unload the proxied node from memory. Later uses of the proxy's methods will attempt to generate it again.



Copyright © 2004-2005 Plan-X. All Rights Reserved.