|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.twicom.qdparser.Element com.twicom.qdparser.TaggedElement
public class TaggedElement
Represents a tagged XML element and contains all the information that the original had. Attributes may be set, accessed and deleted. Child elements may be set accessed or deleted. This can be converted back to XML, along with its children, in a formatted or unformatted string.
Field Summary | |
---|---|
(package private) java.util.Map<java.lang.String,java.lang.String> |
attributes
|
(package private) java.util.List<Element> |
elements
|
(package private) java.lang.String |
name
|
(package private) java.lang.String |
nameSpace
|
(package private) java.lang.String |
tagName
|
Constructor Summary | |
---|---|
TaggedElement(java.lang.String tag)
Class constructor specifying only the name part of the tag |
|
TaggedElement(java.lang.String tag,
java.lang.Object[] children)
Class constructor specifying only the name part of the tag with an array of objects to be added as child elements |
|
TaggedElement(java.lang.String nameSpace,
java.lang.String tagName)
Class constructor specifying the name space and the tag name |
|
TaggedElement(java.lang.String nameSpace,
java.lang.String tag,
java.lang.Object[] children)
Class constructor specifying only the name part of the tag with an array of objects to be added as child elements |
Method Summary | |
---|---|
void |
add(Element element)
adds a child to the end of this element |
void |
add(int index,
Element element)
inserts a child into this element. |
void |
add(int index,
java.lang.String string)
inserts a child into this element If the index is out of range, the child is added at the end |
void |
add(java.lang.String string)
adds a child to the end of this element |
void |
clearElements()
removes the children from this element |
java.lang.Object |
clone()
|
void |
delAttribute(java.lang.String string)
removes the named attribute |
int |
elements()
gets the number of child elements this element has |
TaggedElement |
find(java.lang.String name)
Finds a named child tagged element. |
int |
findIndex(java.lang.String name)
Finds the index of a named child tagged element. |
java.lang.String |
getAttribute(java.lang.String name)
gets the specified attribute of this element |
java.lang.String |
getAttribute(java.lang.String name,
java.lang.String defaultValue)
gets the specified attribute of this element but returns given default value if the attribute does not exist |
java.util.Map<java.lang.String,java.lang.String> |
getAttributes()
gets the attributes in the form of an indexed table |
Element |
getChild(int i)
gets a child from the specified place in this element |
int |
getCol()
gets the XML source code cloumn number where this element was declared. |
java.lang.String |
getComment()
get the comment associated with this element |
java.util.List<Element> |
getElements()
gets a list of the children of this element. |
int |
getLine()
gets the XML source code line number where this element was declared. |
java.lang.String |
getName()
gets the original tag name |
java.lang.String |
getNameSpace()
gets the name space name |
java.lang.String |
getNamespacePrefix()
Gets the namespace prefix to be used for the namespace attribute when printing out the element |
java.lang.String |
getTag()
gets the name part of the tag |
boolean |
hasAttribute(java.lang.String name)
finds out whether an attribute exists |
boolean |
hasAttributes()
finds out whether this element has any attributes |
boolean |
hasElements()
finds out whether this element has any child elements |
java.util.Iterator<Element> |
iterator()
|
boolean |
remove(Element element)
Removes a child from this element |
Element |
remove(int index)
Removes a child from this element |
void |
replace(int index,
Element newElement)
replaces a child element with the one given |
void |
setAttribute(java.lang.String name,
java.lang.String value)
sets an attribute of this element |
void |
setComment(java.lang.String comment)
set this element's comment |
void |
setElements(java.util.List<Element> elements)
sets the list of children of this element. |
void |
setLocation(int line,
int col)
sets the XML source code location information for this element |
void |
setNamespacePrefix(java.lang.String namespacePrefix)
Sets the namespace prefix to be used when converting the XML to a String. |
java.lang.String |
toString()
|
protected java.lang.StringBuffer |
toString(java.lang.StringBuffer sb,
boolean formatted,
int level)
Internal method used recursively to format XML with appropriate indentation. |
Methods inherited from class com.twicom.qdparser.Element |
---|
newElement, quote, toString, unquote |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
java.lang.String nameSpace
java.lang.String tagName
java.lang.String name
java.util.Map<java.lang.String,java.lang.String> attributes
java.util.List<Element> elements
Constructor Detail |
---|
public TaggedElement(java.lang.String tag)
tag
- the name of the tagpublic TaggedElement(java.lang.String nameSpace, java.lang.String tagName)
nameSpace
- the name space nametagName
- the name of the tagpublic TaggedElement(java.lang.String tag, java.lang.Object[] children)
tag
- the name of the tagchildren
- an array of objects to be added as childrenpublic TaggedElement(java.lang.String nameSpace, java.lang.String tag, java.lang.Object[] children)
nameSpace
- the name space nametag
- the name of the tagchildren
- an array of objects to be added as childrenMethod Detail |
---|
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class Element
java.lang.CloneNotSupportedException
public java.lang.String getName()
public java.lang.String getNameSpace()
public java.lang.String getTag()
public void setAttribute(java.lang.String name, java.lang.String value)
name
- the name of the attribute to be setvalue
- the value of the attribute to be setpublic java.lang.String getAttribute(java.lang.String name)
name
- the name of the attribute to get
public java.lang.String getAttribute(java.lang.String name, java.lang.String defaultValue)
name
- the name of the attribute to getdefaultValue
- the value to be returned if the attribute doesn't exist
public void delAttribute(java.lang.String string)
string
- the name of the attribute to be removedpublic boolean hasAttribute(java.lang.String name)
name
- the name of the attribute to look for
public boolean hasAttributes()
public java.util.Map<java.lang.String,java.lang.String> getAttributes()
public int elements()
public boolean hasElements()
public void clearElements()
public void add(Element element)
element
- the child element to be addedpublic void add(int index, Element element)
index
- the location to insert the childelement
- the child element to be addedpublic void add(java.lang.String string)
string
- the child element to be addedpublic void add(int index, java.lang.String string)
index
- the location to insert the childstring
- the child element to be addedpublic Element getChild(int i)
i
- the index where the child is to be added
public void replace(int index, Element newElement)
index
- the child element number to replacenewElement
- the new element to replace the old onepublic Element remove(int index)
index
- the index of the child to be removed
public boolean remove(Element element)
element
- the child to be removed
public TaggedElement find(java.lang.String name)
name
- the name of the child of this TaggedElement to find
public int findIndex(java.lang.String name)
name
- the name of the child of this TaggedElement to find
public void setElements(java.util.List<Element> elements)
elements
- the new list of childrenpublic java.util.List<Element> getElements()
public java.util.Iterator<Element> iterator()
public java.lang.String getNamespacePrefix()
public void setNamespacePrefix(java.lang.String namespacePrefix)
namespacePrefix
- The namespacePrefix to set.public void setLocation(int line, int col)
line
- the line number of the start tagcol
- the column number of the start tagpublic int getLine()
public int getCol()
public java.lang.String getComment()
public void setComment(java.lang.String comment)
comment
- the comment to be storedpublic java.lang.String toString()
toString
in class java.lang.Object
protected java.lang.StringBuffer toString(java.lang.StringBuffer sb, boolean formatted, int level)
Element
toString
in class Element
sb
- TODOformatted
- whether to return formatted XML source. If true, the source is
pretty-printed with new lines and indentation. If false, the XML
string is returned as one long, unformatted line.level
- the indentation level used to write leading spaces
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |