Skip to content

API Details

Alessandro Vurro edited this page Jun 9, 2016 · 27 revisions

On this page are described in detail all the components of JMapperAPI.

General Tips

in order to improve readability and simplify the implementation it is strongly recommended to import static methods provided by JMapperAPI:

...
import static com.googlecode.jmapper.api.JMapperAPI.*;
...

The root

The starting point is JMapperAPI, you need to create it to define a configuration:

JMapperAPI api = new JMapperAPI();

An instance of api permits to do two actions: add mapped classes and print the XML as String format:

  • add(..) method takes as input an instance of MappedClass.
  • toXStream() method returns the bean with xstream annotations, to print the xml just call the method toString().

Mapped Classes

To define a mapped Class what you need is create an instance of MappedClasspassing the class or a the literal name of that class:

MappedClass clazz = new MappedClass(aClass.class);
//or
MappedClass clazz = new MappedClass("package.aClass");

and after add it in api instance:

api.add(clazz);

for readability is recommended to use static methods provided by JMapperAPI (in this case mappedClass method):

api.add(mappedClass(aClass.class));
//or
api.add(mappedClass("package.aClass"));

as JMapperAPI MappedClass has only two methods:

  • add(..) method takes as input an instance of Attribute, Global or Conversion.
  • toXStream() method returns the bean with xstream annotations, to print the xml just call the method toString().

Attributes

under construction

Clone this wiki locally