public class RXElement extends RXAttribute
RXElement
class represents an XML element and simply manages a list of XML elements
(recursively) and a list of attributes. It also inherrits from RXAttribute to get name and value.
For the sake of efficiency, when you need to iterate over a list of elements for a given name, you should do this:
for(int i=anElement.indexOf(elementName); i>=0; i=anElement.indexOf(elementName, i+1)) anElement.get(i).doThis();
Copyright (c) 2004 ReportMill Software, Inc. All Rights Reserved. Contact ReportMill
Modifier | Constructor and Description |
---|---|
|
RXElement()
Creates a new element.
|
protected |
RXElement(java.lang.Object aSource)
Private Constructor which uses XMLLoader inner class to load.
|
|
RXElement(java.lang.String aName)
Creates a new element with given name.
|
|
RXElement(java.lang.String aName,
java.lang.String aValue)
Creates a new element with given name and value.
|
Modifier and Type | Method and Description |
---|---|
void |
add(RXAttribute anAttribute)
Adds the given attribute to this element's list of attributes.
|
void |
add(java.lang.String aName,
boolean aValue)
Adds a new attribute with the given name and boolean value.
|
void |
add(java.lang.String aName,
java.lang.Boolean aValue)
Adds a new attribute with the given name and Boolean value.
|
void |
add(java.lang.String aName,
float aValue)
Adds a new attribute with the given name and float value.
|
void |
add(java.lang.String aName,
int aValue)
Adds a new attribute with the given name and int value.
|
void |
add(java.lang.String aName,
java.lang.Object aValue)
Adds a new attribute with the given name using the object's toString() method.
|
void |
add(java.lang.String aName,
java.lang.String aValue)
Adds a new attribute with the given name and string value.
|
RXElement |
get(int anIndex)
Returns the specific child element at the given index.
|
RXElement |
get(java.lang.String aName)
Returns the first child element with the given name.
|
RXAttribute |
getAttribute(int anIndex)
Returns the specific child attribute at the given index.
|
RXAttribute |
getAttribute(java.lang.String aName)
Returns the specific child attribute with the given name.
|
java.lang.Boolean |
getAttributeBooleanValue(java.lang.String aName)
Returns the Boolean value for the given attribute name.
|
java.lang.Boolean |
getAttributeBooleanValue(java.lang.String aName,
java.lang.Boolean defaultValue)
Returns the Boolean value for the given attribute name (or the given default value, if name not found).
|
boolean |
getAttributeBoolValue(java.lang.String aName)
Returns the boolean value for the given attribute name.
|
boolean |
getAttributeBoolValue(java.lang.String aName,
boolean defaultValue)
Returns the boolean value for the given attribute name (or the given default value, if name not found).
|
int |
getAttributeCount()
Returns the number of child attributes for this element.
|
float |
getAttributeFloatValue(java.lang.String aName)
Returns the float value for the given attribute name.
|
float |
getAttributeFloatValue(java.lang.String aName,
float defaultValue)
Returns the float value for the given attribute name (or the given default value, if name not found).
|
int |
getAttributeIntValue(java.lang.String aName)
Returns the int value for the given attribute name.
|
int |
getAttributeIntValue(java.lang.String aName,
int defaultValue)
Returns the int value for the given attribute name (or the given default value, if name not found).
|
java.lang.Number |
getAttributeNumberValue(java.lang.String aName)
Returns the Number value for the given attribute name.
|
java.lang.Number |
getAttributeNumberValue(java.lang.String aName,
java.lang.Number defaultValue)
Returns the Number value for the given attribute name (or the given default value, if name not found).
|
java.util.List |
getAttributes()
Returns the list of child attributes for this element.
|
java.lang.String |
getAttributeValue(java.lang.String aName)
Returns the attribute string value for the given attribute name.
|
java.lang.String |
getAttributeValue(java.lang.String aName,
java.lang.String defaultValue)
Returns the string value for the given attribute name (or the given default value, if name not found).
|
byte[] |
getBytes()
Returns XML bytes for this element.
|
static RXElement |
getElement(java.lang.Object aSource)
Returns a new element hierarchy loaded from aSource (File, String path, InputStream or whatever).
|
static java.lang.String |
getError()
Returns error message from Loading XML (Should really be a ThreadLocal).
|
boolean |
hasAttribute(java.lang.String aName)
Checks for presence of an attribute.
|
int |
indexOf(java.lang.String aName)
Returns the index of the first child element with the given name.
|
int |
indexOf(java.lang.String aName,
int startIndex)
Returns the index of the first child element with the given name at or beyond the given index.
|
void |
remove(int anIndex)
Removes the child element at the given index.
|
void |
remove(RXAttribute attribute)
Removes the given attribute from this elements attributes list.
|
void |
remove(java.lang.String aName)
Removes the given attribute or element by name.
|
int |
size()
Returns child element list size.
|
int |
size(java.lang.String aName)
Returns child element list size for child elements with given name.
|
java.lang.String |
toString()
Returns a string representation of this element (XML).
|
void |
write(java.lang.Object aDest)
Writes the element as an XML file to the given desination (presumably a String path or File).
|
void |
write(java.lang.Object aDest,
boolean safely)
Writes the element as an XML file to the given desination (presumably a String path or File).
|
void |
write(java.lang.StringBuffer aSB,
int indent,
java.lang.String indentStr)
Writes the element to the given string buffer using the given indent level and indent string.
|
getFloatValue, getIntValue, getName, getNumberValue, getValue, setName, setValue
public RXElement()
public RXElement(java.lang.String aName)
public RXElement(java.lang.String aName, java.lang.String aValue)
protected RXElement(java.lang.Object aSource)
public static RXElement getElement(java.lang.Object aSource)
public int size()
public int size(java.lang.String aName)
public RXElement get(int anIndex)
public RXElement get(java.lang.String aName)
public int indexOf(java.lang.String aName)
public int indexOf(java.lang.String aName, int startIndex)
public java.util.List getAttributes()
public int getAttributeCount()
public RXAttribute getAttribute(int anIndex)
public RXAttribute getAttribute(java.lang.String aName)
public boolean hasAttribute(java.lang.String aName)
public java.lang.String getAttributeValue(java.lang.String aName)
public java.lang.String getAttributeValue(java.lang.String aName, java.lang.String defaultValue)
public boolean getAttributeBoolValue(java.lang.String aName)
public boolean getAttributeBoolValue(java.lang.String aName, boolean defaultValue)
public java.lang.Boolean getAttributeBooleanValue(java.lang.String aName)
public java.lang.Boolean getAttributeBooleanValue(java.lang.String aName, java.lang.Boolean defaultValue)
public int getAttributeIntValue(java.lang.String aName)
public int getAttributeIntValue(java.lang.String aName, int defaultValue)
public float getAttributeFloatValue(java.lang.String aName)
public float getAttributeFloatValue(java.lang.String aName, float defaultValue)
public java.lang.Number getAttributeNumberValue(java.lang.String aName)
public java.lang.Number getAttributeNumberValue(java.lang.String aName, java.lang.Number defaultValue)
public void add(RXAttribute anAttribute)
public void remove(int anIndex)
public void remove(RXAttribute attribute)
public void remove(java.lang.String aName)
public void add(java.lang.String aName, java.lang.String aValue)
public void add(java.lang.String aName, java.lang.Object aValue)
public void add(java.lang.String aName, boolean aValue)
public void add(java.lang.String aName, java.lang.Boolean aValue)
public void add(java.lang.String aName, int aValue)
public void add(java.lang.String aName, float aValue)
public java.lang.String toString()
toString
in class RXAttribute
public byte[] getBytes()
public void write(java.lang.Object aDest)
public void write(java.lang.Object aDest, boolean safely)
public void write(java.lang.StringBuffer aSB, int indent, java.lang.String indentStr)
public static java.lang.String getError()