|
|||||||||
| Home >> All >> cvu >> [ html overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
cvu.html
Class HTMLNode

java.lang.Objectcvu.html.HTMLNode
- public class HTMLNode
- extends java.lang.Object
This class represents a single node within an HTML tree. Each node has a name, zero or more attributes and possibly some content. Nodes can appear within the content of other nodes.
End tags do not appear since they only indicate 'end-of-content'. To prevent the system searching for the end of standalone tags, a dynamic list has been implemented. When the HTMLNode class is resolved a setup method is called adding a set of default standalone tags to the list. Standalone tags can then be added and removed dynamically using static method calls.
The list is the only way the internal code can tell whether a tag is standalone. If a problem occurs the tree structure would still be sound, but it would not be accurate, so while the form of the HTML would be conserved, searches would not operate correctly.
| Field Summary | |
private AttributeList |
attr
|
private java.util.Vector |
children
|
private static java.lang.String[] |
defaultStandaloneList
String of default node names which are standalone. |
private boolean |
hidden
|
private java.lang.String |
name
|
private HTMLNode |
parent
|
private static java.util.Vector |
standaloneList
|
| Constructor Summary | |
HTMLNode(java.lang.String name)
Constructs a new, detached HTMLNode with the specified name. |
|
HTMLNode(TagToken tag,
HTMLNode parent,
java.util.Enumeration src)
Constructs a new HTMLNode. |
|
| Method Summary | |
void |
addAttribute(java.lang.String name,
java.lang.String value)
Adds a new attribute to the node's attribute list with the specified value. |
void |
addChild(java.lang.Object child)
Adds an object to the end of this node's content |
void |
addChildBefore(java.lang.Object child,
HTMLNode before)
Adds an object to this node's content before the specified child node. |
static void |
addStandalone(java.lang.String name)
Adds the specified string to the standalone list. |
HTMLNode |
firstChild()
Returns the first child of this node. |
java.lang.String |
getAttribute(java.lang.String name)
Returns the value of the attribute with the given name. |
java.util.Enumeration |
getAttributes()
Returns an enumeration of attributes defined in this node. |
java.lang.String |
getAttributeToString(java.lang.String name)
Returns a string version of the attribute and its value. |
java.util.Enumeration |
getChildren()
Returns the node's children. |
java.lang.String |
getName()
Returns the name of this node. |
HTMLNode |
getParent()
Returns the node's parent node. |
java.lang.String |
getQuotedAttribute(java.lang.String name)
Returns an attribute with all double quote characters escaped with a backslash. |
void |
hide()
Hides the node. |
boolean |
isAttribute(java.lang.String name)
Returns true if an attribute with the given name exists. |
boolean |
isHidden()
Returns true if the node is currently hidden. |
static boolean |
isStandalone(java.lang.String name)
Checks the standalone list to see if it mentions the specified tag name and returns true if so. |
HTMLNode |
nextChild(HTMLNode child)
Returns the HTMLNode after the specified one in this nodes content. |
HTMLNode |
nextSibling()
Returns the node after this one in the parent's list of children. |
private java.util.Vector |
parseChildren(java.util.Enumeration src)
Parses the contents of this HTML node from the enumeration of tokens provided. |
HTMLNode |
previousChild(HTMLNode child)
Returns the HTMLNode before the specified one in this nodes content. |
HTMLNode |
previousSibling()
Returns the node before this one in the parent's list of children. |
static void |
printDefaultStandaloneList()
Utility method which people can use to find out exactly which nodes are in the default standalone list. |
void |
removeAttribute(java.lang.String name)
Removes an attribute with the specified name from the attribute list. |
void |
removeChild(HTMLNode child)
Removes the specified HTMLNode from the current node's list of children. |
static void |
removeStandalone(java.lang.String name)
Removes the specified string from the standalone list. |
void |
setParent(HTMLNode parent)
Sets the node's parent to the specified HTMLNode. |
private static void |
setupStandaloneList()
Sets up the standalone vector at runtime using the list of default standalone tags. |
java.lang.String |
toString()
Returns a string version of the HTMLNode. |
void |
unhide()
"Unhides" the node. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
parent
private HTMLNode parent
name
private java.lang.String name
attr
private AttributeList attr
children
private java.util.Vector children
hidden
private boolean hidden
defaultStandaloneList
private static java.lang.String[] defaultStandaloneList
- String of default node names which are standalone.
standaloneList
private static java.util.Vector standaloneList
| Constructor Detail |
HTMLNode
public HTMLNode(TagToken tag, HTMLNode parent, java.util.Enumeration src)
- Constructs a new HTMLNode.
HTMLNode
public HTMLNode(java.lang.String name)
- Constructs a new, detached HTMLNode with the specified name.
| Method Detail |
getName
public java.lang.String getName()
- Returns the name of this node.
getParent
public HTMLNode getParent()
- Returns the node's parent node.
getChildren
public java.util.Enumeration getChildren()
- Returns the node's children.
isHidden
public boolean isHidden()
- Returns true if the node is currently hidden.
hide
public void hide()
- Hides the node.
unhide
public void unhide()
- "Unhides" the node.
getAttribute
public java.lang.String getAttribute(java.lang.String name)
- Returns the value of the attribute with the given name.
getAttributes
public java.util.Enumeration getAttributes()
- Returns an enumeration of attributes defined in this node.
getQuotedAttribute
public java.lang.String getQuotedAttribute(java.lang.String name)
- Returns an attribute with all double quote characters
escaped with a backslash.
getAttributeToString
public java.lang.String getAttributeToString(java.lang.String name)
- Returns a string version of the attribute and its value.
toString
public java.lang.String toString()
- Returns a string version of the HTMLNode. If the node is
currently hidden then return an empty string.
setParent
public void setParent(HTMLNode parent)
- Sets the node's parent to the specified HTMLNode.
isAttribute
public boolean isAttribute(java.lang.String name)
- Returns true if an attribute with the given name exists.
addAttribute
public void addAttribute(java.lang.String name, java.lang.String value)
- Adds a new attribute to the node's attribute list with
the specified value. If the attribute already exists the
old value is overwritten.
addChild
public void addChild(java.lang.Object child)
- Adds an object to the end of this node's content
removeChild
public void removeChild(HTMLNode child)
- Removes the specified HTMLNode from the current node's
list of children.
addChildBefore
public void addChildBefore(java.lang.Object child, HTMLNode before)
- Adds an object to this node's content before
the specified child node.
removeAttribute
public void removeAttribute(java.lang.String name)
- Removes an attribute with the specified name from the
attribute list.
nextSibling
public HTMLNode nextSibling()
- Returns the node after this one in the parent's
list of children.
previousSibling
public HTMLNode previousSibling()
- Returns the node before this one in the parent's
list of children.
firstChild
public HTMLNode firstChild()
- Returns the first child of this node.
nextChild
public HTMLNode nextChild(HTMLNode child)
- Returns the HTMLNode after the specified one in this
nodes content.
previousChild
public HTMLNode previousChild(HTMLNode child)
- Returns the HTMLNode before the specified one in this
nodes content.
parseChildren
private java.util.Vector parseChildren(java.util.Enumeration src)
- Parses the contents of this HTML node from the enumeration
of tokens provided.
printDefaultStandaloneList
public static void printDefaultStandaloneList()
- Utility method which people can use to find out exactly
which nodes are in the default standalone list. The default
list is printed to the standard output.
addStandalone
public static void addStandalone(java.lang.String name)
- Adds the specified string to the standalone list.
removeStandalone
public static void removeStandalone(java.lang.String name)
- Removes the specified string from the standalone list.
isStandalone
public static boolean isStandalone(java.lang.String name)
- Checks the standalone list to see if it mentions the specified
tag name and returns true if so.
setupStandaloneList
private static void setupStandaloneList()
- Sets up the standalone vector at runtime using the list of
default standalone tags. New standalone tags can then be added
to the vector.
This method will only be executed once, since it is guarded by a private boolean variable.
|
|||||||||
| Home >> All >> cvu >> [ html overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
cvu.html.HTMLNode