Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@XmlType doubt

 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
g tsuji
Ranch Hand
Posts: 671
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic