Oracle

com.bea.jsptools.tree
Class TreeNode

java.lang.Object
  extended by com.bea.jsptools.tree.TreeNode
All Implemented Interfaces:
Serializable, Comparable

public class TreeNode
extends Object
implements Comparable, Serializable

This class defines an object that JavaScript can render as a single node in a navigation tree.

A TreeNode contains data that you pass to its constructor, such as a unique identifier (ID), a user-visible name, a URL (which JavaScript can use to render a hyperlink for the node), and the ID of its parent node.

By default, a TreeNode's alternative text is the user-visible name and the image that it displays to indicate its expanded or collapsed state is images/spacer.gif. You can use this node's setter methods to change these defaults.

A TreeNode also contains runtime data, such as its state (expanded or collapsed), its sibling nodes, and its child nodes (if any other node has identified it as a parent).

See Also:
Serialized Form

Field Summary
protected static String VAR_NAME_CONSTANT
           
protected static String VAR_NAME_INCREMENT
           
 
Constructor Summary
TreeNode()
           
TreeNode(String nodeId, String nodeName, String nodeUrl)
          Constructs a TreeNode to be rendered at the top (root) level of the navigation tree.
TreeNode(String nodeId, String nodeName, String nodeUrl, TreeNode parent)
          Constructs a TreeNode to be rendered as a child of another node in the navigation tree.
 
Method Summary
 void addChild(TreeNode node)
          Adds a TreeNode as a child of this TreeNode.
 void addProperty(String key, String value)
          Adds an arbitrary (custom) property to this TreeNode.
 int compareTo(Object o)
           
 boolean equals(Object obj)
           
 boolean equals(TreeNode t)
           
static String escapeQuotes(String source)
          Escapes quotation marks, new line, and tabs in a String.
 String getAltText()
          Returns the alternative text for this node.
 List getChildren()
          Returns the collection of child TreeNodes for this TreeNode.
 String getIconSrcClosed()
          Returns the path and name of the image to display when this node is in a collapsed state.
 String getIconSrcOpen()
          Returns the path and name of the image to display when this node is in an expanded state.
 String getJavascriptDefinition()
          Returns the JavaScript representation of the TreeNode.
 TreeNode getNextSibling()
           
 String getNodeId()
          Returns the nodeId.
 String getNodeName()
          Returns the user-visible nodeName.
 String getNodeUrl()
          Returns the nodeUrl.
 TreeNode getParent()
          Returns the TreeNode object that represents this TreeNode's parent node.
 String getParentId()
          Returns the nodeId of this TreeNode's parent node.
 String getParentPath()
          Returns the path to this TreeNode's parent.
 String getPopupId()
          Returns the popupId, which is a string that displays in a popup window when a user right-clicks the node.
 int getPosition()
           
 TreeNode getPreviousSibling()
           
 Properties getProperties()
          Returns all of the custom properties that have been set for this TreeNode.
 String getPropertyValue(String key)
          Returns the value of property that was created using this TreeNode's TreeNode.addProperty(String, String) method.
static String getTaxonomyDelimeter()
          Returns the taxonomyDelimeter.
 String getVarName()
          Returns the variable name that JavaScript uses to refer to this TreeNode object.
 boolean hasChildren()
          Indicates whether this TreeNode has children.
static String htmlChars(String source)
          Encodes special characters as HTML entities.
 boolean isExpanded()
          Indicates if the node as rendered in the navigation tree is currently expanded.
 void removeChild(TreeNode node)
          Removes a TreeNode from this TreeNode's collection of child nodes.
 void replaceChild(TreeNode replace, TreeNode node)
          Replace a child TreeNode with another TreeNode.
 void setAltText(String altText)
          Sets the alternative text for this node.
 void setExpanded(boolean isExpanded)
          Sets the value of the isExpanded property.
 void setHasChildren(boolean hasChildren)
          Sets the value of the hasChildren property.
 void setIconSrcClosed(String iconSrcClosed)
          Sets the path and name of the image to display when this node is in a collapsed state.
 void setIconSrcOpen(String iconSrcOpen)
          Sets the path and name of the image to display when this node is in an expanded state.
 void setNextSibling(TreeNode nextSibling)
           
 void setNodeId(String nodeId)
          Sets the nodeId, which must be alphabetic and unique to all other nodeIds in the tree.
 void setNodeName(String nodeName)
          Sets the user-visible nodeName.
 void setNodeUrl(String nodeUrl)
          Sets the nodeUrl.
 void setParent(TreeNode parent)
          Sets the parent of this TreeNode.
 void setParentAlone(TreeNode parent)
          Sets the parent of this TreeNode but does not add it to the parent's collection of child nodes.
 void setParentPath(String parentPath)
          Sets the path to this TreeNode's parent.
 void setPopupId(String popupId)
          Sets the popupId, which is a string that displays in a popup window when a user right-clicks the node.
 void setPosition(int position)
           
 void setPreviousSibling(TreeNode previousSibling)
           
static void setTaxonomyDelimeter(String taxonomyDelimeter)
          Sets the taxonomyDelimeter.
 void setVarName(String varName)
          Sets the variable name that JavaScript uses to refer to this TreeNode object.
static String unescapeQuotes(String source)
          Replaces the Unicode escape sequence for quotation marks with with actual quotation-mark characters.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VAR_NAME_CONSTANT

protected static String VAR_NAME_CONSTANT

VAR_NAME_INCREMENT

protected static String VAR_NAME_INCREMENT
Constructor Detail

TreeNode

public TreeNode()

TreeNode

public TreeNode(String nodeId,
                String nodeName,
                String nodeUrl)

Constructs a TreeNode to be rendered at the top (root) level of the navigation tree.

The nodeId must be alphabetic and unique to all other nodeIds in the tree. This ID is intended to be used for programmatic purposes; users do not see it.

If you specify a relative URL for nodeUrl, it must be relative to the root of the Web application.

Parameters:
nodeId - A alphabetic string that uniquely identifies this node
nodeName - The display name of the node
nodeUrl - The URL of a resource to which this node links

TreeNode

public TreeNode(String nodeId,
                String nodeName,
                String nodeUrl,
                TreeNode parent)

Constructs a TreeNode to be rendered as a child of another node in the navigation tree.

The nodeId must be alphabetic and unique to all other nodeIds in the tree. This ID is intended to be used for programmatic purposes; users do not see it.

If you specify a relative URL for nodeUrl, it must be relative to the root of the Web application.

Parameters:
nodeId - A alphabetic string that uniquely identifies this node
nodeName - The display name of the node
nodeUrl - The URL of a resource to which this node links
parent - The TreeNode object that is the parent of this node
Method Detail

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getAltText

public String getAltText()

Returns the alternative text for this node. Most user agents display this text in a popup when the user hovers a mouse over the node.

Returns:
A String that contains the alternative text for this node

getIconSrcClosed

public String getIconSrcClosed()

Returns the path and name of the image to display when this node is in a collapsed state. The pathname is relative to the root of the Web application.

Returns:
A String that contains the path and name of the iconSrcClosed image

getIconSrcOpen

public String getIconSrcOpen()

Returns the path and name of the image to display when this node is in an expanded state. The pathname is relative to the root of the Web application.

Returns:
A String that contains the path and name of the iconSrcOpen image

getNodeId

public String getNodeId()
Returns the nodeId.

Returns:
A String that contains the node identifier

getNodeName

public String getNodeName()
Returns the user-visible nodeName.

Returns:
A String that contains the user-visible name of the node

getNodeUrl

public String getNodeUrl()
Returns the nodeUrl. If this value is not null, JavaScript functions can render the node as a hyperlink to this URL.

Returns:
A String that contains a URL to which this node can link

getPopupId

public String getPopupId()

Returns the popupId, which is a string that displays in a popup window when a user right-clicks the node.

Returns:
A String that contains the popupId

setAltText

public void setAltText(String altText)

Sets the alternative text for this node. Most user agents display this text in a popup when the user hovers a mouse over the node.

By default, this value is set to the value of nodeName, which is passed to this object's constructor.

Parameters:
altText - A String that contains the alternative text for this node

setIconSrcClosed

public void setIconSrcClosed(String iconSrcClosed)

Sets the path and name of the image to display when this node is in a collapsed state. The pathname must be relative to the root of the Web application.

By default, this value is set to images/spacer.gif.

Parameters:
iconSrcClosed - A String that contains the path and name of the iconSrcClosed image

setIconSrcOpen

public void setIconSrcOpen(String iconSrcOpen)

Sets the path and name of the image to display when this node is in an expanded state. The pathname must be relative to the root of the Web application.

By default, this value is set to images/spacer.gif.

Parameters:
iconSrcOpen - A String that contains the path and name of the iconSrcOpen image

setNodeId

public void setNodeId(String nodeId)

Sets the nodeId, which must be alphabetic and unique to all other nodeIds in the tree. This ID is intended to be used for programmatic purposes; users do not see it.

Parameters:
nodeId - A String that contains the nodeId

setNodeName

public void setNodeName(String nodeName)
Sets the user-visible nodeName.

Parameters:
nodeName - A String that contains the user-visible nodeName

setNodeUrl

public void setNodeUrl(String nodeUrl)
Sets the nodeUrl.

Parameters:
nodeUrl - The nodeUrl to set

setPopupId

public void setPopupId(String popupId)

Sets the popupId, which is a string that displays in a popup window when a user right-clicks the node.

Parameters:
popupId - A String that contains the popupId

addProperty

public void addProperty(String key,
                        String value)
Adds an arbitrary (custom) property to this TreeNode.

Parameters:
key - A String that contains the key for this key-value pair
value - A String that contains the value for this key-value pair

getPropertyValue

public String getPropertyValue(String key)

Returns the value of property that was created using this TreeNode's TreeNode.addProperty(String, String) method.

Returns null if key not found.

Parameters:
key - A String that contains the key for a key-value pair
Returns:
String

getProperties

public Properties getProperties()
Returns all of the custom properties that have been set for this TreeNode.

Returns:
Properties

getTaxonomyDelimeter

public static String getTaxonomyDelimeter()
Returns the taxonomyDelimeter.

Returns:
String

setTaxonomyDelimeter

public static void setTaxonomyDelimeter(String taxonomyDelimeter)
Sets the taxonomyDelimeter.

Parameters:
taxonomyDelimeter - The taxonomyDelimeter to set

getParentId

public String getParentId()
Returns the nodeId of this TreeNode's parent node.

Returns:
A String that contains the nodeId of this TreeNode's parent

getParent

public TreeNode getParent()
Returns the TreeNode object that represents this TreeNode's parent node.

Returns:
The TreeNode object that represents this TreeNode's parent

setParent

public void setParent(TreeNode parent)
Sets the parent of this TreeNode.

Parameters:
parent - The parent TreeNode object of this TreeNode

setParentAlone

public void setParentAlone(TreeNode parent)

Sets the parent of this TreeNode but does not add it to the parent's collection of child nodes.

Use this method in cases such as 'replaceChild' where the caller is managing the collection.

Parameters:
parent -

getChildren

public List getChildren()
Returns the collection of child TreeNodes for this TreeNode.

Returns:
List of TreeNode objects that represent this TreeNode's children

addChild

public void addChild(TreeNode node)
Adds a TreeNode as a child of this TreeNode.

Parameters:
node - The TreeNode to add as a child

removeChild

public void removeChild(TreeNode node)
Removes a TreeNode from this TreeNode's collection of child nodes.

Parameters:
node - The TreeNode to remove

replaceChild

public void replaceChild(TreeNode replace,
                         TreeNode node)
Replace a child TreeNode with another TreeNode.

Parameters:
replace - The old TreeNode, which will be removed as a child
node - The new TreeNode, which will be added as a child

getVarName

public String getVarName()
Returns the variable name that JavaScript uses to refer to this TreeNode object.

Returns:
A String that contains the variable name

setVarName

public void setVarName(String varName)
Sets the variable name that JavaScript uses to refer to this TreeNode object.

Parameters:
varName - A String that contains the name of the variable

isExpanded

public boolean isExpanded()
Indicates if the node as rendered in the navigation tree is currently expanded. An expanded node shows the list of its child nodes.

Returns:
boolean

setExpanded

public void setExpanded(boolean isExpanded)
Sets the value of the isExpanded property.

Parameters:
isExpanded - The isExpanded to set

hasChildren

public boolean hasChildren()
Indicates whether this TreeNode has children.

Returns:
boolean

setHasChildren

public void setHasChildren(boolean hasChildren)
Sets the value of the hasChildren property.

Parameters:
hasChildren - The hasChildren to set

htmlChars

public static String htmlChars(String source)

Encodes special characters as HTML entities.

'<' becomes &lt;
'>' becomes &gt;
'&' becomes &amp;
'"' becomes &quot;
"'" becomes &#39;

Parameters:
source -
Returns:
String

escapeQuotes

public static String escapeQuotes(String source)
Escapes quotation marks, new line, and tabs in a String.

Parameters:
source - A String with quotation marks, new line or tab characters
Returns:
A String with these characters escaped

unescapeQuotes

public static String unescapeQuotes(String source)

Replaces the Unicode escape sequence for quotation marks with with actual quotation-mark characters.

For example, this method replaces "\\\\u0027" with "'".

Parameters:
source - A String that contains the Unicode escape sequence
Returns:
A String that contains real quotation marks

getJavascriptDefinition

public String getJavascriptDefinition()
Returns the JavaScript representation of the TreeNode.

Parameters:
parent - - This is the javascript representation of the parent node. Should be null for the root node
Returns:
String

compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable

equals

public boolean equals(TreeNode t)

getParentPath

public String getParentPath()

Returns the path to this TreeNode's parent.

Each component of the path is the nodeName of an ancestor TreeNode. A "/" (slash) separates each component.

A path that contains only "/" represents the root of the tree and indicates that this TreeNode is at the top level.


setParentPath

public void setParentPath(String parentPath)

Sets the path to this TreeNode's parent.

Each component of the path is the nodeName of an ancestor TreeNode. A "/" (slash) separates each component.

To place this TreeNode at the top level, specify only "/", which represents the root of the tree.

Parameters:
parentPath - A String that specifies the path to the parent node

getPosition

public int getPosition()

setPosition

public void setPosition(int position)

getPreviousSibling

public TreeNode getPreviousSibling()

setPreviousSibling

public void setPreviousSibling(TreeNode previousSibling)

getNextSibling

public TreeNode getNextSibling()

setNextSibling

public void setNextSibling(TreeNode nextSibling)

Documentation is available at
http://edocs.bea.com/wls/docs103
Copyright 1996,2008, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.