public class DomElement
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private boolean |
blForceTight |
private java.util.List<DomElement> |
listChildren
Child elements.
|
private java.util.Map<java.lang.String,java.lang.String> |
mapAttributes
Attributes.
|
private static long |
serialVersionUID
long serialVersionUID
|
private java.lang.String |
strTagName
Tag name.
|
Constructor and Description |
---|
DomElement(java.lang.String strTagName)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addChild(DomElement domChild)
Appends one specified child node to the end of child
node list in this node.
|
void |
addChild(int intIdx,
DomElement domChild)
Inserts one specified child node at the specified
position in child node list in this node.
|
boolean |
addChildren(java.util.Collection<DomElement> colChildren)
Appends all of the child nodes in the given collection
to the end of child node list in this node, in the order that they are
returned by the given collection's iterator.
|
boolean |
addChildren(DomElement[] tn1dChildren)
Appends all of the child nodes in the given array to the
end of child node list in this node, in the order that they are returned
by the given collection's iterator.
|
boolean |
addChildren(int intIdx,
java.util.Collection<DomElement> colChildren)
Inserts all of the child nodes in the given collection
into child node list in this node at the specified position.
|
boolean |
addChildren(int intIdx,
DomElement[] tn1dChildren)
Inserts all of the child nodes in the given array into
child node list in this node at the specified position.
|
protected java.lang.String |
escapeForDocument(java.lang.String strIn,
char[] char1dScope)
Escapes "&"→"&", "<"→"<",
">"→">" and """→""" for document.
See http://book.51cto .com/art/200907/138928.htm. |
java.lang.String |
getAttribute(java.lang.String strKey)
Returns the attribute value to which the specified key is mapped, or
null if attribute map in this node contains no mapping
for the key.
|
java.util.Map<java.lang.String,java.lang.String> |
getAttributes()
Copies all the attributes into a new
map and return.
|
java.util.Map<java.lang.String,java.lang.String> |
getAttributes(java.util.Collection<java.lang.String> colKeys)
Returns the copied map of attributes to
which the specified keys are mapped, or
null if attribute map in this node contains no mapping
for the keys.
|
java.util.Map<java.lang.String,java.lang.String> |
getAttributes(java.lang.String[] str1dKeys)
Returns the copied map of attributes to
which the specified keys are mapped, or
null if attribute map in this node contains no mapping
for the keys.
|
DomElement |
getChild(int intIdx)
Returns one child node at the specified position in
child node list in this node.
|
java.util.List<DomElement> |
getChildren()
Copies all the child nodes into a new
list and return.
|
java.util.List<DomElement> |
getChildren(int[] int1dIndexes)
Copies the child nodes that at
specified positions into a new list and return.
|
java.lang.String |
getTagName()
Getting the tag name.
|
boolean |
isForceTight()
Judges whether this element to be formatted in "force tight" mode.
|
java.lang.String |
removeAttribute(java.lang.String strKey)
Removes one attribute for a key from this node if it is
present.
|
java.util.Map<java.lang.String,java.lang.String> |
removeAttributes()
Removes all attributes from this node
if it is present.
|
java.util.Map<java.lang.String,java.lang.String> |
removeAttributes(java.util.Collection<java.lang.String> colKeys)
Removes attributes for keys from this
node if it is present.
|
java.util.Map<java.lang.String,java.lang.String> |
removeAttributes(java.lang.String[] str1dKeys)
Removes attributes for keys from this
node if it is present.
|
boolean |
removeChild(DomElement domChild)
Removes the first occurrence of one specified child node
from child node list in this node, if it is present.
|
DomElement |
removeChild(int intIdx)
Removes one child node at the specified position in
child node list from this node.
|
java.util.List<DomElement> |
removeChildren()
Removes all child nodes in child node
list from this node.
|
java.util.List<DomElement> |
removeChildren(java.util.Collection<DomElement> colChildren)
Removes from child node list all of the nodes that are
contained in the specified collection (somehow similar
to
List.removeAll(java.util.Collection) ). |
java.util.List<DomElement> |
removeChildren(DomElement[] tn1dChildren)
Removes from child node list all of the node
s that are contained in the specified array.
|
java.util.List<DomElement> |
removeChildren(int[] int1dIndexes)
Removes child nodes at the specified positions in child
node list from this node.
|
java.lang.String |
resetAttribute(java.lang.String strKey,
java.lang.String strValue)
Cleans attribute map, and then associates
one specified value with the specified key in attribute
map.
|
void |
resetAttributes(java.util.Map<java.lang.String,java.lang.String> mapAttributes)
Cleans attribute map, and then copies
all of the attributes from the specified map
into attribute map in this node.
|
boolean |
resetChild(DomElement domChild)
Cleans child node list, and then appends
one specified child node to the end of child node list
in this node.
|
void |
resetChild(int intIdx,
DomElement domChild)
Cleans child node list, and then inserts
one specified child node at the specified position in
child node list in this node.
|
boolean |
resetChildren(java.util.Collection<DomElement> colChildren)
Cleans child node list, and then appends all of the
child nodes in the given collection to the end of child
node list in this node, in the order that they are returned by the given
collection's iterator.
|
boolean |
resetChildren(DomElement[] tn1dChildren)
Cleans child node list, and then appends all of the
child nodes in the given array to the end of child node
list in this node, in the order that they are returned by the given
collection's iterator.
|
boolean |
resetChildren(int intIdx,
java.util.Collection<DomElement> colChildren)
Cleans child node list, and then inserts all of the
child nodes in the given collection into child node list
in this node at the specified position.
|
boolean |
resetChildren(int intIdx,
DomElement[] tn1dChildren)
Cleans child node list, and then inserts all of the
child nodes in the given array into child node list in
this node at the specified position.
|
java.lang.String |
setAttribute(java.lang.String strKey)
Associates one null value with the specified key in
attribute map.
For probable HTML /XML usage. |
java.lang.String |
setAttribute(java.lang.String strKey,
java.lang.String strValue)
Associates one specified value with the specified key in
attribute map.
|
void |
setAttributes(java.util.Map<java.lang.String,java.lang.String> mapAttributes)
Copies all of the attributes from the
specified map into attribute map in this node.
|
void |
setForceTight(boolean blForceTight)
Sets a "force tight" flag to this element.
|
void |
sortChildren(java.util.Comparator<DomElement> cmp)
Sort the list of child nodes in this node.
|
java.lang.String |
toString() |
java.lang.String |
toString(boolean blFirstLinePrefixFlag)
Returns a string representation of the object.
|
java.lang.String |
toString(boolean blFirstLinePrefixFlag,
java.lang.String strWhiteSpaceTextUnit)
Returns a string representation of the object.
|
java.lang.String |
toString(int intPrefixWhiteSpaceCount)
Returns a string representation of the object.
|
java.lang.String |
toString(int intPrefixWhiteSpaceCount,
boolean blFirstLinePrefixFlag)
Returns a string representation of the object.
|
java.lang.String |
toString(int intPrefixWhiteSpaceCount,
boolean blFirstLinePrefixFlag,
java.lang.String strWhiteSpaceTextUnit)
Returns a string representation of the object.
|
java.lang.String |
toString(int intPrefixWhiteSpaceCount,
boolean blFirstLinePrefixFlag,
java.lang.String strWhiteSpaceTextUnit,
char chCasesFlag,
java.lang.String[] str1dPairTagNames,
java.lang.String[] str1d_TagNames)
Returns a string representation of the object.
|
java.lang.String |
toString(int intPrefixWhiteSpaceCount,
java.lang.String strWhiteSpaceTextUnit)
Returns a string representation of the object.
|
java.lang.String |
toString(java.lang.String strWhiteSpaceTextUnit)
Returns a string representation of the object.
|
java.lang.String |
toTightString()
Returns a tight string representation of the object.
|
java.lang.String |
toTightString(char chCasesFlag,
java.lang.String[] str1dPairTagNames,
java.lang.String[] str1d_TagNames)
Returns a tight string representation of the object.
|
private static final long serialVersionUID
private boolean blForceTight
private java.util.List<DomElement> listChildren
private java.util.Map<java.lang.String,java.lang.String> mapAttributes
private java.lang.String strTagName
public DomElement(java.lang.String strTagName)
strTagName
- - Tag name.public boolean isForceTight()
public void setForceTight(boolean blForceTight)
blForceTight
- - A boolean flag that indicates whether this element to be
formatted in "force tight" mode:public boolean addChild(DomElement domChild)
domChild
- - The child node to be appended to the child node list in this
node.List.add(Object)
public void addChild(int intIdx, DomElement domChild)
intIdx
- - The index at which the specified child node is to be
inserted.domChild
- - The child node to be inserted to the child node list in this
node.List.add(int, Object)
public boolean addChildren(DomElement[] tn1dChildren)
tn1dChildren
- - Container containing the child nodes to append into this
node.addChildren(int, DomElement[])
public boolean addChildren(int intIdx, DomElement[] tn1dChildren)
intIdx
- - The index at which to insert the first child node from the
given collection.tn1dChildren
- - Container containing the child nodes to append into this
node.public boolean addChildren(java.util.Collection<DomElement> colChildren)
colChildren
- - Container containing the child nodes to append into this
node.List.addAll(Collection)
public boolean addChildren(int intIdx, java.util.Collection<DomElement> colChildren)
intIdx
- - The index at which to insert the first child node from the
given collection.colChildren
- - Container containing the child nodes to append into this
node.List.addAll(int, Collection)
public DomElement getChild(int intIdx)
intIdx
- - The index of the child node to return.List.get(int)
public java.util.List<DomElement> getChildren()
public java.util.List<DomElement> getChildren(int[] int1dIndexes)
int1dIndexes
- - The indexes of the child nodes to return.public DomElement removeChild(int intIdx)
intIdx
- - The index of the child node to be removed.List.remove(int)
public boolean removeChild(DomElement domChild)
domChild
- - The child node to be removed from child node list, if
present.List.remove(Object)
public java.util.List<DomElement> removeChildren()
removeChildren(Collection)
public java.util.List<DomElement> removeChildren(int[] int1dIndexes)
int1dIndexes
- - The indexes of the child nodes to be removed.public java.util.List<DomElement> removeChildren(DomElement[] tn1dChildren)
tn1dChildren
- - Container containing nodes to be removed from child node
list.public java.util.List<DomElement> removeChildren(java.util.Collection<DomElement> colChildren)
List.removeAll(java.util.Collection)
).colChildren
- - The collection containing nodes to be removed from child
node list.removeChildren(DomElement[])
public boolean resetChild(DomElement domChild)
domChild
- - The child node to be appended to the child node list in this
node.removeChildren()
,
addChild(DomElement)
public void resetChild(int intIdx, DomElement domChild)
intIdx
- - The index at which the specified child node is to be
inserted.domChild
- - The child node to be inserted to the child node list in this
node.removeChildren()
,
addChild(int, DomElement)
public boolean resetChildren(DomElement[] tn1dChildren)
tn1dChildren
- - Container containing the child nodes to append into this
node.removeChildren()
,
addChildren(DomElement[])
public boolean resetChildren(int intIdx, DomElement[] tn1dChildren)
intIdx
- - The index at which to insert the first child node from the
given collection.tn1dChildren
- - Container containing nodes to be removed from child node
list.removeChildren()
,
addChildren(int, DomElement[])
public boolean resetChildren(java.util.Collection<DomElement> colChildren)
colChildren
- - Container containing nodes to be removed from child node
list.removeChildren()
,
addChildren(Collection)
public boolean resetChildren(int intIdx, java.util.Collection<DomElement> colChildren)
intIdx
- - The index at which to insert the first child node from the
given collection.colChildren
- - Container containing nodes to be removed from child node
list.removeChildren()
,
addChildren(int, Collection)
public void sortChildren(java.util.Comparator<DomElement> cmp)
cmp
- - Comparator to sort child nodes.public java.lang.String setAttribute(java.lang.String strKey)
strKey
- - The key with which the specified value is to be associated.
Map.put(Object, Object)
public java.lang.String setAttribute(java.lang.String strKey, java.lang.String strValue)
strKey
- - The key with which the specified value is to be associated.
strValue
- - The value to be associated with the specified key.Map.put(Object, Object)
public void setAttributes(java.util.Map<java.lang.String,java.lang.String> mapAttributes)
mapAttributes
- - The foreign attributes to be copied into this node.Map.putAll(Map)
public java.lang.String getAttribute(java.lang.String strKey)
strKey
- - The key whose associated value is to be returned.Map.get(Object)
public java.util.Map<java.lang.String,java.lang.String> getAttributes()
public java.util.Map<java.lang.String,java.lang.String> getAttributes(java.lang.String[] str1dKeys)
str1dKeys
- - Container containing the keys whose
associated values are to be returned.public java.util.Map<java.lang.String,java.lang.String> getAttributes(java.util.Collection<java.lang.String> colKeys)
colKeys
- - Container containing the keys whose
associated values are to be returned.getAttributes(String[])
public java.lang.String removeAttribute(java.lang.String strKey)
strKey
- - The key whose attribute is to be removed from this node.
Map.remove(Object)
public java.util.Map<java.lang.String,java.lang.String> removeAttributes()
removeAttributes(String[])
public java.util.Map<java.lang.String,java.lang.String> removeAttributes(java.lang.String[] str1dKeys)
str1dKeys
- - Container containing the keys whose
attributes are to be removed from this node.public java.util.Map<java.lang.String,java.lang.String> removeAttributes(java.util.Collection<java.lang.String> colKeys)
colKeys
- - Container containing the keys whose
attributes are to be removed from this node.removeAttributes(String[])
public java.lang.String resetAttribute(java.lang.String strKey, java.lang.String strValue)
strKey
- - The key with which the specified value is to be associated.
strValue
- - The value to be associated with the specified key.removeAttributes()
,
Map.put(Object, Object)
public void resetAttributes(java.util.Map<java.lang.String,java.lang.String> mapAttributes)
mapAttributes
- - The foreign attributes to be copied into this node.removeAttributes()
,
Map.putAll(Map)
public java.lang.String getTagName()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public java.lang.String toString(int intPrefixWhiteSpaceCount)
intPrefixWhiteSpaceCount
- - Count of prefix white space.public java.lang.String toString(boolean blFirstLinePrefixFlag)
blFirstLinePrefixFlag
- - A boolean flag that indicates use or NOT use a prefix to the
first line of the text:public java.lang.String toString(java.lang.String strWhiteSpaceTextUnit)
strWhiteSpaceTextUnit
- - Text unit of white space.public java.lang.String toString(int intPrefixWhiteSpaceCount, boolean blFirstLinePrefixFlag)
intPrefixWhiteSpaceCount
- - Count of prefix white space.blFirstLinePrefixFlag
- - A boolean flag that indicates use or NOT use a prefix to the
first line of the text:public java.lang.String toString(int intPrefixWhiteSpaceCount, java.lang.String strWhiteSpaceTextUnit)
intPrefixWhiteSpaceCount
- - Count of prefix white space.strWhiteSpaceTextUnit
- - Text unit of white space.public java.lang.String toString(boolean blFirstLinePrefixFlag, java.lang.String strWhiteSpaceTextUnit)
blFirstLinePrefixFlag
- - A boolean flag that indicates use or NOT use a prefix to the
first line of the text:strWhiteSpaceTextUnit
- - Text unit of white space.public java.lang.String toString(int intPrefixWhiteSpaceCount, boolean blFirstLinePrefixFlag, java.lang.String strWhiteSpaceTextUnit)
intPrefixWhiteSpaceCount
- - Count of prefix white space.blFirstLinePrefixFlag
- - A boolean flag that indicates use or NOT use a prefix to the
first line of the text:strWhiteSpaceTextUnit
- - Text unit of white space.public java.lang.String toString(int intPrefixWhiteSpaceCount, boolean blFirstLinePrefixFlag, java.lang.String strWhiteSpaceTextUnit, char chCasesFlag, java.lang.String[] str1dPairTagNames, java.lang.String[] str1d_TagNames)
intPrefixWhiteSpaceCount
- - Count of prefix white space.blFirstLinePrefixFlag
- - A boolean flag that indicates use or NOT use a prefix to the
first line of the text:strWhiteSpaceTextUnit
- - Text unit of white space; null would be
processed as "\t".chCasesFlag
- - Character cases of the tag names and attribute names:str1dPairTagNames
- - The names of the tags that must appear in pairs, even if
they contain no child elements; null or
empty are acceptable.str1d_TagNames
- - The names of the tags that must have a blank character
before their "/>", if they contain no child elements;
null or empty are
acceptable.public java.lang.String toTightString()
public java.lang.String toTightString(char chCasesFlag, java.lang.String[] str1dPairTagNames, java.lang.String[] str1d_TagNames)
chCasesFlag
- - Character cases of the tag names and attribute names:str1dPairTagNames
- - The names of the tags that must appear in pairs, even if
they contain no child elements; null or
empty are acceptable.str1d_TagNames
- - The names of the tags that must have a blank character
before their "/>", if they contain no child elements;
null or empty are
acceptable.protected final java.lang.String escapeForDocument(java.lang.String strIn, char[] char1dScope)
strIn
- - The incoming text to be escapes.char1dScope
- - The scope of characters to be escapes.