|
J avolution v3.7 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavolution.xml.XmlElement
public final class XmlElement
This class represents a XML element. Instances of this class are made available only during the XML serialization/deserialization process.
During serialization, XmlFormat.format(XmlElement) is used to represent the Java objects
into XML.
During deserialization, XmlFormat.parse(XmlElement) is used to restore the objects from their
XML representations.
| Method Summary | ||
|---|---|---|
void |
add(java.lang.Object obj)
Adds the specified object as an anonymous nested element of unknown type. |
|
void |
add(java.lang.Object obj,
java.lang.String qName)
Adds the specified object as a named nested element of unknown type ( null objects are ignored). |
|
void |
add(java.lang.Object obj,
java.lang.String qName,
java.lang.Class clazz)
Adds the specified object as a named nested element of known type ( null objects are ignored). |
|
void |
add(java.lang.Object obj,
java.lang.String qName,
XmlFormat xmlFormat)
Deprecated. Replaced by add(Object, String, Class) |
|
ContentHandler |
formatter()
Returns the content handler used during serialization (typically a WriterHandler). |
|
|
get(java.lang.String qName)
Returns the object corresponding to the next nested element only if it has the specified qualified name. |
|
|
get(java.lang.String qName,
java.lang.Class clazz)
Returns the object corresponding to the next nested element only if it has the specified qualified name; the object type is identified by the specified class parameter. |
|
|
get(java.lang.String qName,
XmlFormat xmlFormat)
Deprecated. Replaced by get(String, Class) |
|
java.lang.CharSequence |
getAttribute(java.lang.String name)
Searches for the attribute having the specified name. |
|
boolean |
getAttribute(java.lang.String name,
boolean defaultValue)
Returns the specified boolean attribute. |
|
java.lang.Boolean |
getAttribute(java.lang.String name,
java.lang.Boolean defaultValue)
Searches for the specified Boolean attribute. |
|
java.lang.Byte |
getAttribute(java.lang.String name,
java.lang.Byte defaultValue)
Searches for the specified Byte attribute. |
|
java.lang.CharSequence |
getAttribute(java.lang.String name,
java.lang.CharSequence defaultValue)
Returns the specified CharSequence attribute. |
|
double |
getAttribute(java.lang.String name,
double defaultValue)
Returns the specified double attribute. |
|
java.lang.Double |
getAttribute(java.lang.String name,
java.lang.Double defaultValue)
Searches for the specified Double attribute. |
|
float |
getAttribute(java.lang.String name,
float defaultValue)
Returns the specified float attribute. |
|
java.lang.Float |
getAttribute(java.lang.String name,
java.lang.Float defaultValue)
Searches for the specified Float attribute. |
|
int |
getAttribute(java.lang.String name,
int defaultValue)
Returns the specified int attribute. |
|
java.lang.Integer |
getAttribute(java.lang.String name,
java.lang.Integer defaultValue)
Searches for the specified Integer attribute. |
|
long |
getAttribute(java.lang.String name,
long defaultValue)
Returns the specified long attribute. |
|
java.lang.Long |
getAttribute(java.lang.String name,
java.lang.Long defaultValue)
Searches for the specified Long attribute. |
|
java.lang.Short |
getAttribute(java.lang.String name,
java.lang.Short defaultValue)
Searches for the specified Short attribute. |
|
java.lang.String |
getAttribute(java.lang.String name,
java.lang.String defaultValue)
Returns the specified String attribute. |
|
Attributes |
getAttributes()
Returns the attributes for this xml element (parsing or formatting). |
|
FastList |
getContent()
Deprecated. Formats should use getNext() and hasNext()
to parse anonymous content and add(Object)
to serialize anonymous content. |
|
|
getNext()
Returns the object corresponding to the next nested element. |
|
boolean |
hasNext()
Indicates if more nested elements can be read. |
|
boolean |
isAttribute(java.lang.String name)
Indicates if the specified attribute is present. |
|
TextBuilder |
newAttribute(java.lang.String name)
Creates a new attribute for this xml element. |
|
|
object()
Returns the object corresponding to this xml element; this is the object which has been allocated by
the xml format or using the public no-arg constructor
of objectClass(). |
|
java.lang.Class |
objectClass()
Returns the Java(tm) class corresponding to this XML element; the class is identified by the tag name of this xml element or the
"j:class" attribute when present. |
|
XmlPullParser |
parser()
Returns the pull parser used during deserialization. |
|
void |
removeAttribute(java.lang.String name)
Removes the specified attribute. |
|
void |
setAttribute(java.lang.String name,
boolean value)
Sets the specified boolean attribute. |
|
void |
setAttribute(java.lang.String name,
java.lang.Boolean value)
Sets the specified Boolean attribute. |
|
void |
setAttribute(java.lang.String name,
java.lang.Byte value)
Sets the specified Byte attribute. |
|
void |
setAttribute(java.lang.String name,
java.lang.CharSequence value)
Sets the specified CharSequence attribute
(null values are ignored). |
|
void |
setAttribute(java.lang.String name,
double value)
Sets the specified double attribute. |
|
void |
setAttribute(java.lang.String name,
java.lang.Double value)
Sets the specified Double attribute. |
|
void |
setAttribute(java.lang.String name,
float value)
Sets the specified float attribute. |
|
void |
setAttribute(java.lang.String name,
java.lang.Float value)
Sets the specified Float attribute. |
|
void |
setAttribute(java.lang.String name,
int value)
Sets the specified int attribute. |
|
void |
setAttribute(java.lang.String name,
java.lang.Integer value)
Sets the specified Integer attribute. |
|
void |
setAttribute(java.lang.String name,
long value)
Sets the specified long attribute. |
|
void |
setAttribute(java.lang.String name,
java.lang.Long value)
Sets the specified Long attribute. |
|
void |
setAttribute(java.lang.String name,
java.lang.Short value)
Sets the specified Short attribute. |
|
void |
setAttribute(java.lang.String name,
java.lang.String value)
Sets the specified String attribute
(null values are ignored). |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public <T> T object()
throws XmlException
allocated by
the xml format or using the public no-arg constructor
of objectClass().
XmlExceptionpublic java.lang.Class objectClass()
"j:class" attribute when present.
- Returns:
- this XML element's corresponding class.
public ContentHandler formatter()
WriterHandler).
public void add(java.lang.Object obj)
obj - the object added as nested element or null.
public void add(java.lang.Object obj,
java.lang.String qName)
null objects are ignored). The nested xml element
will contain a "j:class" attribute identifying the object type.
obj - the object added as nested element or null.qName - the qualified name of the nested element.
public void add(java.lang.Object obj,
java.lang.String qName,
java.lang.Class clazz)
null objects are ignored).
obj - the object added as nested element or null.qName - the qualified name of the nested element.clazz - the class identifying the xml format to use.public TextBuilder newAttribute(java.lang.String name)
// Formats the color RGB value in hexadecimal.
xml.newAttribute("color").append(_color.getRGB(), 16);
// Formats the error using 4 digits.
xml.newAttribute("error").append(error, 4, false, false);
name - the attribute name.
public void setAttribute(java.lang.String name,
java.lang.CharSequence value)
CharSequence attribute
(null values are ignored).
name - the attribute name.value - the attribute value or null.
public void setAttribute(java.lang.String name,
java.lang.String value)
String attribute
(null values are ignored).
name - the attribute name.value - the attribute value.
public void setAttribute(java.lang.String name,
boolean value)
boolean attribute.
name - the attribute name.value - the boolean value for the specified attribute.getAttribute(String, boolean)
public void setAttribute(java.lang.String name,
int value)
int attribute.
name - the attribute name.value - the int value for the specified attribute.getAttribute(String, int)
public void setAttribute(java.lang.String name,
long value)
long attribute.
name - the attribute name.value - the long value for the specified attribute.getAttribute(String, long)
public void setAttribute(java.lang.String name,
float value)
float attribute.
name - the attribute name.value - the float value for the specified attribute./
public void setAttribute(java.lang.String name,
double value)
double attribute.
name - the attribute name.value - the double value for the specified attribute./
public void setAttribute(java.lang.String name,
java.lang.Boolean value)
Boolean attribute.
name - the name of the attribute.value - the Boolean value for the specified attribute
or null in which case the attribute is not set.getAttribute(String, Boolean)
public void setAttribute(java.lang.String name,
java.lang.Byte value)
Byte attribute.
name - the name of the attribute.value - the Byte value for the specified attribute
or null in which case the attribute is not set.getAttribute(String, Byte)
public void setAttribute(java.lang.String name,
java.lang.Short value)
Short attribute.
name - the name of the attribute.value - the Short value for the specified attribute
or null in which case the attribute is not set.getAttribute(String, Short)
public void setAttribute(java.lang.String name,
java.lang.Integer value)
Integer attribute.
name - the name of the attribute.value - the Integer value for the specified attribute
or null in which case the attribute is not set.getAttribute(String, Integer)
public void setAttribute(java.lang.String name,
java.lang.Long value)
Long attribute.
name - the name of the attribute.value - the Long value for the specified attribute
or null in which case the attribute is not set.getAttribute(String, Long)
public void setAttribute(java.lang.String name,
java.lang.Float value)
Float attribute.
name - the name of the attribute.value - the Float value for the specified attribute
or null in which case the attribute is not set./
public void setAttribute(java.lang.String name,
java.lang.Double value)
Double attribute.
name - the name of the attribute.value - the Double value for the specified attribute
or null in which case the attribute is not set./public void removeAttribute(java.lang.String name)
name - the name of the attribute to remove.public XmlPullParser parser()
public boolean hasNext()
true if more nested elements can be read;
false otherwise.public <T> T getNext()
java.util.NoSuchElementException - if
this.hasNext() == falsepublic <T> T get(java.lang.String qName)
qName - the nested element qualified name required.
null if the qName
does not match.
XmlException - if the specified object has no "j:class" attribute
identifying the object type.
public <T> T get(java.lang.String qName,
java.lang.Class clazz)
qName - the nested element qualified name required.clazz - the class identifying the object to return.
null if the qName
does not match.public Attributes getAttributes()
public java.lang.CharSequence getAttribute(java.lang.String name)
name - the qualified name of the attribute (qName).
null
if the attribute is not found.public boolean isAttribute(java.lang.String name)
name - the qualified name of the attribute (qName).
true if this xml element contains the specified
attribute; false otherwise.
public java.lang.CharSequence getAttribute(java.lang.String name,
java.lang.CharSequence defaultValue)
CharSequence attribute.
name - the name of the attribute.defaultValue - a default value.
defaultValue if the attribute is not found.
public java.lang.String getAttribute(java.lang.String name,
java.lang.String defaultValue)
String attribute.
name - the name of the attribute.defaultValue - a default value.
defaultValue if the attribute is not found.
public boolean getAttribute(java.lang.String name,
boolean defaultValue)
boolean attribute.
name - the name of the attribute searched for.defaultValue - the value returned if the attribute is not found.
boolean value for the specified attribute or
the default value if the attribute is not found.
public int getAttribute(java.lang.String name,
int defaultValue)
int attribute. This method handles
string formats that are used to represent octal and hexadecimal numbers.
name - the name of the attribute searched for.defaultValue - the value returned if the attribute is not found.
int value for the specified attribute or
the default value if the attribute is not found.
public long getAttribute(java.lang.String name,
long defaultValue)
long attribute. This method handles
string formats that are used to represent octal and hexadecimal numbers.
name - the name of the attribute searched for.defaultValue - the value returned if the attribute is not found.
long value for the specified attribute or
the default value if the attribute is not found.
public float getAttribute(java.lang.String name,
float defaultValue)
float attribute.
name - the name of the attribute searched for.defaultValue - the value returned if the attribute is not found.
float value for the specified attribute or
the default value if the attribute is not found.
/
public double getAttribute(java.lang.String name,
double defaultValue)
double attribute.
name - the name of the attribute searched for.defaultValue - the value returned if the attribute is not found.
double value for the specified attribute or
the default value if the attribute is not found.
/
public java.lang.Boolean getAttribute(java.lang.String name,
java.lang.Boolean defaultValue)
Boolean attribute.
name - the name of the attribute.defaultValue - the value returned if the attribute is not found.
Boolean value for the specified attribute or
the default value if the attribute is not found.
public java.lang.Byte getAttribute(java.lang.String name,
java.lang.Byte defaultValue)
Byte attribute.
name - the name of the attribute.defaultValue - the value returned if the attribute is not found.
Byte value for the specified attribute or
the default value if the attribute is not found.
public java.lang.Short getAttribute(java.lang.String name,
java.lang.Short defaultValue)
Short attribute.
name - the name of the attribute.defaultValue - the value returned if the attribute is not found.
Short value for the specified attribute or
the default value if the attribute is not found.
public java.lang.Integer getAttribute(java.lang.String name,
java.lang.Integer defaultValue)
Integer attribute.
name - the name of the attribute.defaultValue - the value returned if the attribute is not found.
Integer value for the specified attribute or
the default value if the attribute is not found.
public java.lang.Long getAttribute(java.lang.String name,
java.lang.Long defaultValue)
Long attribute.
name - the name of the attribute.defaultValue - the value returned if the attribute is not found.
Long value for the specified attribute or
the default value if the attribute is not found.
public java.lang.Float getAttribute(java.lang.String name,
java.lang.Float defaultValue)
Float attribute.
name - the name of the attribute.defaultValue - the value returned if the attribute is not found.
Float value for the specified attribute or
the default value if the attribute is not found.
/
public java.lang.Double getAttribute(java.lang.String name,
java.lang.Double defaultValue)
Double attribute.
name - the name of the attribute.defaultValue - the value returned if the attribute is not found.
Double value for the specified attribute or
the default value if the attribute is not found.
/public FastList getContent()
getNext() and hasNext()
to parse anonymous content and add(Object)
to serialize anonymous content.
public void add(java.lang.Object obj,
java.lang.String qName,
XmlFormat xmlFormat)
add(Object, String, Class)
public <T> T get(java.lang.String qName,
XmlFormat xmlFormat)
get(String, Class)
|
J avolution v3.7 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||