wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes @XmlType doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "@XmlType doubt" Watch "@XmlType doubt" New topic
Author

@XmlType doubt

Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1050

Dear Members,

I came across @XmlType annotation in the below link:
http://java.dzone.com/articles/jaxbs-xmltype-and-proporder

In this the below statement was mentioned which confused me:

When property (method) access is used, the entries in the propOrder attribute correspond to the property names. Note that in this example the property names are different from the underlying field names.
and the code example was given as below.



in the fourth line of the code the line: @XmlType(propOrder={"ID", "firstName", "lastName"}) as this is the example for property(method) access, then how come the attributes of propOrder is "ID" ,"firstName" and "lastName" and why not is is having the method names like getFirstName,getLastName and setID.


http://www.lifesbizzare.blogspot.com || OCJP:81%
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 468
    
    2
... then how come the attributes of propOrder is "ID" ,"firstName" and "lastName" and why not is is having the method names like getFirstName,getLastName and setID.

At least the author is telling a consistent story. The property is taking on specific sense in the general setting of javabeans. In javabeans, a property (private) is accessed through public setter and getter methods following a specific naming convention. They look like this.
void setPropertyName(PropertyType value)
PropertyType getPropertyName()
//or in case of boolean property
boolean isPropertyName()

So the names in those cases are ID, firstName, and lastName (again some inferring via naming convention is used, such as "ID" kept upper in ID, "f" kept lower in FirstName etc). If you advocate another naming schema for javax.xml.bind.annotation, that means you are making your proprietary package rather than using jaxb.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: @XmlType doubt
 
Similar Threads
dynamic (?!) casting
org.hibernate.InvalidMappingException
Unable to understand exception
Could not resolve a persistence unit corresponding to the persistence-context-ref-name
Error setting the expression with value [Ljava.lang.String;@1d05b0a