net.sf.jsm.table.utils
Class JsmTableUtil

java.lang.Object
  extended bynet.sf.jsm.table.utils.JsmTableUtil

public class JsmTableUtil
extends java.lang.Object

Utiltiy class to work with table related classes

Author:
ronald ploeger

Field Summary
static Log logger
           
 
Constructor Summary
JsmTableUtil()
           
 
Method Summary
static java.util.ArrayList generateJsmTrs(java.util.Collection valueObjects, java.util.List propertyPathsToRetrieveValues, java.lang.String[] propertyPathsForRowMetaData, GenerateJsmTrsCallback callback)
          Generates a JsmTr object for each of the valueObjects.
static java.util.ArrayList generateJsmTrs(java.util.Collection valueObjects, java.lang.String[] propertyPathsToRetrieveValues, java.lang.String[] propertyPathsForRowMetaData, GenerateJsmTrsCallback callback)
          Generates a JsmTr object for each of the valueObjects.
static java.lang.String getJSONRows(java.util.Collection rows)
          Generates a JSON Array of JsmTr objects
static void setValuesOnObject(java.lang.Object object, JSONObject json, java.util.HashMap converters)
          Sets values from a JSONObject back into a bean optionally using converters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static Log logger
Constructor Detail

JsmTableUtil

public JsmTableUtil()
Method Detail

generateJsmTrs

public static java.util.ArrayList generateJsmTrs(java.util.Collection valueObjects,
                                                 java.lang.String[] propertyPathsToRetrieveValues,
                                                 java.lang.String[] propertyPathsForRowMetaData,
                                                 GenerateJsmTrsCallback callback)
                                          throws JsmException
Generates a JsmTr object for each of the valueObjects. Adds cells for each property retrieved by the propertyPathsForCellValues entries. Adds meta data to the row retrieved by the propertyPathsForRowMetaData entries.

Parameters:
valueObjects - The objects to get the retrieve the values from
propertyPathsToRetrieveValues - The path to retrieve the cell values from the value objects
propertyPathsForRowMetaData - The path to retrieve the row meta data from the value objects; Can be null
callback - An optional callback object (can be null) which will be called with every created JsmTr object. The call back has read access to the currently processed valueObject but should never modify it. The JsmTr object can be modified.
Returns:
Throws:
JsmException

generateJsmTrs

public static java.util.ArrayList generateJsmTrs(java.util.Collection valueObjects,
                                                 java.util.List propertyPathsToRetrieveValues,
                                                 java.lang.String[] propertyPathsForRowMetaData,
                                                 GenerateJsmTrsCallback callback)
                                          throws JsmException
Generates a JsmTr object for each of the valueObjects. Adds cells for each property retrieved by the propertyPathsForCellValues entries. Adds meta data to the row retrieved by the propertyPathsForRowMetaData entries.
Sets the meta data JsmObject.META_DATA_NAME_PROPERTY_PATH on each cell to the string specified in propertyPathsToSetValues

Parameters:
valueObjects - The objects to get the retrieve the values from
propertyPathsToRetrieveValues - List of String or String[] elements. A String element or the first item of the String[] is used as the path to retrieve the cell value from the value objects. The second item of the String[] is used to populate the meta data JsmObject.META_DATA_NAME_VALUE of the cell
propertyPathsForRowMetaData - The path to retrieve the row meta data from the value objects; Can be null
callback - An optional callback object (can be null) which will be called with every created JsmTr object. The call back has read access to the currently processed valueObject but should never modify it. The JsmTr object can be modified.
Returns:
Throws:
JsmException

setValuesOnObject

public static void setValuesOnObject(java.lang.Object object,
                                     JSONObject json,
                                     java.util.HashMap converters)
                              throws JsmException
Sets values from a JSONObject back into a bean optionally using converters

Parameters:
object - The object to set the values on
json - The JSONObject which keys are the propertyPath and which values are the values to set on the object
converters - A HashMap of converters implementing the Converter interface. The key of the HashMap is the propertyPath on which the converter (which is the value of the HashMap) should be used.
Throws:
JsmException

getJSONRows

public static java.lang.String getJSONRows(java.util.Collection rows)
Generates a JSON Array of JsmTr objects

Parameters:
rows - Collection of JsmTr objects
Returns: