Docmosis API 4.5.0

com.docmosis.template.population
Interface DataProvider

All Known Subinterfaces:
MutableDataProvider
All Known Implementing Classes:
CompoundDataProvider, DebugDataProvider, KeyedReflectiveDataProvider, MemoryDataProvider, NestingDataProvider, ReflectiveDataProvider

public interface DataProvider

The DataProvider interface marks classes that can provide data to the population phase of document production. Data may be "indexed" meaning that for a key there is a sequence of values. Sequenced data is used when populating repeating areas of a template such as lists or repeating table rows. Indexes are assumed to start at zero. The DataProvider interface also allow nesting of other data providers. This allows the building of data into naturally recursive structures. Many calls will be made to the DataProvider to fetch data so if the implementation performs lengthy operations in these methods, document production will be slowed. Note also that since the data population phase may be re-tried automatically, the implementation must be able to provide the data each time the getter method is called. This is mostly relevant to the getImage() method which must be able to produce the correct stream each time even if the stream has previously been partially read.


Method Summary
 boolean getBoolean(String key)
          Determine if the given key hs been set to true.
 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.
 InputStream getImage(String key)
          Get an InputStream over the image with the given key.
 String getString(String key)
          Get the value for the given key
 boolean hasBooleanKey(String key)
          Determine if a value for the boolean key has been specified
 boolean hasDataProviderKey(String key)
          Determine if a data provider for the key has been specified (even if null)
 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)
 

Method Detail

getString

public String getString(String key)
Get the value for the given key

Parameters:
key - the to look up the value
Returns:
the String value or null

hasStringKey

public boolean hasStringKey(String key)
Determine if the given string has been set (even if to null)

Parameters:
key - the key for the String
Returns:
true if the key has been set.

getImage

public InputStream getImage(String key)
Get an InputStream over the image with the given key. The stream will be closed by the consumer when finished. Document generation may request the same image more than once (even if the stream has been partially read).

Parameters:
key - the key under which to locate the image.
Returns:
null if the image cannot be found

hasImageKey

public boolean hasImageKey(String key)
Determine if the given image has been set (even if to null)

Parameters:
key - the key for the String
Returns:
true if the key has been set.

getBoolean

public boolean getBoolean(String key)
Determine if the given key hs been set to true.

Parameters:
key - the key to lookup
Returns:
false if the key is not set or has not been set to true

hasBooleanKey

public boolean hasBooleanKey(String key)
Determine if a value for the boolean key has been specified

Parameters:
key - the key to lookup
Returns:
true if the boolean value has been set, regardless of what the value is.

getDataProviderCount

public int getDataProviderCount(String key)
Return the number of data providers contained within this data provider with the given key as a name.

Parameters:
key - the key (name) of the data providers to look for.
Returns:
the number of data providers.

hasDataProviderKey

public boolean hasDataProviderKey(String key)
Determine if a data provider for the key has been specified (even if null)

Parameters:
key - the key with which to lookup the data provider
Returns:
true if a data provider has been set for the given key, even if null

getDataProvider

public 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.

Parameters:
key - the key (name) of the data provider to look for.
index - the index of the data provider.
Returns:
a data provider.

Docmosis API 4.5.0

Copyright © 2014 Docmosis Pty Ltd. All Rights Reserved.