Docmosis API 4.5.0

com.docmosis.template.population
Class JSONDataProvider

java.lang.Object
  extended bycom.docmosis.template.population.MemoryDataProvider
      extended bycom.docmosis.template.population.JSONDataProvider
All Implemented Interfaces:
Cleanable, DataProvider, MutableDataProvider, Serializable

public class JSONDataProvider
extends MemoryDataProvider

A MemoryDataProvider that can load itself from JSON formatted data.

See Also:
Serialized Form

Constructor Summary
JSONDataProvider()
           
JSONDataProvider(String jsonString, StringInterceptor[] interceptors)
          Construct a data provider from a JSON string.
 
Method Summary
 String toJSONString()
          Convert this Data Provider into a JSON string.
static String toJSONString(MemoryDataProvider dp)
          Convert the given Data Provider into a JSON string.
 
Methods inherited from class com.docmosis.template.population.MemoryDataProvider
addDataProvider, cleanup, finalize, getBoolean, getBooleanKeys, getDataProvider, getDataProviderCount, getDataProviderKeys, getImage, getImageKeys, getRealKey, getString, getStringKeys, hasBooleanKey, hasDataProviderKey, hasImageKey, hasStringKey, setBoolean, setFalse, setImage, setImage, setString, setTrue, toDebugString, toDebugString, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JSONDataProvider

public JSONDataProvider()

JSONDataProvider

public JSONDataProvider(String jsonString,
                        StringInterceptor[] interceptors)
                 throws JSONException
Construct a data provider from a JSON string.

Parameters:
jsonString - the JSON string.
interceptors - an array of interceptors that have the opportunity to interpret the given key and value and add the data to this data provider in a different form.
Method Detail

toJSONString

public String toJSONString()
                    throws JSONException
Convert this Data Provider into a JSON string.

Returns:
a string containing the JSON content - can be written to a file.
Throws:
JSONException - for serious unexpected errors.
ClassCastException - if any sub data provider of dp is not a MemoryDataProvider (or subclass).

toJSONString

public static String toJSONString(MemoryDataProvider dp)
                           throws JSONException
Convert the given Data Provider into a JSON string.

Parameters:
dp - the data provider to convert (must be a MemoryDataProvider or subclass).
Returns:
a string containing the JSON content - can be written to a file.
Throws:
JSONException - for serious unexpected errors.
ClassCastException - if any sub data provider of dp is not a MemoryDataProvider (or subclass).

Docmosis API 4.5.0

Copyright © 2014 Docmosis Pty Ltd. All Rights Reserved.