| java.lang.Object org.w3c.tidy.Node
Node | public class Node implements Cloneable(Code) | | Used for elements and text nodes element name is null for text nodes start and end are offsets into lexbuf which
contains the textual content of all elements in the parse tree. Parent and content allow traversal of the parse tree
in any direction. attributes are represented as a linked list of AttVal nodes which hold the strings for
attribute/value pairs.
author: Dave Raggett dsr@w3.org author: Andy Quick ac.quick@sympatico.ca (translation to Java) author: Fabrizio Giustina version: $Revision: 1.31 $ ($Author: fgiust $) |
Field Summary | |
final public static short | ASP_TAG node type: asp tag. | final public static short | CDATA_TAG node type: CDATA. | final public static short | COMMENT_TAG node type: comment. | final public static short | DOCTYPE_TAG node type: doctype. | final public static short | END_TAG End tag. | final public static short | JSTE_TAG node type: jste tag. | final public static short | PHP_TAG node type: php tag. | final public static short | PROC_INS_TAG node type: . | final public static short | ROOT_NODE node type: root. | final public static short | SECTION_TAG node type: section tag. | final public static short | START_END_TAG Start of an end tag. | final public static short | START_TAG Start tag. | final public static short | TEXT_NODE node type: text. | final public static short | XML_DECL node type: doctype. | protected org.w3c.dom.Node | adapter DOM adapter. | protected AttVal | attributes Attribute/Value linked list. | protected boolean | closed true if closed by explicit end tag. | protected Node | content Contained node. | protected String | element Tag name. | protected int | end end of span onto text array. | protected boolean | implicit true if inferred. | protected Node | last last node. | protected boolean | linebreak true if followed by a line break. | protected Node | next next node. | protected Node | parent parent node. | protected Node | prev pevious node. | protected int | start start of span onto text array. | protected Dict | tag tag's dictionary definition. | protected byte[] | textarray the text array. | protected short | type TextNode, StartTag, EndTag etc. | protected Dict | was old tag when it was changed. |
Constructor Summary | |
public | Node() Instantiates a new text node. | public | Node(short type, byte[] textarray, int start, int end) Instantiates a new node.
Parameters: type - node type: Node.ROOT_NODE | Node.DOCTYPE_TAG | Node.COMMENT_TAG | Node.PROC_INS_TAG | Node.TEXT_NODE |Node.START_TAG | Node.END_TAG | Node.START_END_TAG | Node.CDATA_TAG | Node.SECTION_TAG | Node. | public | Node(short type, byte[] textarray, int start, int end, String element, TagTable tt) Instantiates a new node.
Parameters: type - node type: Node.ROOT_NODE | Node.DOCTYPE_TAG | Node.COMMENT_TAG | Node.PROC_INS_TAG | Node.TEXT_NODE |Node.START_TAG | Node.END_TAG | Node.START_END_TAG | Node.CDATA_TAG | Node.SECTION_TAG | Node. |
Method Summary | |
public void | addAttribute(String name, String value) Adds an attribute to the node. | public void | addClass(String classname) Add a css class to the node. | public void | checkAttributes(Lexer lexer) Default method for checking an element's attributes. | public boolean | checkNodeIntegrity() Checks for node integrity. | protected Object | clone() Used to clone heading nodes when split by an hr. | protected Node | cloneNode(boolean deep) Clone this node. | public static void | coerceNode(Lexer lexer, Node node, Dict tag) Coerce a node. | public void | discardDocType() Discard the doctype node. | public static Node | discardElement(Node element) Remove node from markup tree and discard it. | protected static Node | escapeTag(Lexer lexer, Node element) Escapes the given tag. | public boolean | expectsContent() | public Node | findBody(TagTable tt) Find the body node. | public Node | findDocType() Find the doctype element. | public Node | findHEAD(TagTable tt) Find the head tag. | public Node | findHTML(TagTable tt) Find the "html" element. | public static void | fixEmptyRow(Lexer lexer, Node row) If a table row is empty then insert an empty cell.This practice is consistent with browser behavior and avoids
potential problems with row spanning cells. | protected org.w3c.dom.Node | getAdapter() Returns a DOM Node which wrap the current tidy Node. | public AttVal | getAttrByName(String name) Returns an attribute with the given name in the current node.
Parameters: name - attribute name. | public boolean | hasOneChild() | public static void | insertDocType(Lexer lexer, Node element, Node doctype) The doctype has been found after other tags, and needs moving to before the html element. | public static boolean | insertMisc(Node element, Node node) Insert a node at the end. | public void | insertNodeAfterElement(Node node) Insert node into markup tree after element. | public static void | insertNodeAsParent(Node element, Node node) Insert node into markup tree in pace of element which is moved to become the child of the node.
Parameters: element - child node. | public void | insertNodeAtEnd(Node node) Insert node into markup tree. | public void | insertNodeAtStart(Node node) Insert a node into markup tree. | public static void | insertNodeBeforeElement(Node element, Node node) Insert node into markup tree before element.
Parameters: element - child node. | public boolean | isBlank(Lexer lexer) Is the node content empty or blank? Assumes node is a text node. | public boolean | isDescendantOf(Dict tag) | public boolean | isElement() | public boolean | isJavaScript() Used to check script node for script language. | public boolean | isNewNode() Is this a new (user defined) node? Used to determine how attributes without values should be printed. | public static void | moveBeforeTable(Node row, Node node, TagTable tt) Unexpected content in table row is moved to just before the table in accordance with Netscape and IE. | public void | removeAttribute(AttVal attr) Remove an attribute from node and then free it. | public void | removeNode() Extract this node and its children from a markup tree. | public void | repairDuplicateAttributes(Lexer lexer) The same attribute name can't be used more than once in each element. | protected void | setType(short newType) Setter for node type. | public String | toString() | public static void | trimEmptyElement(Lexer lexer, Node element) Trim an empty element. | public static void | trimInitialSpace(Lexer lexer, Node element, Node text) This maps <p> hello <em> world </em> to <p> hello <em> world </em> . | public static void | trimSpaces(Lexer lexer, Node element) Move initial and trailing space out. | public static void | trimTrailingSpace(Lexer lexer, Node element, Node last) This maps hello world to hello world . |
ASP_TAG | final public static short ASP_TAG(Code) | | node type: asp tag.
|
CDATA_TAG | final public static short CDATA_TAG(Code) | | node type: CDATA.
|
COMMENT_TAG | final public static short COMMENT_TAG(Code) | | node type: comment.
|
DOCTYPE_TAG | final public static short DOCTYPE_TAG(Code) | | node type: doctype.
|
END_TAG | final public static short END_TAG(Code) | | End tag.
|
JSTE_TAG | final public static short JSTE_TAG(Code) | | node type: jste tag.
|
PHP_TAG | final public static short PHP_TAG(Code) | | node type: php tag.
|
PROC_INS_TAG | final public static short PROC_INS_TAG(Code) | | node type: .
|
ROOT_NODE | final public static short ROOT_NODE(Code) | | node type: root.
|
SECTION_TAG | final public static short SECTION_TAG(Code) | | node type: section tag.
|
START_END_TAG | final public static short START_END_TAG(Code) | | Start of an end tag.
|
START_TAG | final public static short START_TAG(Code) | | Start tag.
|
TEXT_NODE | final public static short TEXT_NODE(Code) | | node type: text.
|
XML_DECL | final public static short XML_DECL(Code) | | node type: doctype.
|
attributes | protected AttVal attributes(Code) | | Attribute/Value linked list.
|
closed | protected boolean closed(Code) | | true if closed by explicit end tag.
|
content | protected Node content(Code) | | Contained node.
|
end | protected int end(Code) | | end of span onto text array.
|
implicit | protected boolean implicit(Code) | | true if inferred.
|
linebreak | protected boolean linebreak(Code) | | true if followed by a line break.
|
start | protected int start(Code) | | start of span onto text array.
|
tag | protected Dict tag(Code) | | tag's dictionary definition.
|
textarray | protected byte[] textarray(Code) | | the text array.
|
type | protected short type(Code) | | TextNode, StartTag, EndTag etc.
|
was | protected Dict was(Code) | | old tag when it was changed.
|
Node | public Node()(Code) | | Instantiates a new text node.
|
Node | public Node(short type, byte[] textarray, int start, int end)(Code) | | Instantiates a new node.
Parameters: type - node type: Node.ROOT_NODE | Node.DOCTYPE_TAG | Node.COMMENT_TAG | Node.PROC_INS_TAG | Node.TEXT_NODE |Node.START_TAG | Node.END_TAG | Node.START_END_TAG | Node.CDATA_TAG | Node.SECTION_TAG | Node. ASP_TAG |Node.JSTE_TAG | Node.PHP_TAG | Node.XML_DECL Parameters: textarray - array of bytes contained in the Node Parameters: start - start position Parameters: end - end position |
Node | public Node(short type, byte[] textarray, int start, int end, String element, TagTable tt)(Code) | | Instantiates a new node.
Parameters: type - node type: Node.ROOT_NODE | Node.DOCTYPE_TAG | Node.COMMENT_TAG | Node.PROC_INS_TAG | Node.TEXT_NODE |Node.START_TAG | Node.END_TAG | Node.START_END_TAG | Node.CDATA_TAG | Node.SECTION_TAG | Node. ASP_TAG |Node.JSTE_TAG | Node.PHP_TAG | Node.XML_DECL Parameters: textarray - array of bytes contained in the Node Parameters: start - start position Parameters: end - end position Parameters: element - tag name Parameters: tt - tag table instance |
addAttribute | public void addAttribute(String name, String value)(Code) | | Adds an attribute to the node.
Parameters: name - attribute name Parameters: value - attribute value |
addClass | public void addClass(String classname)(Code) | | Add a css class to the node. If a class attribute already exists adds the value to the existing attribute.
Parameters: classname - css class name |
checkAttributes | public void checkAttributes(Lexer lexer)(Code) | | Default method for checking an element's attributes.
Parameters: lexer - Lexer |
checkNodeIntegrity | public boolean checkNodeIntegrity()(Code) | | Checks for node integrity.
false if node is not consistent |
cloneNode | protected Node cloneNode(boolean deep)(Code) | | Clone this node.
Parameters: deep - if true deep clone the node (also clones all the contained nodes) cloned node |
coerceNode | public static void coerceNode(Lexer lexer, Node node, Dict tag)(Code) | | Coerce a node.
Parameters: lexer - Lexer Parameters: node - Node Parameters: tag - tag dictionary reference |
discardDocType | public void discardDocType()(Code) | | Discard the doctype node.
|
discardElement | public static Node discardElement(Node element)(Code) | | Remove node from markup tree and discard it.
Parameters: element - discarded node next node |
escapeTag | protected static Node escapeTag(Lexer lexer, Node element)(Code) | | Escapes the given tag.
Parameters: lexer - Lexer Parameters: element - node to be escaped escaped node |
expectsContent | public boolean expectsContent()(Code) | | Does the node expect contents?
false if this node should be empty |
findBody | public Node findBody(TagTable tt)(Code) | | Find the body node.
Parameters: tt - tag table body node |
findDocType | public Node findDocType()(Code) | | Find the doctype element.
doctype node or null if not found |
findHEAD | public Node findHEAD(TagTable tt)(Code) | | Find the head tag.
Parameters: tt - tag table head node |
findHTML | public Node findHTML(TagTable tt)(Code) | | Find the "html" element.
Parameters: tt - tag table html node |
fixEmptyRow | public static void fixEmptyRow(Lexer lexer, Node row)(Code) | | If a table row is empty then insert an empty cell.This practice is consistent with browser behavior and avoids
potential problems with row spanning cells.
Parameters: lexer - Lexer Parameters: row - row node |
getAdapter | protected org.w3c.dom.Node getAdapter()(Code) | | Returns a DOM Node which wrap the current tidy Node.
org.w3c.dom.Node instance |
getAttrByName | public AttVal getAttrByName(String name)(Code) | | Returns an attribute with the given name in the current node.
Parameters: name - attribute name. AttVal instance or null if no attribute with the iven name is found |
hasOneChild | public boolean hasOneChild()(Code) | | Does the node have one (and only one) child?
true if the node has one child |
insertDocType | public static void insertDocType(Lexer lexer, Node element, Node doctype)(Code) | | The doctype has been found after other tags, and needs moving to before the html element.
Parameters: lexer - Lexer Parameters: element - document Parameters: doctype - doctype node to insert at the beginning of element |
insertMisc | public static boolean insertMisc(Node element, Node node)(Code) | | Insert a node at the end.
Parameters: element - parent node Parameters: node - will be inserted at the end of element true if the node has been inserted |
insertNodeAfterElement | public void insertNodeAfterElement(Node node)(Code) | | Insert node into markup tree after element.
Parameters: node - new node to insert |
insertNodeAsParent | public static void insertNodeAsParent(Node element, Node node)(Code) | | Insert node into markup tree in pace of element which is moved to become the child of the node.
Parameters: element - child node. Will be inserted as a child of element Parameters: node - parent node |
insertNodeAtEnd | public void insertNodeAtEnd(Node node)(Code) | | Insert node into markup tree.
Parameters: node - Node to insert |
insertNodeAtStart | public void insertNodeAtStart(Node node)(Code) | | Insert a node into markup tree.
Parameters: node - to insert |
insertNodeBeforeElement | public static void insertNodeBeforeElement(Node element, Node node)(Code) | | Insert node into markup tree before element.
Parameters: element - child node. Will be insertedbefore element Parameters: node - following node |
isBlank | public boolean isBlank(Lexer lexer)(Code) | | Is the node content empty or blank? Assumes node is a text node.
Parameters: lexer - Lexer true if the node content empty or blank |
isDescendantOf | public boolean isDescendantOf(Dict tag)(Code) | | Is this node contained in a given tag?
Parameters: tag - descendant tag true if node is contained in tag |
isElement | public boolean isElement()(Code) | | Is the node an element?
true if type is START_TAG | START_END_TAG |
isJavaScript | public boolean isJavaScript()(Code) | | Used to check script node for script language.
true if the script node contains javascript |
isNewNode | public boolean isNewNode()(Code) | | Is this a new (user defined) node? Used to determine how attributes without values should be printed. This was
introduced to deal with user defined tags e.g. Cold Fusion.
true if this node represents a user-defined tag. |
moveBeforeTable | public static void moveBeforeTable(Node row, Node node, TagTable tt)(Code) | | Unexpected content in table row is moved to just before the table in accordance with Netscape and IE. This code
assumes that node hasn't been inserted into the row.
Parameters: row - Row node Parameters: node - Node which should be moved before the table Parameters: tt - tag table |
removeAttribute | public void removeAttribute(AttVal attr)(Code) | | Remove an attribute from node and then free it.
Parameters: attr - attribute to remove |
removeNode | public void removeNode()(Code) | | Extract this node and its children from a markup tree.
|
repairDuplicateAttributes | public void repairDuplicateAttributes(Lexer lexer)(Code) | | The same attribute name can't be used more than once in each element. Discard or join attributes according to
configuration.
Parameters: lexer - Lexer |
setType | protected void setType(short newType)(Code) | | Setter for node type.
Parameters: newType - a valid node type constant |
trimEmptyElement | public static void trimEmptyElement(Lexer lexer, Node element)(Code) | | Trim an empty element.
Parameters: lexer - Lexer Parameters: element - empty node to be removed |
trimInitialSpace | public static void trimInitialSpace(Lexer lexer, Node element, Node text)(Code) | | This maps <p> hello <em> world </em> to <p> hello <em> world </em> .
Trims initial space, by moving it before the start tag, or if this element is the first in parent's content, then
by discarding the space.
Parameters: lexer - Lexer Parameters: element - parent node Parameters: text - text node |
trimSpaces | public static void trimSpaces(Lexer lexer, Node element)(Code) | | Move initial and trailing space out. This routine maps: hello world to hello world and
hello world to hello world .
Parameters: lexer - Lexer Parameters: element - Node |
trimTrailingSpace | public static void trimTrailingSpace(Lexer lexer, Node element, Node last)(Code) | | This maps hello world to hello world . If last child of
element is a text node then trim trailing white space character moving it to after element's end tag.
Parameters: lexer - Lexer Parameters: element - node Parameters: last - last child of element |
|
|