Need to know Java logic to form a setter method for XML property
Sureshkumar Chinnappan
Greenhorn
Joined: Feb 15, 2006
Posts: 27
posted
0
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.
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.
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.