org.planx.xmlstore.nodes
Class NodeProxy

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

public abstract class NodeProxy
extends AbstractNode

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

Field Summary
 
Fields inherited from class org.planx.xmlstore.nodes.AbstractNode
eqCls, ref, visitToken
 
Fields inherited from interface org.planx.xmlstore.Node
CHARDATA, ELEMENT
 
Constructor Summary
protected NodeProxy(LocalLocator l, Reference ref)
           
protected NodeProxy(Reference ref)
           
 
Method Summary
 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.
protected abstract  SystemNode generate()
           
 SystemNode get()
          Resolves the node if it is a proxy and guarantees to return a 'real' node.
 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.
 List<SystemNode> getChildren()
          Returns the children of this Node.
 int getHeight()
           
protected  LocalLocator getLoc()
           
 LocalLocator getLocator()
           
 String getNodeValue()
          Returns the value of this Node.
 byte getType()
          Returns the node type of this Node.
 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 setChild(int index, SystemNode child)
           
 void setHeight(int height)
           
protected  void setLoc(LocalLocator l)
           
 void setLocator(LocalLocator l)
           
 void setShared(boolean isShared)
           
 String toString()
           
 void unload()
          Unload the proxied node from memory.
 
Methods inherited from class org.planx.xmlstore.nodes.AbstractNode
getEquivalenceClass, getReference, getVisitToken, setEquivalenceClass, setReference, setVisitToken
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NodeProxy

protected NodeProxy(Reference ref)

NodeProxy

protected NodeProxy(LocalLocator l,
                    Reference ref)
Method Detail

setLoc

protected void setLoc(LocalLocator l)

getLoc

protected LocalLocator getLoc()

generate

protected abstract SystemNode generate()
                                throws UnknownReferenceException,
                                       IOException
Throws:
UnknownReferenceException
IOException

get

public SystemNode get()
Description copied from interface: SystemNode
Resolves the node if it is a proxy and guarantees to return a 'real' node.

Specified by:
get in interface SystemNode
Overrides:
get in class AbstractNode

isMutable

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

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

getType

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

Returns:
The node type

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.

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.

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.

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.

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.

Returns:
The attribute names of the node.

isShared

public boolean isShared()

setShared

public void setShared(boolean isShared)

getHeight

public int getHeight()

setHeight

public void setHeight(int height)

getLocator

public LocalLocator getLocator()

setLocator

public void setLocator(LocalLocator l)

setChild

public void setChild(int index,
                     SystemNode child)

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

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 © 2010. All Rights Reserved.