How to generate the Clone method in the classes

View: New views
3 Messages — Rating Filter:   Alert me  

How to generate the Clone method in the classes

by BACHU, RAJESH (RAJESH)** CTR ** :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi,

 

I am using Castor1.2. With the help of Binding file, I am able add the impl= ements tag on the class. But found no possibility to add the method clone()= .

Is there any way to generate the clone method?

 

Thanks,

RajBachu

 


Parent Message unknown RE: How to generate the Clone method in the classes

by sperlab :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Provided your mapping, here is a method to clone any castor instance :

 

                public Object getCastorXMLClone(Object castorSource) {

                               Object clonedObject = null;

                               try {

                                               Document doc1 = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();

                                               Marshaller m = new Marshaller(doc1);

                                               m.setMapping(myMapping);

                                               m.marshal(castorSource);

 

                                               Unmarshaller u = new Unmarshaller(DbProvider.getInstance().getCloneMapping());

                                               clonedObject = u.unmarshal(doc1);

 

                               } catch (Exception e) {

                                               e.printStackTrace();

                               }

                               return clonedObject;

                }

 

Sébastien PERES-LABOURDETTE


Re: How to generate the Clone method in the classes

by Werner Guttmann-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

BACHU, RAJESH (RAJESH)** CTR ** wrote:
> I am using Castor1.2. With the help of Binding file, I am able add
> the impl= ements tag on the class. But found no possibility to add
> the method clone()= . Is there any way to generate the clone method?
Not currently. But feel free to add a feature request to our Jira instance.

Out of curiosity, what would you expect in this context ?

Regards
Wernea

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email