java.lang.Cloneablepublic class Node
extends java.lang.Object
implements java.lang.Cloneable
| Modifier and Type | Field | Description |
|---|---|---|
protected org.w3c.dom.Node |
adapter |
DOM adapter.
|
static short |
ASP_TAG |
node type: asp tag.
|
protected AttVal |
attributes |
Attribute/Value linked list.
|
static short |
CDATA_TAG |
node type: CDATA.
|
protected boolean |
closed |
true if closed by explicit end tag.
|
static short |
COMMENT_TAG |
node type: comment.
|
protected Node |
content |
Contained node.
|
static short |
DOCTYPE_TAG |
node type: doctype.
|
protected java.lang.String |
element |
Tag name.
|
protected int |
end |
end of span onto text array.
|
static short |
END_TAG |
End tag.
|
protected boolean |
implicit |
true if inferred.
|
static short |
JSTE_TAG |
node type: jste tag.
|
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.
|
static short |
PHP_TAG |
node type: php tag.
|
protected Node |
prev |
pevious node.
|
static short |
PROC_INS_TAG |
node type: .
|
static short |
ROOT_NODE |
node type: root.
|
static short |
SECTION_TAG |
node type: section tag.
|
protected int |
start |
start of span onto text array.
|
static short |
START_END_TAG |
Start of an end tag.
|
static short |
START_TAG |
Start tag.
|
protected Dict |
tag |
tag's dictionary definition.
|
static short |
TEXT_NODE |
node type: text.
|
protected byte[] |
textarray |
the text array.
|
protected short |
type |
TextNode, StartTag, EndTag etc.
|
protected Dict |
was |
old tag when it was changed.
|
static short |
XML_DECL |
node type: doctype.
|
| Constructor | Description |
|---|---|
Node() |
Instantiates a new text node.
|
Node(short type,
byte[] textarray,
int start,
int end) |
Instantiates a new node.
|
Node(short type,
byte[] textarray,
int start,
int end,
java.lang.String element,
TagTable tt) |
Instantiates a new node.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addAttribute(java.lang.String name,
java.lang.String value) |
Adds an attribute to the node.
|
void |
addClass(java.lang.String classname) |
Add a css class to the node.
|
void |
checkAttributes(Lexer lexer) |
Default method for checking an element's attributes.
|
boolean |
checkNodeIntegrity() |
Checks for node integrity.
|
protected java.lang.Object |
clone() |
Used to clone heading nodes when split by an hr.
|
protected Node |
cloneNode(boolean deep) |
Clone this node.
|
static void |
coerceNode(Lexer lexer,
Node node,
Dict tag) |
Coerce a node.
|
void |
discardDocType() |
Discard the doctype node.
|
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.
|
boolean |
expectsContent() |
Does the node expect contents?
|
Node |
findBody(TagTable tt) |
Find the body node.
|
Node |
findDocType() |
Find the doctype element.
|
Node |
findHEAD(TagTable tt) |
Find the head tag.
|
Node |
findHTML(TagTable tt) |
Find the "html" element.
|
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.
|
AttVal |
getAttrByName(java.lang.String name) |
Returns an attribute with the given name in the current node.
|
boolean |
hasOneChild() |
Does the node have one (and only one) child?
|
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.
|
static boolean |
insertMisc(Node element,
Node node) |
Insert a node at the end.
|
void |
insertNodeAfterElement(Node node) |
Insert node into markup tree after element.
|
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.
|
void |
insertNodeAtEnd(Node node) |
Insert node into markup tree.
|
void |
insertNodeAtStart(Node node) |
Insert a node into markup tree.
|
static void |
insertNodeBeforeElement(Node element,
Node node) |
Insert node into markup tree before element.
|
boolean |
isBlank(Lexer lexer) |
Is the node content empty or blank? Assumes node is a text node.
|
boolean |
isDescendantOf(Dict tag) |
Is this node contained in a given tag?
|
boolean |
isElement() |
Is the node an element?
|
boolean |
isJavaScript() |
Used to check script node for script language.
|
boolean |
isNewNode() |
Is this a new (user defined) node? Used to determine how attributes without values should be printed.
|
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.
|
void |
removeAttribute(AttVal attr) |
Remove an attribute from node and then free it.
|
void |
removeNode() |
Extract this node and its children from a markup tree.
|
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.
|
java.lang.String |
toString() |
|
static void |
trimEmptyElement(Lexer lexer,
Node element) |
Trim an empty element.
|
static void |
trimInitialSpace(Lexer lexer,
Node element,
Node text) |
This maps
<p> hello <em> world </em> to <p> hello <em> world </em>. |
static void |
trimSpaces(Lexer lexer,
Node element) |
Move initial and trailing space out.
|
static void |
trimTrailingSpace(Lexer lexer,
Node element,
Node last) |
This maps hello world to hello world .
|
public static final short ROOT_NODE
public static final short DOCTYPE_TAG
public static final short COMMENT_TAG
public static final short PROC_INS_TAG
public static final short TEXT_NODE
public static final short START_TAG
public static final short END_TAG
public static final short START_END_TAG
public static final short CDATA_TAG
public static final short SECTION_TAG
public static final short ASP_TAG
public static final short JSTE_TAG
public static final short PHP_TAG
public static final short XML_DECL
protected Node parent
protected Node prev
protected Node next
protected Node last
protected int start
protected int end
protected byte[] textarray
protected short type
protected boolean closed
protected boolean implicit
protected boolean linebreak
protected Dict was
protected Dict tag
protected java.lang.String element
protected AttVal attributes
protected Node content
protected org.w3c.dom.Node adapter
public Node()
public Node(short type,
byte[] textarray,
int start,
int end)
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_DECLtextarray - array of bytes contained in the Nodestart - start positionend - end positionpublic Node(short type,
byte[] textarray,
int start,
int end,
java.lang.String element,
TagTable tt)
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_DECLtextarray - array of bytes contained in the Nodestart - start positionend - end positionelement - tag namett - tag table instanceprotected java.lang.Object clone()
clone in class java.lang.ObjectObject.clone()public AttVal getAttrByName(java.lang.String name)
name - attribute name.public void checkAttributes(Lexer lexer)
lexer - Lexerpublic void repairDuplicateAttributes(Lexer lexer)
lexer - Lexerpublic void addAttribute(java.lang.String name,
java.lang.String value)
name - attribute namevalue - attribute valuepublic void removeAttribute(AttVal attr)
attr - attribute to removepublic Node findDocType()
public void discardDocType()
public static Node discardElement(Node element)
element - discarded nodepublic void insertNodeAtStart(Node node)
node - to insertpublic void insertNodeAtEnd(Node node)
node - Node to insertpublic static void insertNodeAsParent(Node element, Node node)
element - child node. Will be inserted as a child of elementnode - parent nodepublic static void insertNodeBeforeElement(Node element, Node node)
element - child node. Will be insertedbefore elementnode - following nodepublic void insertNodeAfterElement(Node node)
node - new node to insertpublic static void trimEmptyElement(Lexer lexer, Node element)
lexer - Lexerelement - empty node to be removedpublic static void trimTrailingSpace(Lexer lexer, Node element, Node last)
lexer - Lexerelement - nodelast - last child of elementprotected static Node escapeTag(Lexer lexer, Node element)
lexer - Lexerelement - node to be escapedpublic boolean isBlank(Lexer lexer)
lexer - Lexertrue if the node content empty or blankpublic static void trimInitialSpace(Lexer lexer, Node element, Node text)
<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.lexer - Lexerelement - parent nodetext - text nodepublic static void trimSpaces(Lexer lexer, Node element)
lexer - Lexerelement - Nodepublic boolean isDescendantOf(Dict tag)
tag - descendant tagtrue if node is contained in tagpublic static void insertDocType(Lexer lexer, Node element, Node doctype)
lexer - Lexerelement - documentdoctype - doctype node to insert at the beginning of elementpublic Node findBody(TagTable tt)
tt - tag tablepublic boolean isElement()
true if type is START_TAG | START_END_TAGpublic static void moveBeforeTable(Node row, Node node, TagTable tt)
row - Row nodenode - Node which should be moved before the tablett - tag tablepublic static void fixEmptyRow(Lexer lexer, Node row)
lexer - Lexerrow - row nodepublic static void coerceNode(Lexer lexer, Node node, Dict tag)
lexer - Lexernode - Nodetag - tag dictionary referencepublic void removeNode()
public static boolean insertMisc(Node element, Node node)
element - parent nodenode - will be inserted at the end of elementtrue if the node has been insertedpublic boolean isNewNode()
true if this node represents a user-defined tag.public boolean hasOneChild()
true if the node has one childpublic Node findHTML(TagTable tt)
tt - tag tablepublic Node findHEAD(TagTable tt)
tt - tag tablepublic boolean checkNodeIntegrity()
public void addClass(java.lang.String classname)
classname - css class namepublic java.lang.String toString()
toString in class java.lang.ObjectObject.toString()protected org.w3c.dom.Node getAdapter()
protected Node cloneNode(boolean deep)
deep - if true deep clone the node (also clones all the contained nodes)protected void setType(short newType)
newType - a valid node type constantpublic boolean isJavaScript()
true if the script node contains javascriptpublic boolean expectsContent()
false if this node should be empty