|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.Vector<XML>
com.bmc.mainview.nvbapi.XML
public class XML
An object containing XML stored as a DOM-like structure.
An XML element may be a top-level element in which case it may have processing instructions, or it may be added to another XML element as a sub-element. Each element may have a set of attributes and either a value or a set of sub-elements, but not both.
Field Summary | |
---|---|
static java.lang.String |
HEADER
The header placed at the beginning of each formatted XML string. |
static int |
NOINDENT
Argument to toString(int) to suppress indentation |
static int |
NOPI
Argument to toString(int) to suppress indentation and processing instructions |
Constructor Summary | |
---|---|
XML(java.io.Reader source)
Create a DOM-like structure from an XML input stream. |
|
XML(java.lang.String tag)
Create an element with the given tag |
Method Summary | |
---|---|
boolean |
add(XML subElement)
Appends the specified sub-element to this XML. |
void |
addElement(java.lang.String s,
java.lang.String parm)
A utility method that adds a sub-element with the given value to the element |
void |
addElement(XML element)
Add a sub-element to the current XML element. |
void |
addProcessingInstruction(XML pi)
Add a processing instruction to the current XML element. |
XML |
clone()
Creates and returns a copy of this object. |
java.lang.String |
dump()
Writes a printable version of the entire XML stream which contains this element. |
boolean |
equals(java.lang.Object other)
|
boolean |
equals(XML other)
Compare attributes, value, and elements of two XML objects for equality. |
XML |
findElement(java.lang.String tag)
Searches for the first sub-element with the given tag and returns it. |
XML |
findElement(java.lang.String tag,
int which)
Searches for the nth sub-element with the given tag and returns it. |
java.util.Enumeration<XML> |
findElements(java.lang.String tag)
Allows sub-elements of a given type to be accessed sequentially |
java.lang.String |
getAttribute(java.lang.String name)
Retrieve an attribute of this elemrnt |
int |
getAttributeCount()
Determine how many attributes there are |
java.util.Enumeration<java.lang.Object> |
getAttributeList()
Get an Enumeration of the attributes |
XML |
getElement(int n)
Get the nth sub-element of the element |
int |
getElementCount(java.lang.String tag)
Returns number of sub-elements with the given tag |
int |
getIntAttribute(java.lang.String name)
Retrieve an attribute of this elemrnt which is an int |
XML |
getParent()
Find the XML element of which this is a sub-element. |
java.util.Vector<XML> |
getProcessingInstructions()
Retrieve the current set of processing instructions. |
int |
getSize()
The number of sub-elements in this element. |
java.lang.String |
getTag()
Retrieve the type of this element |
java.lang.String |
getValue()
Gets the value contained in this element. |
XML |
remove(int index)
Remove a specific element |
boolean |
removeElement(java.lang.Object element)
Removes the first occurrence of the specified sub-element in this XML If the XML does not contain the sub-element, it is unchanged. |
void |
setAttribute(java.lang.String name,
int value)
Add an attribute to this element |
void |
setAttribute(java.lang.String name,
java.lang.String value)
Add an attribute to this element |
void |
setDocType(java.lang.String docType)
|
void |
setElementAt(XML obj,
int index)
|
void |
setValue(java.lang.String data)
Store a value between the beginning and ending tags of this element An element may have either a single value or an ordered list of sub-elements. |
java.lang.String |
toString()
Converts the XML to string |
java.lang.String |
toString(int indent)
Converts the XML to String |
java.lang.StringBuffer |
toStringBuffer(int indent)
Converts the XML to a StringBuffer |
Methods inherited from class java.util.Vector |
---|
add, addAll, addAll, capacity, clear, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, removeAll, removeAllElements, removeElementAt, retainAll, set, setSize, size, subList, toArray, toArray, trimToSize |
Methods inherited from class java.util.AbstractList |
---|
iterator, listIterator, listIterator |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
iterator, listIterator, listIterator |
Field Detail |
---|
public static final java.lang.String HEADER
public static final int NOINDENT
toString(int)
,
Constant Field Valuespublic static final int NOPI
toString(int)
,
Constant Field ValuesConstructor Detail |
---|
public XML(java.lang.String tag)
tag
- public XML(java.io.Reader source) throws java.io.IOException
source
- A Reader such as a StringReader or a FileReader.
java.io.IOException
- If there are errors in the input stream.Method Detail |
---|
public void setDocType(java.lang.String docType)
public XML clone()
clone
in class java.util.Vector<XML>
Cloneable
public boolean equals(XML other)
other
-
public boolean equals(java.lang.Object other)
equals
in interface java.util.Collection<XML>
equals
in interface java.util.List<XML>
equals
in class java.util.Vector<XML>
public java.lang.String getTag()
public int getAttributeCount()
public java.util.Enumeration<java.lang.Object> getAttributeList()
public java.lang.String getAttribute(java.lang.String name)
name
-
public int getIntAttribute(java.lang.String name)
name
-
public void setAttribute(java.lang.String name, java.lang.String value)
name
- The name of the attributevalue
- The value to be set. If null, the attribute is removedpublic void setAttribute(java.lang.String name, int value)
name
- The name of the attributevalue
- The value to be set.public void addElement(XML element)
addElement
in class java.util.Vector<XML>
element
- An XML elementpublic boolean add(XML subElement)
add
in interface java.util.Collection<XML>
add
in interface java.util.List<XML>
add
in class java.util.Vector<XML>
subElement
- sub-element to be appended to this XML.
addElement(com.bmc.mainview.nvbapi.XML)
public boolean removeElement(java.lang.Object element)
removeElement
in class java.util.Vector<XML>
element
- sub-element to be removed from this XML, if present.
public XML remove(int index)
remove
in interface java.util.List<XML>
remove
in class java.util.Vector<XML>
index
- the element number to removeVector.remove(int)
public void addElement(java.lang.String s, java.lang.String parm)
s
- The tag of the new sub-elementparm
- The value that the sub-element is to contain.public XML getElement(int n)
n
- The ordinal number of the desired sub-element
public void setElementAt(XML obj, int index)
setElementAt
in class java.util.Vector<XML>
public XML findElement(java.lang.String tag)
tag
- The type of the sub-element
public XML findElement(java.lang.String tag, int which)
tag
- The type of the sub-elementwhich
- Zer0-based index of the desired element
public java.util.Enumeration<XML> findElements(java.lang.String tag)
tag
-
public XML getParent()
public int getSize()
public java.util.Vector<XML> getProcessingInstructions()
addProcessingInstruction(XML)
public void addProcessingInstruction(XML pi)
pi
- An XML element. The tag will be the tag of the processing instruction
and the attributes will be the parameters. Any value or sub-elements will be
ignored.toString()
,
toString(int)
,
toStringBuffer(int)
public java.lang.String getValue()
java.lang.IllegalArgumentException
- if the element has sub-elements.public void setValue(java.lang.String data)
data
-
java.lang.IllegalArgumentException
- if the element has sub-elements.public java.lang.String dump()
public java.lang.String toString()
toString
in class java.util.Vector<XML>
public java.lang.String toString(int indent)
indent
- The initial indentation.
NOINDENT
,
NOPI
public java.lang.StringBuffer toStringBuffer(int indent)
indent
- The initial indentation.
NOINDENT
,
NOPI
public int getElementCount(java.lang.String tag)
tag
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |