Operating system | ||
Stable release 1.4.1 / May 15, 2016; 9 months ago (2016-05-15) |
Castor is a data binding framework for Java with some features like Java to Java-to-XML binding, Java-to-SQL persistence, paths between Java objects, XML documents, relational tables, etc. Castor is one of the oldest data binding projects.
Contents
Process flow
Basic process flows include class generation, marshalling, unmarshalling, etc. Marshalling framework includes a set of ClassDescriptors and FieldDescription to describe objects.
Class Generation
Class generation is similar to JAXB and Zeus. Castor supports XML Schema instead of DTDs (DTDs are not supported by Castor).
Unmarshalling and marshalling
Unmarshalling and marshalling are dealt with marshall() and unmarshall() methods respectively. During marshalling, conversion process from Java to XML is carried out, and, during unmarshalling, conversion process from XML to Java is carried out. Mapping files are the equivalent of a binding schema, which allows to transforms names from XML to Java and vice versa.
Additional Features
Castor offers some additional features which are not present in JAXB. Additional features include:
Code Samples
Code for marshalling may look life as follows:
Code for unmarshalling may look like as follows:
Sample mapping file may look like as follows: