Class RXElement
java.lang.Object
com.inductiveautomation.rm.archiver.RXAttribute
com.inductiveautomation.rm.archiver.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 can do this:
for(int i=anElement.indexOf(elementName); i>=0; i=anElement.indexOf(elementName, i+1))
anElement.get(i).doThis();-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(RXAttribute anAttribute) Adds the given attribute to this element's list of attributes.Adds a new attribute with the given name and boolean value.Adds a new attribute with the given name and float value.Adds a new attribute with the given name and int value.Adds a new attribute with the given name and Boolean value.Adds a new attribute with the given name using the object's toString() method.Adds a new attribute with the given name and string value.void
Adds all the given child elements and attributes of given element to this element.void
addAttribute
(RXAttribute anAttribute) Adds an attribute.void
addAttribute
(RXAttribute anAttribute, int anIndex) Adds an attribute at given index.void
addElement
(RXElement anElement) Adds given element to elements list.void
addElement
(RXElement anElement, int anIndex) Adds given element to elements list at given index.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 (or null if not found).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).getAttributeColorValue
(String aName, Color defaultValue) int
Returns the number of child attributes for this element.getAttributeEnumValue
(String aName, Class enumClass, Enum defaultValue) Returns the Enum of a specific type for the given attribute name (or the given default value, if name not found).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).getAttributeFontValue
(String aName, Font defaultValue) int
getAttributeIndex
(RXAttribute anAttribute) Returns this index of the given attribute.int
getAttributeIndex
(String aName) Returns the index of the attribute with the given name (or -1 if 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.getElement
(int anIndex) Returns the individual element at given index.static RXElement
getElement
(Object aSource) Returns a new element hierarchy loaded from aSource (File, String path, InputStream or whatever).getElement
(String aName) Returns the first element for a given name.int
Returns the number of child elements.int
getElementCount
(String aName) Returns the number of child elements with the given name.int
getElementIndex
(RXElement anElement) Returns the index of the given element.int
getElementIndex
(String aName, int start) Returns the index of element with given name.Returns the list of elements.getElements
(String aName) Returns the list of child elements with given name.byte[]
Returns the element value as bytes.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.removeAttribute
(int anIndex) Removes the attribute at given index.int
removeAttribute
(RXAttribute anAttribute) Removes the given attribute.removeAttribute
(String aName) Removes the attribute with given name.removeElement
(int anIndex) Removes element at given index.int
removeElement
(RXElement anElement) Removes given element.removeElement
(String aName) Removes the first element with given name and returns it.removeElements
(String aName) Removes elements for given element name.void
setValueBytes
(byte[] theBytes) Sets the element value from bytes.int
size()
Returns child element list size.toString()
Returns a string representation of this element (XML).void
write
(StringBuffer aSB, int indent, String indentStr) Writes the element to the given string buffer using the given indent level and indent string.protected void
writePreamble
(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.inductiveautomation.rm.archiver.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.
-
-
Method Details
-
getElement
Returns a new element hierarchy loaded from aSource (File, String path, InputStream or whatever). -
getAttributeCount
public int getAttributeCount()Returns the number of child attributes for this element. -
getAttribute
Returns the specific child attribute at the given index. -
getAttributes
Returns the list of child attributes for this element. -
addAttribute
Adds an attribute. -
addAttribute
Adds an attribute at given index. -
removeAttribute
Removes the attribute at given index. -
removeAttribute
Removes the given attribute. -
removeAttribute
Removes the attribute with given name. -
getAttributeIndex
Returns this index of the given attribute. -
getAttribute
Returns the specific child attribute with the given name (or null if not found). -
getAttributeIndex
Returns the index of the attribute with the given name (or -1 if not found). -
getElementCount
public int getElementCount()Returns the number of child elements. -
getElement
Returns the individual element at given index. -
getElements
Returns the list of elements. -
addElement
Adds given element to elements list. -
addElement
Adds given element to elements list at given index. -
removeElement
Removes element at given index. -
removeElement
Removes given element. -
getElementIndex
Returns the index of the given element. -
getElementCount
Returns the number of child elements with the given name. -
getElementIndex
Returns the index of element with given name. -
getElement
Returns the first element for a given name. -
removeElement
Removes the first element with given name and returns it. -
getElements
Returns the list of child elements with given name. -
removeElements
Removes elements for given element 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). -
getAttributeColorValue
-
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). -
getAttributeEnumValue
Returns the Enum of a specific type for the given attribute name (or the given default value, if name not found). -
getAttributeFontValue
-
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
-
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. -
add
-
size
public int size()Returns child element list size. -
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. -
add
Adds the given attribute to this element's list of attributes. -
addAll
Adds all the given child elements and attributes of given element to this element. -
getValueBytes
public byte[] getValueBytes()Returns the element value as bytes. -
setValueBytes
public void setValueBytes(byte[] theBytes) Sets the element value from bytes. -
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 to the given string buffer using the given indent level and indent string. -
writePreamble
Writes the element to the given string buffer using the given indent level and indent string.
-