Package com.ribs
Class RXElement
- java.lang.Object
- 
- com.ribs.RXAttribute
- 
- com.ribs.RXElement
 
 
- 
 public class RXElement extends RXAttribute TheRXElementclass 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 . 
- 
- 
Constructor SummaryConstructors Modifier Constructor Description RXElement()Creates a new element.protectedRXElement(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.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(RXAttribute anAttribute)Adds the given attribute to this element's list of attributes.voidadd(java.lang.String aName, boolean aValue)Adds a new attribute with the given name and boolean value.voidadd(java.lang.String aName, float aValue)Adds a new attribute with the given name and float value.voidadd(java.lang.String aName, int aValue)Adds a new attribute with the given name and int value.voidadd(java.lang.String aName, java.lang.Boolean aValue)Adds a new attribute with the given name and Boolean value.voidadd(java.lang.String aName, java.lang.Object aValue)Adds a new attribute with the given name using the object's toString() method.voidadd(java.lang.String aName, java.lang.String aValue)Adds a new attribute with the given name and string value.RXElementget(int anIndex)Returns the specific child element at the given index.RXElementget(java.lang.String aName)Returns the first child element with the given name.RXAttributegetAttribute(int anIndex)Returns the specific child attribute at the given index.RXAttributegetAttribute(java.lang.String aName)Returns the specific child attribute with the given name.java.lang.BooleangetAttributeBooleanValue(java.lang.String aName)Returns the Boolean value for the given attribute name.java.lang.BooleangetAttributeBooleanValue(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).booleangetAttributeBoolValue(java.lang.String aName)Returns the boolean value for the given attribute name.booleangetAttributeBoolValue(java.lang.String aName, boolean defaultValue)Returns the boolean value for the given attribute name (or the given default value, if name not found).intgetAttributeCount()Returns the number of child attributes for this element.floatgetAttributeFloatValue(java.lang.String aName)Returns the float value for the given attribute name.floatgetAttributeFloatValue(java.lang.String aName, float defaultValue)Returns the float value for the given attribute name (or the given default value, if name not found).intgetAttributeIntValue(java.lang.String aName)Returns the int value for the given attribute name.intgetAttributeIntValue(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.NumbergetAttributeNumberValue(java.lang.String aName)Returns the Number value for the given attribute name.java.lang.NumbergetAttributeNumberValue(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.ListgetAttributes()Returns the list of child attributes for this element.java.lang.StringgetAttributeValue(java.lang.String aName)Returns the attribute string value for the given attribute name.java.lang.StringgetAttributeValue(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 RXElementgetElement(java.lang.Object aSource)Returns a new element hierarchy loaded from aSource (File, String path, InputStream or whatever).static java.lang.StringgetError()Returns error message from Loading XML (Should really be a ThreadLocal).booleanhasAttribute(java.lang.String aName)Checks for presence of an attribute.intindexOf(java.lang.String aName)Returns the index of the first child element with the given name.intindexOf(java.lang.String aName, int startIndex)Returns the index of the first child element with the given name at or beyond the given index.voidremove(int anIndex)Removes the child element at the given index.voidremove(RXAttribute attribute)Removes the given attribute from this elements attributes list.voidremove(java.lang.String aName)Removes the given attribute or element by name.intsize()Returns child element list size.intsize(java.lang.String aName)Returns child element list size for child elements with given name.java.lang.StringtoString()Returns a string representation of this element (XML).voidwrite(java.lang.Object aDest)Writes the element as an XML file to the given desination (presumably a String path or File).voidwrite(java.lang.Object aDest, boolean safely)Writes the element as an XML file to the given desination (presumably a String path or File).voidwrite(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.- 
Methods inherited from class com.ribs.RXAttributegetFloatValue, getIntValue, getName, getNumberValue, getValue, setName, setValue
 
- 
 
- 
- 
- 
Constructor Detail- 
RXElementpublic RXElement() Creates a new element.
 - 
RXElementpublic RXElement(java.lang.String aName) Creates a new element with given name.
 - 
RXElementpublic RXElement(java.lang.String aName, java.lang.String aValue)Creates a new element with given name and value.
 - 
RXElementprotected RXElement(java.lang.Object aSource) Private Constructor which uses XMLLoader inner class to load.
 
- 
 - 
Method Detail- 
getElementpublic static RXElement getElement(java.lang.Object aSource) Returns a new element hierarchy loaded from aSource (File, String path, InputStream or whatever).
 - 
sizepublic int size() Returns child element list size.
 - 
sizepublic int size(java.lang.String aName) Returns child element list size for child elements with given name.
 - 
getpublic RXElement get(int anIndex) Returns the specific child element at the given index.
 - 
getpublic RXElement get(java.lang.String aName) Returns the first child element with the given name.
 - 
indexOfpublic int indexOf(java.lang.String aName) Returns the index of the first child element with the given name.
 - 
indexOfpublic 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.
 - 
getAttributespublic java.util.List getAttributes() Returns the list of child attributes for this element.
 - 
getAttributeCountpublic int getAttributeCount() Returns the number of child attributes for this element.
 - 
getAttributepublic RXAttribute getAttribute(int anIndex) Returns the specific child attribute at the given index.
 - 
getAttributepublic RXAttribute getAttribute(java.lang.String aName) Returns the specific child attribute with the given name.
 - 
hasAttributepublic boolean hasAttribute(java.lang.String aName) Checks for presence of an attribute.
 - 
getAttributeValuepublic java.lang.String getAttributeValue(java.lang.String aName) Returns the attribute string value for the given attribute name.
 - 
getAttributeValuepublic 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).
 - 
getAttributeBoolValuepublic boolean getAttributeBoolValue(java.lang.String aName) Returns the boolean value for the given attribute name.
 - 
getAttributeBoolValuepublic 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).
 - 
getAttributeBooleanValuepublic java.lang.Boolean getAttributeBooleanValue(java.lang.String aName) Returns the Boolean value for the given attribute name.
 - 
getAttributeBooleanValuepublic 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).
 - 
getAttributeIntValuepublic int getAttributeIntValue(java.lang.String aName) Returns the int value for the given attribute name.
 - 
getAttributeIntValuepublic 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).
 - 
getAttributeFloatValuepublic float getAttributeFloatValue(java.lang.String aName) Returns the float value for the given attribute name.
 - 
getAttributeFloatValuepublic 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).
 - 
getAttributeNumberValuepublic java.lang.Number getAttributeNumberValue(java.lang.String aName) Returns the Number value for the given attribute name.
 - 
getAttributeNumberValuepublic 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).
 - 
addpublic void add(RXAttribute anAttribute) Adds the given attribute to this element's list of attributes.
 - 
removepublic void remove(int anIndex) Removes the child element at the given index.
 - 
removepublic void remove(RXAttribute attribute) Removes the given attribute from this elements attributes list.
 - 
removepublic void remove(java.lang.String aName) Removes the given attribute or element by name.
 - 
addpublic void add(java.lang.String aName, java.lang.String aValue)Adds a new attribute with the given name and string value.
 - 
addpublic void add(java.lang.String aName, java.lang.Object aValue)Adds a new attribute with the given name using the object's toString() method.
 - 
addpublic void add(java.lang.String aName, boolean aValue)Adds a new attribute with the given name and boolean value.
 - 
addpublic void add(java.lang.String aName, java.lang.Boolean aValue)Adds a new attribute with the given name and Boolean value.
 - 
addpublic void add(java.lang.String aName, int aValue)Adds a new attribute with the given name and int value.
 - 
addpublic void add(java.lang.String aName, float aValue)Adds a new attribute with the given name and float value.
 - 
toStringpublic java.lang.String toString() Returns a string representation of this element (XML).- Overrides:
- toStringin class- RXAttribute
 
 - 
getBytespublic byte[] getBytes() Returns XML bytes for this element.
 - 
writepublic void write(java.lang.Object aDest) Writes the element as an XML file to the given desination (presumably a String path or File).
 - 
writepublic 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). If safely is true, it will write to a backup file then move it over.
 - 
writepublic 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.
 - 
getErrorpublic static java.lang.String getError() Returns error message from Loading XML (Should really be a ThreadLocal).
 
- 
 
-