|
Docmosis API 4.5.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.docmosis.template.population.MemoryDataProvider
An efficient memory based DataProvider. All data is plugged in to an instance of this class which is then immediately available to the population of the template.
This class is provided as a utility to simplify the process of passing data to the population process. When lookups are done using the get* or has* functions, the key parameter may be treated literally or they may have logic applied depending on how this class was constructed. The period ('.') character may be used to indicate a level of "nesting" of data or it may alternatively be treated purely as another character in the key. For example, depending on whether nesting is enabled or not, the following call will behave differently:dp.getString("my.value");If nesting is enabled, the call above is equivalent to (ignoring nulls):
dp.getDataProvider("my").getString("value");If nesting is disabled that same call is equivalent to (ignoring nulls):
dp.getString("my.value");Further, nested elements can be indexed. For example:
dp.getString("my[1].value");is equivalent to
dp.getDataProvider("my", 1).getString("value");if nesting is enabled. Otherwise it is treated literally and lookup will be performed with a key with the precise String
"my[1].value"
.
NOTE: the logic of nesting does NOT apply when setting, adding or removing values.
This means that the following call:
mdp.setString("abc.def", "hello");always treats the key as literal. It is intended that the DataProviderBuilder be used for creating MemoryDataProviders with nesting in mind.
DataProviderBuilder
,
Serialized FormConstructor Summary | |
MemoryDataProvider()
Basic constructor. |
Method Summary | |
void |
addDataProvider(String key,
DataProvider value)
Add a data provider of the given key at the next available index. |
void |
cleanup()
Perform any cleanup duties such as freeing resources. |
protected void |
finalize()
|
boolean |
getBoolean(String key)
Determine if the given key hs been set to true. |
Set |
getBooleanKeys()
Get all of the available keys representing any boolean values. |
DataProvider |
getDataProvider(String key,
int index)
Get the data provider contained within this data provider with the given key as a name, and an index. |
int |
getDataProviderCount(String key)
Return the number of data providers contained within this data provider with the given key as a name. |
Set |
getDataProviderKeys()
Get all of the available keys representing any data providers. |
InputStream |
getImage(String key)
Get the input stream over the image with the given key. |
Set |
getImageKeys()
Get all of the available keys representing any images. |
protected static String |
getRealKey(String key)
Depending on whether we are in case-sensitive mode, return a case-edited version of the key. |
String |
getString(String key)
Gets the string set to the given value. |
Set |
getStringKeys()
Get all of the available keys representing any string values. |
boolean |
hasBooleanKey(String key)
Determine if a value for the boolean key has been specified |
boolean |
hasDataProviderKey(String key)
NOTE: This method does not support nesting of the key value. |
boolean |
hasImageKey(String key)
Determine if the given image has been set (even if to null) |
boolean |
hasStringKey(String key)
Determine if the given string has been set (even if to null) |
void |
setBoolean(String key,
boolean value)
Puts the given value for the given key. |
void |
setFalse(String key)
Add a false value at the given key. |
void |
setImage(String key,
File file)
Puts the given image for the given key. |
void |
setImage(String key,
InputStream in)
Put the given inputstream for an image against the given key. |
void |
setString(String key,
String value)
Sets the given value for the given key. |
void |
setTrue(String key)
Add a true value at the given key. |
String |
toDebugString()
Return the contents represented by a single string, for debug purposes. |
protected String |
toDebugString(int level)
|
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public MemoryDataProvider()
Method Detail |
public String getString(String key)
getString
in interface DataProvider
key
- the key to find the value.
public boolean hasStringKey(String key)
DataProvider
hasStringKey
in interface DataProvider
key
- the key for the String
public void setString(String key, String value)
setString
in interface MutableDataProvider
key
- the key to look for.value
- the value to set.public Set getStringKeys()
public InputStream getImage(String key)
getImage
in interface DataProvider
key
- the key under which to locate the image.
public boolean hasImageKey(String key)
DataProvider
hasImageKey
in interface DataProvider
key
- the key for the String
public void setImage(String key, File file)
setImage
in interface MutableDataProvider
key
- the key to use.file
- the image to set.public void setImage(String key, InputStream in)
setImage
in interface MutableDataProvider
key
- the key to usein
- the inputstream to assignpublic Set getImageKeys()
public boolean getBoolean(String key)
DataProvider
getBoolean
in interface DataProvider
key
- the key to lookup
public boolean hasBooleanKey(String key)
DataProvider
hasBooleanKey
in interface DataProvider
key
- the key to lookup
public void setTrue(String key)
setTrue
in interface MutableDataProvider
key
- the key against which to store a true valuepublic void setFalse(String key)
setFalse
in interface MutableDataProvider
key
- the key against which to store a false valuepublic void setBoolean(String key, boolean value)
setBoolean
in interface MutableDataProvider
key
- the key to look for.value
- the value to set.public Set getBooleanKeys()
public int getDataProviderCount(String key)
getDataProviderCount
in interface DataProvider
key
- the key (name) of the data providers to look for.
public boolean hasDataProviderKey(String key)
hasDataProviderKey
in interface DataProvider
key
- the key with which to lookup the data provider
public DataProvider getDataProvider(String key, int index)
getDataProvider
in interface DataProvider
key
- the key (name) of the data provider to look for.index
- the index of the data provider.
public void addDataProvider(String key, DataProvider value)
addDataProvider
in interface MutableDataProvider
key
- the key (name) for the data provider.value
- the data provider to add.public Set getDataProviderKeys()
protected static String getRealKey(String key)
key
- the key to use.
public String toString()
public String toDebugString()
protected String toDebugString(int level)
protected void finalize() throws Throwable
Throwable
public void cleanup()
Cleanable
cleanup
in interface Cleanable
|
Docmosis API 4.5.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |