jaxb annotations

@XmlRootElement

Class level. Mark as Root

@XmlType(properOder={“field1”, “field2″…}

Class Level. Not root element and will be used inside the DOM tree.

notice the propOrder parameter of the @XmlType annotation. By default JAXB will order the elements alphabetically. Use the propOrder parameter to specify the order when marshaling to XML. The values are the bean names, not the overridden names in the @XmlElement(name = “overridenName”) annotation.

@XmlElement

field/property level. Used as element\

@XmlAttribute

filed/property level. Used for xml attribute

@XmlAccessorType

Class level . REFERENCE

XmlAccessType.PUBLIC_MEMBER

PUBLIC_MEMBER is the default access type in JAXB.  It means that a JAXB implementation will generate bindings for:
  • public fields
  • annotated fields
  • properties

XmlAccessType.PROPERTY

When the PROPERTY access type is used, JAXB implementations will generate bindings for:
  • annotated fields
  • properties
XmlAccessType.FIELD
The use of access type FIELD will cause JAXB implementations to create bindings for:
  • fields
  • annotated properties
XmlAccessType.NONE
When access type NONE is used JAXB will create bindings for:
  • annotated fields
  • annotated properties

@XmlElementWrapper

@XmlElementWrapper annotation on the List collection. This makes JAXB wrap all of the order XML elements inside of an orders XML element. This annotation can be used with an array instead of a List too

@XmlJavaTypeAdapter

good for inheritence : reference

HERE is a good article

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s