This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need to know Java logic to form a setter method for XML property

 
Sureshkumar Chinnappan
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
We are developing our own XML to object mapping frame work.
In this I want to call my object setter and getter method based on the xml property value.
For ex, My XML looks like,
<class name"Employee">
<property name="employeeId" function="set" value="1000" />
<property name="employeeName" function="set" value="Suresh" />
</class>
My Employee bean class looks like,
class Employee{
String employeeId;
String employeeName;
public void setEmployeeId(String employeeId){this.employeeId=employeeId;}
public void setEmployeeName(String mployeeName){this.employeeName=mployeeName;}
public String getEmployeeId(){return employeeId;}
public String getEmployeeName(){return employeeId;}
}
In this, while parsing the Employee part of XML code if the property function is set and the name is employeeId then my frame work java logic should call setEmployeeId(String employeeId) method. I dont know which Java API i should ude for this? ANy help is highly appreciated.
Thanks in advance.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why re-invent the wheel? Can you use JAXB or even Hibernate allows you to map from Java Objects to XML?

Mark
 
Sureshkumar Chinnappan
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,
Thanks for your reply.
We are not creating XML from object. We are setting object values based on the XML. Our product is a legacy one, so cant implement hibernate stuffs. Our database also not a relationdb. So creating our own mapping techniques.
Can you please suggest how to form a method from xml propery. here xml property is nothing but a variable name.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sureshkumar Chinnappan:
Hi Mark,
Thanks for your reply.
We are not creating XML from object. We are setting object values based on the XML. Our product is a legacy one, so cant implement hibernate stuffs. Our database also not a relationdb. So creating our own mapping techniques.
Can you please suggest how to form a method from xml propery. here xml property is nothing but a variable name.


Um, JAXB and Hibernate go in both directions. Not just in creating xml files.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic