public class XmlElementAttributes
extends java.util.HashMap<java.lang.String,java.lang.String>
Aside from the hash map methods, it also has convenience methods for extracting integers, booleans and doubles.
Constructor and Description |
---|
XmlElementAttributes(org.w3c.dom.Element element)
Creates an object given an Element object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
getBoolean(java.lang.String attribute)
Get an boolean attribute.
|
double |
getDouble(java.lang.String attribute)
Get a double attribute.
|
int |
getInt(java.lang.String attribute)
Get an integer attribute.
|
java.lang.String |
toXml()
Renders the content of the attributes as Xml.
|
public XmlElementAttributes(org.w3c.dom.Element element)
element
- the element to read from.public int getInt(java.lang.String attribute) throws XmlParseException
attribute
- the name of the attribute.XmlParseException
- if we fail to parse this attribute as an int, or the attribute is missing.public double getDouble(java.lang.String attribute) throws XmlParseException
attribute
- the name of the attribute.XmlParseException
- if we fail to parse this attribute as an double, or the attribute is missing.public boolean getBoolean(java.lang.String attribute) throws XmlParseException
"true", "yes" and "y" are all interpreted as true. (Case-independent)
"false", "no" and "no" are all interpreted at false. (Case-independent)
attribute
- the name of the attribute.XmlParseException
- if the attribute value does match true or false as defined, or the attribute is missing.public java.lang.String toXml()