org.jclientpages.page.dom
Class ClientPageNode

java.lang.Object
  extended by org.jclientpages.page.dom.ClientPageNode

public class ClientPageNode
extends java.lang.Object

A wrapper of JSObject representing each element in the page DOM.
This class contains some facility methods for common operations

Author:
Luigi Dell'Aquila (luigi.dellaquila--at--gmail.com)

Constructor Summary
ClientPageNode(netscape.javascript.JSObject iJsObject)
          creates a ClientPageNode that wraps the given JSObject
 
Method Summary
 ClientPageNode appendChild(ClientPageNode node)
          appends a new child node to the current node
 ClientPageNode appendChild(java.lang.String tagName)
          creates a new child node and appends it in the current node
 void appendTextChild(java.lang.String text)
          appends a new text child to the current node
 netscape.javascript.JSObject asJSObject()
          returns the wrapped JSObject
 java.lang.Object call(java.lang.String functionName, java.lang.Object[] args)
          calls a function on the current node
 void clear()
          removes all the child nodes of this node
 boolean equals(java.lang.Object obj)
           
 java.lang.Object getAttribute(java.lang.String name)
          returns the value of an attribute of the current node
 ClientPageNode[] getChildren()
          returns the child nodes
 java.lang.String getInnerHTML()
          retruns the inner HTML of the current node
 ClientPageNode getParent()
          returns the parent node of this node
 ClientPageNodeStyle getStyle()
          returns an object representing the node style.
 int hashCode()
           
 boolean isTag()
          returns true if this node is an HTML tag
 void remove()
          removes this node from the document DOM
 void removeChild(ClientPageNode node)
          removes a child node
 java.lang.Object removeChild(int index)
          removes a child node given its position
 void setAttribute(java.lang.String name, java.lang.Object value)
          sets an attribute value on the current value
 void setInnerHTML(java.lang.String innerHtml)
          sets the inner HTML of the current node
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientPageNode

public ClientPageNode(netscape.javascript.JSObject iJsObject)
creates a ClientPageNode that wraps the given JSObject

Parameters:
iJsObject - the JSObject to be wrapped
Method Detail

asJSObject

public netscape.javascript.JSObject asJSObject()
returns the wrapped JSObject

Returns:
the wrapped JSObject

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
returns the value of an attribute of the current node

Parameters:
name - the attribute name
Returns:
the value of an attribute of the current node

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
sets an attribute value on the current value

Parameters:
name - the attribute name
value - the new attribute value

getInnerHTML

public java.lang.String getInnerHTML()
retruns the inner HTML of the current node

Returns:
the inner HTML of the current node

setInnerHTML

public void setInnerHTML(java.lang.String innerHtml)
sets the inner HTML of the current node

Parameters:
innerHtml - the new inner HTML

call

public java.lang.Object call(java.lang.String functionName,
                             java.lang.Object[] args)
calls a function on the current node

Parameters:
functionName - the function name
args - the function argument values
Returns:
the result of the invocation

getParent

public ClientPageNode getParent()
returns the parent node of this node

Returns:
the parent node of this node

getChildren

public ClientPageNode[] getChildren()
returns the child nodes

Returns:
the child nodes

removeChild

public java.lang.Object removeChild(int index)
removes a child node given its position

Parameters:
index - the position of the child node to be eliminated
Returns:
the removed child node

removeChild

public void removeChild(ClientPageNode node)
removes a child node

Parameters:
node - the node to be removed

clear

public void clear()
removes all the child nodes of this node


remove

public void remove()
removes this node from the document DOM


appendChild

public ClientPageNode appendChild(java.lang.String tagName)
creates a new child node and appends it in the current node

Parameters:
tagName - the tag name of the child node
Returns:
the new child node

appendChild

public ClientPageNode appendChild(ClientPageNode node)
appends a new child node to the current node

Parameters:
node - the new child
Returns:
the added child node

appendTextChild

public void appendTextChild(java.lang.String text)
appends a new text child to the current node

Parameters:
text - the content of the text child

isTag

public boolean isTag()
returns true if this node is an HTML tag

Returns:
true if this node is an HTML tag

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getStyle

public ClientPageNodeStyle getStyle()
returns an object representing the node style. This object can be used to inspect or edit the node style.

Returns:
an object representing the node style