com.extjs.gxt.ui.client.data
Class JsonReader<D>

java.lang.Object
  extended by com.extjs.gxt.ui.client.data.JsonReader<D>
Type Parameters:
D - the ListLoadResult type being returned by the reader
All Implemented Interfaces:
DataReader<D>
Direct Known Subclasses:
JsonLoadResultReader

public class JsonReader<D>
extends java.lang.Object
implements DataReader<D>

A DataReader implementation that reads JSON data using a ModelType definition and produces a set of ModelData instances.

Subclasses can override createReturnData(Object, List, int) to control what object is returned by the reader. Subclass may override newModelInstance() to return any model data subclass.


Constructor Summary
JsonReader(ModelType modelType)
          Creates a new JSON reader.
 
Method Summary
protected  java.lang.Object createReturnData(java.lang.Object loadConfig, java.util.List<ModelData> records, int totalCount)
          Responsible for the object being returned by the reader.
protected  int getTotalCount(com.google.gwt.json.client.JSONObject root)
           
protected  ModelData newModelInstance()
          Returns the new model instances.
 D read(java.lang.Object loadConfig, java.lang.Object data)
          Reads the raw data and returns the typed data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonReader

public JsonReader(ModelType modelType)
Creates a new JSON reader.

Parameters:
modelType - the model type definition
Method Detail

read

public D read(java.lang.Object loadConfig,
              java.lang.Object data)
Description copied from interface: DataReader
Reads the raw data and returns the typed data.

Specified by:
read in interface DataReader<D>
data - the data to read
Returns:
the data

createReturnData

protected java.lang.Object createReturnData(java.lang.Object loadConfig,
                                            java.util.List<ModelData> records,
                                            int totalCount)
Responsible for the object being returned by the reader.

Parameters:
loadConfig - the load config
records - the list of models
totalCount - the total count
Returns:
the data to be returned by the reader

getTotalCount

protected int getTotalCount(com.google.gwt.json.client.JSONObject root)

newModelInstance

protected ModelData newModelInstance()
Returns the new model instances. Subclasses may override to provide an model data subclass.

Returns:
the new model data instance