This is famous but little older than Jibx.
How to work with Castor?
It has two ways of implemention, first one as expected using mapping file and the other one is using ClassDescriptors in Castor API.
In First implementation, we will have the following code.
For marshalling:
For unmarshalling :
Second Implementation as follows,
For Marshalling:
Marshaller.marshal(this, out);
For Unmarshalling:
(Clazz) Unmarshaller.unmarshal(Clazz.class, reader);
No need of mapping, but Need a Descriptor File which extends org.exolab.castor.xml.util.XMLClassDescriptorImpl and define descriptors for fields in that file.
At the end Castor & Jibx works fine and looks similar. But in performance Jibx is far better than the other, Since it uses pull parsing, where as Castor uses SAX Parser as it is slower in performance.
How to work with Castor?
It has two ways of implemention, first one as expected using mapping file and the other one is using ClassDescriptors in Castor API.
In First implementation, we will have the following code.
For marshalling:
StringWriter stringWriter = new StringWriter();
Marshaller marshaller = new Marshaller(stringWriter);
marshaller.setMapping(mapping);
marshaller.marshal(object);For unmarshalling :
StringReader stringReader = new StringReader(xmlString);
Unmarshaller unmarshaller = new Unmarshaller(mapping);
Object unmarshalledObject = unmarshaller.unmarshal(new InputSource(stringReader));Second Implementation as follows,
For Marshalling:
Marshaller.marshal(this, out);
For Unmarshalling:
(Clazz) Unmarshaller.unmarshal(Clazz.class, reader);
No need of mapping, but Need a Descriptor File which extends org.exolab.castor.xml.util.XMLClassDescriptorImpl and define descriptors for fields in that file.
At the end Castor & Jibx works fine and looks similar. But in performance Jibx is far better than the other, Since it uses pull parsing, where as Castor uses SAX Parser as it is slower in performance.