aspose file tools*
The moose likes Object Relational Mapping and the fly likes Need to know Java logic to form a setter method for XML property Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Need to know Java logic to form a setter method for XML property" Watch "Need to know Java logic to form a setter method for XML property" New topic
Author

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

Sureshkumar Chinnappan
Greenhorn

Joined: Feb 15, 2006
Posts: 27
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.


Warm Regards,<br />Suresh Kumar<br /> <br />SCJP 5.0<br />SCWCD 1.4
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Why re-invent the wheel? Can you use JAXB or even Hibernate allows you to map from Java Objects to XML?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Sureshkumar Chinnappan
Greenhorn

Joined: Feb 15, 2006
Posts: 27
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

Joined: Feb 05, 2001
Posts: 17260
    
    6

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
 
subject: Need to know Java logic to form a setter method for XML property