Package com.ribs
Class RXElement
java.lang.Object
com.ribs.RXAttribute
com.ribs.RXElement
The
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 <info@reportmill.com>.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a new element.protected
Private Constructor which uses XMLLoader inner class to load.Creates a new element with given name.Creates a new element with given name and value. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(RXAttribute anAttribute) Adds the given attribute to this element's list of attributes.void
Adds a new attribute with the given name and boolean value.void
Adds a new attribute with the given name and float value.void
Adds a new attribute with the given name and int value.void
Adds a new attribute with the given name and Boolean value.void
Adds a new attribute with the given name using the object's toString() method.void
Adds a new attribute with the given name and string value.get
(int anIndex) Returns the specific child element at the given index.Returns the first child element with the given name.getAttribute
(int anIndex) Returns the specific child attribute at the given index.getAttribute
(String aName) Returns the specific child attribute with the given name.getAttributeBooleanValue
(String aName) Returns the Boolean value for the given attribute name.getAttributeBooleanValue
(String aName, Boolean defaultValue) Returns the Boolean value for the given attribute name (or the given default value, if name not found).boolean
getAttributeBoolValue
(String aName) Returns the boolean value for the given attribute name.boolean
getAttributeBoolValue
(String aName, boolean defaultValue) Returns the boolean value for the given attribute name (or the given default value, if name not found).int
Returns the number of child attributes for this element.float
getAttributeFloatValue
(String aName) Returns the float value for the given attribute name.float
getAttributeFloatValue
(String aName, float defaultValue) Returns the float value for the given attribute name (or the given default value, if name not found).int
getAttributeIntValue
(String aName) Returns the int value for the given attribute name.int
getAttributeIntValue
(String aName, int defaultValue) Returns the int value for the given attribute name (or the given default value, if name not found).getAttributeNumberValue
(String aName) Returns the Number value for the given attribute name.getAttributeNumberValue
(String aName, Number defaultValue) Returns the Number value for the given attribute name (or the given default value, if name not found).Returns the list of child attributes for this element.getAttributeValue
(String aName) Returns the attribute string value for the given attribute name.getAttributeValue
(String aName, 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
(Object aSource) Returns a new element hierarchy loaded from aSource (File, String path, InputStream or whatever).static String
getError()
Returns error message from Loading XML (Should really be a ThreadLocal).boolean
hasAttribute
(String aName) Checks for presence of an attribute.int
Returns the index of the first child element with the given name.int
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
Removes the given attribute or element by name.int
size()
Returns child element list size.int
Returns child element list size for child elements with given name.toString()
Returns a string representation of this element (XML).void
Writes the element as an XML file to the given desination (presumably a String path or File).void
Writes the element as an XML file to the given desination (presumably a String path or File).void
write
(StringBuffer aSB, int indent, String indentStr) Writes the element to the given string buffer using the given indent level and indent string.Methods inherited from class com.ribs.RXAttribute
getFloatValue, getIntValue, getName, getNumberValue, getValue, setName, setValue
-
Constructor Details
-
RXElement
public RXElement()Creates a new element. -
RXElement
Creates a new element with given name. -
RXElement
Creates a new element with given name and value. -
RXElement
Private Constructor which uses XMLLoader inner class to load.
-
-
Method Details
-
getElement
Returns a new element hierarchy loaded from aSource (File, String path, InputStream or whatever). -
size
public int size()Returns child element list size. -
size
Returns child element list size for child elements with given name. -
get
Returns the specific child element at the given index. -
get
Returns the first child element with the given name. -
indexOf
Returns the index of the first child element with the given name. -
indexOf
Returns the index of the first child element with the given name at or beyond the given index. -
getAttributes
Returns the list of child attributes for this element. -
getAttributeCount
public int getAttributeCount()Returns the number of child attributes for this element. -
getAttribute
Returns the specific child attribute at the given index. -
getAttribute
Returns the specific child attribute with the given name. -
hasAttribute
Checks for presence of an attribute. -
getAttributeValue
Returns the attribute string value for the given attribute name. -
getAttributeValue
Returns the string value for the given attribute name (or the given default value, if name not found). -
getAttributeBoolValue
Returns the boolean value for the given attribute name. -
getAttributeBoolValue
Returns the boolean value for the given attribute name (or the given default value, if name not found). -
getAttributeBooleanValue
Returns the Boolean value for the given attribute name. -
getAttributeBooleanValue
Returns the Boolean value for the given attribute name (or the given default value, if name not found). -
getAttributeIntValue
Returns the int value for the given attribute name. -
getAttributeIntValue
Returns the int value for the given attribute name (or the given default value, if name not found). -
getAttributeFloatValue
Returns the float value for the given attribute name. -
getAttributeFloatValue
Returns the float value for the given attribute name (or the given default value, if name not found). -
getAttributeNumberValue
Returns the Number value for the given attribute name. -
getAttributeNumberValue
Returns the Number value for the given attribute name (or the given default value, if name not found). -
add
Adds the given attribute to this element's list of attributes. -
remove
public void remove(int anIndex) Removes the child element at the given index. -
remove
Removes the given attribute from this elements attributes list. -
remove
Removes the given attribute or element by name. -
add
Adds a new attribute with the given name and string value. -
add
Adds a new attribute with the given name using the object's toString() method. -
add
Adds a new attribute with the given name and boolean value. -
add
Adds a new attribute with the given name and Boolean value. -
add
Adds a new attribute with the given name and int value. -
add
Adds a new attribute with the given name and float value. -
toString
Returns a string representation of this element (XML).- Overrides:
toString
in classRXAttribute
-
getBytes
public byte[] getBytes()Returns XML bytes for this element. -
write
Writes the element as an XML file to the given desination (presumably a String path or File). -
write
Writes the element as an XML file to the given desination (presumably a String path or File). If safely is true, it will write to a backup file then move it over. -
write
Writes the element to the given string buffer using the given indent level and indent string. -
getError
Returns error message from Loading XML (Should really be a ThreadLocal).
-