Package org.simpleframework.xml
Annotation Interface Attribute
The
Attribute
annotation represents a serializable XML
attribute within an XML element. An object annotated with this is
typically a primitive or enumerated type. Conversion from the
attribute to primitive type is done with a Transform
object. If a suitable transform can be found then this will convert
the attribute string value to an object instance, which can be
assigned to the annotated field, or passed to the annotated method.- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThis is used to provide a default value for the attribute if the annotated field or method is null.This represents the name of the XML attribute.boolean
Determines whether the attribute is required within an XML element.
-
Element Details
-
name
String nameThis represents the name of the XML attribute. Annotated fields or methods can optionally provide the name of the XML attribute they represent. If a name is not provided then the field or method name is used in its place. A name can be specified if the field or method name is not suitable for the XML attribute.- Returns:
- the name of the XML attribute this represents
- Default:
""
-
empty
String emptyThis is used to provide a default value for the attribute if the annotated field or method is null. This ensures the the serialization process writes the attribute with a value even if the value is null, and allows deserialization to determine whether the value within the object was null or not.- Returns:
- this returns the default attribute value to use
- Default:
""
-
required
boolean requiredDetermines whether the attribute is required within an XML element. Any field marked as not required will not have its value set when the object is deserialized. If an object is to be serialized only a null attribute will not appear as XML.- Returns:
- true if the attribute is required, false otherwise
- Default:
true
-