net.sourceforge.javajson.converter
Class Mapper

java.lang.Object
  extended by net.sourceforge.javajson.converter.Mapper

public class Mapper
extends Object

Maps objects to a json object TODO: addMapper as: String field, String alias to map to an existing mapper TODO: addMapper to map a field to objAtField.fieldName and maybe rename the field too


Field Summary
static Mapper DefaultMapper
          Default mapper that can be used to map object all the way down the tree.
protected  Logger log
           
 
Method Summary
 JsonObject toJson(Object obj)
           
 JsonObject toJson(Object obj, boolean flat)
           
protected  JsonObject toJson(Object obj, Class cls)
          Maps an object to json based on a class, this method only works when using the default mapper and is meant to be called via convenience method on Converter.
protected  JsonObject toJson(Object obj, Class cls, boolean flat)
           
 JsonArray toJsonArray(Collection col)
           
 JsonArray toJsonArray(Collection col, boolean flat)
           
protected  JsonArray toJsonArray(Collection col, Class cls)
          Maps a collection to jsonarray based on a class, this method only works when using the default mapper and is meant to be called via convenience method on Converter.
protected  JsonArray toJsonArray(Collection col, Class cls, boolean flat)
          Maps a collection to jsonarray based on a class, this method only works when using the default mapper and is meant to be called via convenience method on Converter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final Logger log

DefaultMapper

public static Mapper DefaultMapper
Default mapper that can be used to map object all the way down the tree.

Method Detail

toJson

protected JsonObject toJson(Object obj,
                            Class cls)
                     throws IllegalArgumentException,
                            IllegalAccessException,
                            InvocationTargetException
Maps an object to json based on a class, this method only works when using the default mapper and is meant to be called via convenience method on Converter.

Parameters:
obj - The object to convert to json
cls -
locale -
Returns:
Throws:
InvocationTargetException
IllegalAccessException
IllegalArgumentException
InvocationTargetException
IllegalAccessException
IllegalArgumentException

toJson

protected JsonObject toJson(Object obj,
                            Class cls,
                            boolean flat)
                     throws IllegalArgumentException,
                            IllegalAccessException,
                            InvocationTargetException
Throws:
IllegalArgumentException
IllegalAccessException
InvocationTargetException

toJson

public JsonObject toJson(Object obj,
                         boolean flat)
                  throws IllegalArgumentException,
                         IllegalAccessException,
                         InvocationTargetException
Throws:
IllegalArgumentException
IllegalAccessException
InvocationTargetException

toJson

public JsonObject toJson(Object obj)
                  throws IllegalArgumentException,
                         IllegalAccessException,
                         InvocationTargetException
Throws:
IllegalArgumentException
IllegalAccessException
InvocationTargetException

toJsonArray

protected JsonArray toJsonArray(Collection col,
                                Class cls)
                         throws IllegalArgumentException,
                                IllegalAccessException,
                                InvocationTargetException
Maps a collection to jsonarray based on a class, this method only works when using the default mapper and is meant to be called via convenience method on Converter.

Parameters:
col -
cls -
Returns:
Throws:
InvocationTargetException
IllegalAccessException
IllegalArgumentException
SecurityException
IllegalArgumentException
NoSuchMethodException
IllegalAccessException
InvocationTargetException

toJsonArray

protected JsonArray toJsonArray(Collection col,
                                Class cls,
                                boolean flat)
                         throws IllegalArgumentException,
                                IllegalAccessException,
                                InvocationTargetException
Maps a collection to jsonarray based on a class, this method only works when using the default mapper and is meant to be called via convenience method on Converter.

Parameters:
col -
cls -
Returns:
Throws:
InvocationTargetException
IllegalAccessException
IllegalArgumentException
SecurityException
IllegalArgumentException
NoSuchMethodException
IllegalAccessException
InvocationTargetException

toJsonArray

public JsonArray toJsonArray(Collection col)
                      throws IllegalArgumentException,
                             IllegalAccessException,
                             InvocationTargetException
Throws:
IllegalArgumentException
IllegalAccessException
InvocationTargetException

toJsonArray

public JsonArray toJsonArray(Collection col,
                             boolean flat)
                      throws IllegalArgumentException,
                             IllegalAccessException,
                             InvocationTargetException
Throws:
IllegalArgumentException
IllegalAccessException
InvocationTargetException