simple.xml
Annotation Type Attribute


@Retention(value=RUNTIME)
public @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 the types single argument constructor, that takes a string. For example an int is converted with the Integer(String) constructor.

Author:
Niall Gallagher

Optional Element Summary
 java.lang.String name
          This represents the name of the XML attribute.
 boolean required
          Determines whether the attribute is required within an XML element.
 

name

public abstract java.lang.String name
This 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:
""

required

public abstract boolean required
Determines 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