|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>
java.util.LinkedList<XmlElement>
xmlwise.XmlElement
public class XmlElement
A simplified XML Element that only has an attribute map, a list of sub elements a text value and a name.
This is the basic entity of the xmlwise library.
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
XmlElement(org.w3c.dom.Element element)
Creates a new XmlElement given an Element object. |
|
XmlElement(java.lang.String name)
Creates a new XmlElement with the given name with no inner text. |
|
XmlElement(java.lang.String name,
java.lang.String value)
Creates a new XmlElement with the given name and inner text value. |
Method Summary | |
---|---|
boolean |
contains(java.lang.String key)
Determines if a direct sub-element exists. |
boolean |
containsAttribute(java.lang.String attribute)
Determines if an attribute exists. |
boolean |
equals(java.lang.Object o)
|
java.util.LinkedList<XmlElement> |
get(java.lang.String name)
Get all elements matching the given key. |
java.lang.String |
getAttribute(java.lang.String attribute)
Returns the (string) value of an attribute. |
java.lang.String |
getAttribute(java.lang.String attribute,
java.lang.String defaultValue)
Get a (string) attribute for this element, defaulting to a default value if the attribute is missing. |
XmlElementAttributes |
getAttributes()
Returns a map with all attributes of this element. |
boolean |
getBoolAttribute(java.lang.String attribute)
Get an boolean attribute for this element. |
boolean |
getBoolAttribute(java.lang.String attribute,
boolean defaultValue)
Get an boolean attribute for this element, defaulting to the default value if missing. |
double |
getDoubleAttribute(java.lang.String attribute)
Get a double attribute for this element. |
double |
getDoubleAttribute(java.lang.String attribute,
double defaultValue)
Get an double attribute for this element, defaulting to a default value if the attribute is missing. |
int |
getIntAttribute(java.lang.String attribute)
Get an integer attribute for this element. |
int |
getIntAttribute(java.lang.String attribute,
int defaultValue)
Get an integer attribute for this element, defaulting to a default value if the attribute is missing. |
java.lang.String |
getName()
Returns the name of this element. |
XmlElement |
getUnique(java.lang.String name)
Get the single direct sub-element with the given name. |
java.lang.String |
getValue()
Get the string value contained in this element. |
int |
hashCode()
|
boolean |
removeAttribute(java.lang.String attribute)
Convenience method to remove an attribute from this element. |
void |
setAttribute(java.lang.String attribute,
java.lang.Object value)
Convenience method to set an attribute on this element. |
java.lang.String |
toString()
|
java.lang.String |
toXml()
Renders this as XML. |
Methods inherited from class java.util.LinkedList |
---|
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, toArray, toArray |
Methods inherited from class java.util.AbstractSequentialList |
---|
iterator |
Methods inherited from class java.util.AbstractList |
---|
listIterator, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, isEmpty, removeAll, retainAll |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
containsAll, isEmpty, iterator, listIterator, removeAll, retainAll, subList |
Methods inherited from interface java.util.Deque |
---|
iterator |
Constructor Detail |
---|
public XmlElement(org.w3c.dom.Element element)
element
- the document element to construct this object from.public XmlElement(java.lang.String name, java.lang.String value)
name
- the name of the node.value
- the inner text value of the node.public XmlElement(java.lang.String name)
name
- the name of the node.Method Detail |
---|
public XmlElement getUnique(java.lang.String name) throws XmlParseException
name
- the name of the sub-element.
XmlParseException
- if there are more than one of the sub element, or if no such element was found.public int getIntAttribute(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 int getIntAttribute(java.lang.String attribute, int defaultValue) throws XmlParseException
attribute
- the name of the attribute.defaultValue
- the default value for the attribute, returned if the attribute is missing.
XmlParseException
- if we fail to parse this attribute as an int.public double getDoubleAttribute(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 double getDoubleAttribute(java.lang.String attribute, double defaultValue) throws XmlParseException
attribute
- the name of the attribute.defaultValue
- the default value for the attribute, returned if the attribute is missing.
XmlParseException
- if we fail to parse this attribute as an double.public java.lang.String getAttribute(java.lang.String attribute, java.lang.String defaultValue)
attribute
- the name of the attribute.defaultValue
- the default value for the attribute, returned if the attribute is missing.
public java.lang.String getAttribute(java.lang.String attribute)
attribute
- the attribute name.
public boolean getBoolAttribute(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 boolean getBoolAttribute(java.lang.String attribute, boolean defaultValue) 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.defaultValue
- the default value of the attribute.
XmlParseException
- if the attribute value does match true or false as definedpublic java.util.LinkedList<XmlElement> get(java.lang.String name)
name
- the key to match.
public void setAttribute(java.lang.String attribute, java.lang.Object value)
attribute
- the attribute to set.value
- the new value of the attribute.public boolean removeAttribute(java.lang.String attribute)
attribute
- the attribute to remove.
public boolean contains(java.lang.String key)
key
- the name of the sub-element.
public java.lang.String toXml()
public java.lang.String getValue()
E.g. the element for <node>foo</node>
would return "foo" as its value.
Note that this value will be a concatenation of all strings directly inside the element, even if the element contains sub elements.
public XmlElementAttributes getAttributes()
public java.lang.String getName()
E.g. the element for <node>foo</node>
would return "node" as its name.
public boolean containsAttribute(java.lang.String attribute)
attribute
- the attribute to check.
public boolean equals(java.lang.Object o)
equals
in interface java.util.Collection<XmlElement>
equals
in interface java.util.List<XmlElement>
equals
in class java.util.AbstractList<XmlElement>
public int hashCode()
hashCode
in interface java.util.Collection<XmlElement>
hashCode
in interface java.util.List<XmlElement>
hashCode
in class java.util.AbstractList<XmlElement>
public java.lang.String toString()
toString
in class java.util.AbstractCollection<XmlElement>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |