Ontimize 5.2071EN

com.ontimize.util.templates
Class AbstractTemplateGenerator

java.lang.Object
  extended bycom.ontimize.util.templates.AbstractTemplateGenerator
All Implemented Interfaces:
TemplateGenerator
Direct Known Subclasses:
ODFTemplateGenerator, PdfTemplateGenerator, WordTemplateGenerator

public abstract class AbstractTemplateGenerator
extends java.lang.Object
implements TemplateGenerator


Field Summary
protected static boolean createLabelsInTemplate
          Variable used to show labels in the template or not, if createLabelsInTemplate is false only the bookmarks are added to the template, without any label
protected  java.text.DateFormat dateFormat
           
static boolean DEBUG
           
protected  java.text.NumberFormat numberFormat
           
 
Constructor Summary
AbstractTemplateGenerator()
           
 
Method Summary
static int calculateRecordCount(java.util.Hashtable data)
          Calculates the number of data rows.
static boolean containsHashtableValue(java.util.Hashtable data)
          Returns true if some of the values in the input parameter is another hashtable
static java.io.File createFileFieldData(java.io.File directory, java.lang.String data)
          Creates the File 'fielddata.dat' in the specified directory
static java.io.File createImageDataFile(java.io.File directory, java.util.Hashtable valuesImages)
          Creates the data files with image values.
static java.io.File createTableDataDefinition(java.io.File directory, java.util.Hashtable valuesTable, java.text.DateFormat df)
          Creates table definition files
Creates one file for each table and one index file (tableIndex.txt)
static java.io.File createTableDataDefinition(java.io.File directory, java.util.Hashtable valuesTable, java.text.DateFormat df, java.text.NumberFormat numberFormat)
           
static java.io.File createTableDataFile(java.io.File directory, java.util.Hashtable valuesTable)
          Creates the data files with table values.
static java.io.File createTableDataFile(java.io.File directory, java.util.Hashtable valuesTable, java.lang.String indexFileName)
           
static java.lang.String exportFieldData(java.util.Hashtable data, java.lang.String delimiter, java.text.DateFormat df)
          Creates a String with format: key1 + delimiter + value1 + delimiter + key2 + delimiter + value2 + delimiter + ... + keyN + delimiter + valueN
static java.lang.String exportFieldData(java.util.Hashtable data, java.lang.String delimiter, java.text.DateFormat df, java.text.NumberFormat numberFormat)
          Creates a String with format: key1 + delimiter + value1 + delimiter + key2 + delimiter + value2 + delimiter + ... + keyN + delimiter + valueN
static java.lang.String exportTableData(java.util.Hashtable data)
          Creates a String with all table data.
 java.io.File fillDocument(java.io.InputStream input, java.lang.String nameFile, java.util.Hashtable fieldValues, java.util.Hashtable valuesTable, java.util.Hashtable valuesImages)
          Fills the template
 java.io.File fillDocument(java.lang.String resource, java.util.Hashtable fieldValues, java.util.Hashtable valuesTable, java.util.Hashtable valuesImages)
          Fills the specified template
 java.io.File fillDocument(java.lang.String resource, java.util.Hashtable fieldValues, java.util.Hashtable valuesTable, java.util.Hashtable valuesImages, java.util.Hashtable valuesPivotTable)
           
static java.lang.Object[] getKeysOrder(java.util.Hashtable data)
           
protected static double getScreenPoints(int pixelsValue)
          Calculates the screen point for a pixel value
protected static java.lang.String parseNumber(java.lang.Number number, java.text.NumberFormat numberFormat)
           
static void savePngImageFile(java.awt.Image im, java.io.File fImage)
          Save the image in the specified File as a png Image.
 void setCreateLabelsInTemplate(boolean createLabels)
           
 void setDateFormat(java.text.DateFormat df)
          Sets the date format to use in the dates of the document
 void setNumberFormat(java.text.NumberFormat nf)
          Sets the number format to use in the numeric values of the document
static java.lang.String transformFieldData(java.util.Hashtable dataField, java.text.DateFormat df)
          Creates a String with format: key1 + delimiter + value1 + delimiter + key2 + delimiter + value2 + delimiter + ... + keyN + delimiter + valueN Replace all "\n" for "\r" to delete the carriage return
static java.lang.String transformFieldData(java.util.Hashtable dataField, java.text.DateFormat df, java.text.NumberFormat numberFormat)
          Creates a String with format: key1 + delimiter + value1 + delimiter + key2 + delimiter + value2 + delimiter + ... + keyN + delimiter + valueN Replace all "\n" for "\r" to delete the carriage return
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ontimize.util.templates.TemplateGenerator
createTemplate, fillDocument, queryTemplateFields, queryTemplateFields, setShowTemplate
 

Field Detail

DEBUG

public static boolean DEBUG

createLabelsInTemplate

protected static boolean createLabelsInTemplate
Variable used to show labels in the template or not, if createLabelsInTemplate is false only the bookmarks are added to the template, without any label


dateFormat

protected java.text.DateFormat dateFormat

numberFormat

protected java.text.NumberFormat numberFormat
Constructor Detail

AbstractTemplateGenerator

public AbstractTemplateGenerator()
Method Detail

fillDocument

public java.io.File fillDocument(java.lang.String resource,
                                 java.util.Hashtable fieldValues,
                                 java.util.Hashtable valuesTable,
                                 java.util.Hashtable valuesImages)
                          throws java.lang.Exception
Description copied from interface: TemplateGenerator
Fills the specified template

Specified by:
fillDocument in interface TemplateGenerator
Parameters:
fieldValues - Values for the data fields
valuesTable - Table values
valuesImages - Image values
Returns:
Throws:
java.lang.Exception

fillDocument

public java.io.File fillDocument(java.io.InputStream input,
                                 java.lang.String nameFile,
                                 java.util.Hashtable fieldValues,
                                 java.util.Hashtable valuesTable,
                                 java.util.Hashtable valuesImages)
                          throws java.lang.Exception
Description copied from interface: TemplateGenerator
Fills the template

Specified by:
fillDocument in interface TemplateGenerator
Parameters:
input - : Template to fill.
nameFile - : Name used to save the filled template
fieldValues - : This object contains the data field values to insert in the template. Keys must be the field names and values must have the data field values to insert.
valuesTable - : The object contains the table values to insert in the template. Each key must be the table entity name and value must be an EntityResult
valuesImages - : The object contains the image values to insert. Key must be the image field name and value must be the image data. The value could be an image object (Image), a BytesBlock or a File.
Returns:
Throws:
java.lang.Exception

fillDocument

public java.io.File fillDocument(java.lang.String resource,
                                 java.util.Hashtable fieldValues,
                                 java.util.Hashtable valuesTable,
                                 java.util.Hashtable valuesImages,
                                 java.util.Hashtable valuesPivotTable)
                          throws java.lang.Exception
Specified by:
fillDocument in interface TemplateGenerator
Throws:
java.lang.Exception

setCreateLabelsInTemplate

public void setCreateLabelsInTemplate(boolean createLabels)
Specified by:
setCreateLabelsInTemplate in interface TemplateGenerator

transformFieldData

public static java.lang.String transformFieldData(java.util.Hashtable dataField,
                                                  java.text.DateFormat df)
Creates a String with format: key1 + delimiter + value1 + delimiter + key2 + delimiter + value2 + delimiter + ... + keyN + delimiter + valueN Replace all "\n" for "\r" to delete the carriage return

Parameters:
dataField -
df -
Returns:
See Also:
exportFieldData(Hashtable, String, DateFormat)

transformFieldData

public static java.lang.String transformFieldData(java.util.Hashtable dataField,
                                                  java.text.DateFormat df,
                                                  java.text.NumberFormat numberFormat)
Creates a String with format: key1 + delimiter + value1 + delimiter + key2 + delimiter + value2 + delimiter + ... + keyN + delimiter + valueN Replace all "\n" for "\r" to delete the carriage return

Parameters:
dataField -
df -
numberFormat -
Returns:
See Also:
exportFieldData(Hashtable, String, DateFormat,NumberFormat)

createFileFieldData

public static java.io.File createFileFieldData(java.io.File directory,
                                               java.lang.String data)
                                        throws java.lang.Exception
Creates the File 'fielddata.dat' in the specified directory

Parameters:
directory - Directory
data - File content
Returns:
Throws:
java.lang.Exception

createTableDataFile

public static java.io.File createTableDataFile(java.io.File directory,
                                               java.util.Hashtable valuesTable)
                                        throws java.lang.Exception
Creates the data files with table values.
Creates one file for each table and one index file (tableIndex.txt)

Parameters:
directory - Directory where the files will be created in
valuesTable - The object contains the table values to insert in the template. Each key must be the table entity name and value must be an EntityResult
Returns:
The index file with name tableIndex.txt
Throws:
java.lang.Exception

createTableDataFile

public static java.io.File createTableDataFile(java.io.File directory,
                                               java.util.Hashtable valuesTable,
                                               java.lang.String indexFileName)
                                        throws java.lang.Exception
Parameters:
directory - Directory where the files will be created in
valuesTable - The object contains the table values to insert in the template. Each key must be the table entity name and value must be an EntityResult
indexFileName - Name of the returned file with the table index
Returns:
Throws:
java.lang.Exception

createTableDataDefinition

public static java.io.File createTableDataDefinition(java.io.File directory,
                                                     java.util.Hashtable valuesTable,
                                                     java.text.DateFormat df)
                                              throws java.lang.Exception
Creates table definition files
Creates one file for each table and one index file (tableIndex.txt)

Parameters:
directory - Directory where the files will be created in
valuesTable - The object contains the table data to create the template. Each key must be the table entity name and value must be an Hashtable with column names and labels
df -
Returns:
The table index File
Throws:
java.lang.Exception

createTableDataDefinition

public static java.io.File createTableDataDefinition(java.io.File directory,
                                                     java.util.Hashtable valuesTable,
                                                     java.text.DateFormat df,
                                                     java.text.NumberFormat numberFormat)
                                              throws java.lang.Exception
Throws:
java.lang.Exception

createImageDataFile

public static java.io.File createImageDataFile(java.io.File directory,
                                               java.util.Hashtable valuesImages)
                                        throws java.lang.Exception
Creates the data files with image values.
Creates one file for each image and one index file (imageIndex.txt)

Parameters:
directory - Directory where the files will be created in
valuesImages - The object contains the image values to insert. Key must be the image field name and value must be the image data. The value could be an image object (Image), a BytesBlock or a File .
Returns:
Throws:
java.lang.Exception

getScreenPoints

protected static double getScreenPoints(int pixelsValue)
Calculates the screen point for a pixel value

Parameters:
pixelsValue - number of pixels
Returns:

exportFieldData

public static java.lang.String exportFieldData(java.util.Hashtable data,
                                               java.lang.String delimiter,
                                               java.text.DateFormat df)
Creates a String with format: key1 + delimiter + value1 + delimiter + key2 + delimiter + value2 + delimiter + ... + keyN + delimiter + valueN

Parameters:
data - Hashtable with all data
delimiter - Delimiter to separate the fields
df - Format to use in date data fields
Returns:

exportFieldData

public static java.lang.String exportFieldData(java.util.Hashtable data,
                                               java.lang.String delimiter,
                                               java.text.DateFormat df,
                                               java.text.NumberFormat numberFormat)
Creates a String with format: key1 + delimiter + value1 + delimiter + key2 + delimiter + value2 + delimiter + ... + keyN + delimiter + valueN

Parameters:
data - Hashtable with all data
delimiter - Delimiter to separate the fields
df - Format to use in date data fields
numberFormat - Format to use in the numeric fields
Returns:

parseNumber

protected static java.lang.String parseNumber(java.lang.Number number,
                                              java.text.NumberFormat numberFormat)

exportTableData

public static java.lang.String exportTableData(java.util.Hashtable data)
Creates a String with all table data. The String format is:
\n colName1 $ colData1.1 # colData1.2 # ...# colData1.N $ colName2 $ colData2.1 # colData2.2 # ...# colData2.N

Parameters:
data - Table data
Returns:

calculateRecordCount

public static int calculateRecordCount(java.util.Hashtable data)
Calculates the number of data rows.

Parameters:
data -
Returns:
The size of the first Vector found in the Hashtable

savePngImageFile

public static void savePngImageFile(java.awt.Image im,
                                    java.io.File fImage)
                             throws java.io.IOException
Save the image in the specified File as a png Image.

Parameters:
im - Image to save
fImage - File
Throws:
java.io.IOException

setDateFormat

public void setDateFormat(java.text.DateFormat df)
Description copied from interface: TemplateGenerator
Sets the date format to use in the dates of the document

Specified by:
setDateFormat in interface TemplateGenerator
Parameters:
df - Format

setNumberFormat

public void setNumberFormat(java.text.NumberFormat nf)
Description copied from interface: TemplateGenerator
Sets the number format to use in the numeric values of the document

Specified by:
setNumberFormat in interface TemplateGenerator
Parameters:
nf -

containsHashtableValue

public static boolean containsHashtableValue(java.util.Hashtable data)
Returns true if some of the values in the input parameter is another hashtable

Parameters:
data -
Returns:

getKeysOrder

public static java.lang.Object[] getKeysOrder(java.util.Hashtable data)

Ontimize