• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to create a MAP[Key: XML Element name, Value: Java Object Property Name] for JAXB processed XML?

 
Ketan Damle
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Am currently working on the following requirement.

1. I have a user interface wherein every XML element (in SOAP request/response) would be mapped to a less technical term or a label. (E.g. specType would be referred as "Technology").

2. For the various webservice or for that matter the XML request/response fields, i need to set certain rules (E.g. if specType is the element, then something like Technology is not equal to 'XYZ').

3. There is a UI for creation of rules on the different XML elements(For eg. Country is 'ABC' && Technology is not equal to 'XYZ').

4, JAXB has been used for XML to JAVA transformations.

Is there a way i can generate a map having the XML element name as key, and corresponding Java object property as the value, at runtime in my program?

This may be very very simple, so please bear my ignorance.

Thanks,
Ketan
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds like a java.util.Properties object - there is a nice Properties load( Reader ) method that could be used to read a file. Assuming you can create a text file with the mapping you want, thats all you need.

Bill
 
Ketan Damle
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bill for your reply, but perhaps I have not been able to put across my question properly.

Assume I have a JAXB transformed JAVA class, and has properties as below. (This has been an automatic transformation, no customized bindings provided here.)



Now what I want is a Map with key as the XML element name and value as Java Property name, something like{["local_creationDate","localCreationDate"],["local_accessType", "localAcessType"]}

There is a UI for mapping the XML element name to a less technical label, e.g. [local_creationDate ---> Local Creation Date]. The rule would appear to be set on "Local Creation Date" (E.g. Local Creation Date not before '20-08-2013') but would actually be applied on the java property name "localCreationDate"

Additionally i do not want this to be a static mapping, instead it should be dynamic or at runtime, i was wondering if i could loop through either the XSD or the java classes using reflection and generate this sort of a Map. One way was to read the annotations using reflection, but is there a a more standard, straightforward way to achieve this?


Thanks,
Ketan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!