TemplateEngine

Inheritance: java.lang.Object

public final class TemplateEngine

This class uses specified template to construct E-Mail messages.

Constructors

Constructor Description
TemplateEngine(String fileName) Initializes a new instance of the TemplateEngine class.
TemplateEngine(MailMessage templateMessage) Initializes a new instance of the TemplateEngine class.

Methods

Method Description
registerRoutine(String name, TemplateRoutine routine) Registers the template routine to the temaplate engine.
isRoutineRegistered(String name) Determines if a name of template routine is registered in the template engine.
unregisterRoutine(String name) Unregister the template routine from the template engine by name.
merge(MailMessage source) Merge a source MailMessage with the template
merge(DataRow row) Merge a source DataRow with the template.
reset() Resets this instance.
instantiate(DataTable table, DataColumnMappingCollection mappings) Instantiates the template with a DataTable as datasource.
instantiate(DataTable table) Instantiates the template with a DataTable as datasource.
instantiate(DataRowCollection rows, DataColumnMappingCollection mappings) Instantiates the template with a DataRowCollection as datasource.
instantiate(DataRowCollection rows) Instantiates the template with a DataRowCollection as datasource.
instantiate(IDataReader reader) Instantiates the template with a IDataReader as datasource.

TemplateEngine(String fileName)

public TemplateEngine(String fileName)

Initializes a new instance of the TemplateEngine class.

Parameters:

Parameter Type Description
fileName java.lang.String Name of the file.

TemplateEngine(MailMessage templateMessage)

public TemplateEngine(MailMessage templateMessage)

Initializes a new instance of the TemplateEngine class.

Parameters:

Parameter Type Description
templateMessage MailMessage The template message.

registerRoutine(String name, TemplateRoutine routine)

public final void registerRoutine(String name, TemplateRoutine routine)

Registers the template routine to the temaplate engine.

Parameters:

Parameter Type Description
name java.lang.String The name of the funciton.
routine TemplateRoutine Delegate processing the data

isRoutineRegistered(String name)

public final boolean isRoutineRegistered(String name)

Determines if a name of template routine is registered in the template engine.

Parameters:

Parameter Type Description
name java.lang.String The name that is used to register the template routine.

Returns: boolean - Returns True if the name is registered in the template engine, otherwise returns False.

unregisterRoutine(String name)

public final void unregisterRoutine(String name)

Unregister the template routine from the template engine by name.

Parameters:

Parameter Type Description
name java.lang.String The name that is used to unregister the template routine.

merge(MailMessage source)

public final MailMessage merge(MailMessage source)

Merge a source MailMessage with the template

Parameters:

Parameter Type Description
source MailMessage The source MailMessage

Returns: MailMessage - The MailMessage merged with template

merge(DataRow row)

public final MailMessage merge(DataRow row)

Merge a source DataRow with the template.

Parameters:

Parameter Type Description
row DataRow The source DataRow.

Returns: MailMessage - The MailMessage merged with template.

reset()

public final void reset()

Resets this instance.

instantiate(DataTable table, DataColumnMappingCollection mappings)

public final MailMessageCollection instantiate(DataTable table, DataColumnMappingCollection mappings)

Instantiates the template with a DataTable as datasource.

Parameters:

Parameter Type Description
table DataTable The DataTable, which contains the source data to instantiate the template.
mappings DataColumnMappingCollection The IColumnMappingCollection, which represents the mapping between the source column in DataTable and target field in template

Returns: MailMessageCollection - A MailMessageCollection that generated by the template and the datasource.

instantiate(DataTable table)

public final MailMessageCollection instantiate(DataTable table)

Instantiates the template with a DataTable as datasource.

Parameters:

Parameter Type Description
table DataTable The DataTable, which contains the source data to instantiate the template.

Returns: MailMessageCollection - A MailMessageCollection that generated by the template and the datasource.

instantiate(DataRowCollection rows, DataColumnMappingCollection mappings)

public final MailMessageCollection instantiate(DataRowCollection rows, DataColumnMappingCollection mappings)

Instantiates the template with a DataRowCollection as datasource.

Parameters:

Parameter Type Description
rows DataRowCollection The DataRowCollection, which contains the source data to instantiate the template.
mappings DataColumnMappingCollection The IColumnMappingCollection, which represents the mapping between the source column in data source and target field in template

Returns: MailMessageCollection - A MailMessageCollection that generated by the template and the datasource.

instantiate(DataRowCollection rows)

public final MailMessageCollection instantiate(DataRowCollection rows)

Instantiates the template with a DataRowCollection as datasource.

Parameters:

Parameter Type Description
rows DataRowCollection The DataRowCollection, which contains the source data to instantiate the template.

Returns: MailMessageCollection - A MailMessageCollection that generated by the template and the datasource.

instantiate(IDataReader reader)

public final MailMessageCollection instantiate(IDataReader reader)

Instantiates the template with a IDataReader as datasource.

Parameters:

Parameter Type Description
reader IDataReader The IDataReader, which will provide the source data to instantiate the template.

Returns: MailMessageCollection - A MailMessageCollection that generated by the template and the datasource.