|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.softartisans.wordwriter.WordTemplate
An implemenation of WordWriter template functionality. Opens a WordWriter template file, populates it with data from a specified data source, and generates a new Word file. A WordWriter template is a file created in Microsoft Word that contains merge fields. A merge field displays a data source field name (for example, a database column name) where a data source value will be inserted. Merge fields are bound to a data source in code.
| Field Summary | |
static int |
ALL_ROWS
|
| Constructor Summary | |
WordTemplate()
Creates a new WordTemplate object. |
|
| Method Summary | |
java.lang.String[] |
getBookmarks()
Returns all bookmarks in this template. |
java.lang.String |
getContentType()
|
int |
getDocumentsCreatedToday()
|
java.lang.String[] |
getFieldMarkers()
Returns the names of all mergefields in this template. |
java.lang.String[] |
getFieldMarkers(java.lang.String aBookmark)
Returns the names of all mergefields contained within a specified bookmark |
java.lang.String |
getLicenseKey()
|
java.lang.String |
getVersion()
Returns the exact version of the WordWriter product. |
void |
open(java.io.InputStream templateStream)
Opens WordWriter template from an InputStream. |
void |
open(java.lang.String templateFileName)
Opens WordWriter template from a file on disk. |
void |
process()
Processes WordWriter template and populates MergeFields with data from the specified data source. |
void |
save(javax.servlet.http.HttpServletResponse response)
Sends generated Word binary file to the client's browser. |
void |
save(javax.servlet.http.HttpServletResponse response,
java.lang.String attachmentName,
boolean openInBrowser)
Sends generated Word binary file to the client's browser. |
void |
save(java.io.OutputStream outputStream)
Sends generated Word binary file to OutputStream. |
void |
save(java.lang.String outputFileName)
Saves generated Word binary file on disk. |
void |
setContentType(java.lang.String contentType)
Sets custom content type response parameter string used for streaming the resulting Word document to browser |
void |
setDataSource(java.lang.Object[] dataRow,
java.lang.String[] fieldNames)
Sets the default data source for the document's body to an array of objects. |
void |
setDataSource(java.lang.Object[] dataRow,
java.lang.String[] fieldNames,
java.lang.String name)
Sets a named data source for the document's body to an array of objects. |
void |
setDataSource(java.sql.ResultSet rs)
Sets the default data source for the document's body to Resultset passed as a parameter. |
void |
setDataSource(java.sql.ResultSet rs,
java.lang.String name)
Sets a named data source for the document's body to Resultset passed as a parameter. |
void |
setLicenseKey(java.lang.String licenseKey)
Instructs WordTemplate to use a particular license key for the duration of this instance, rather than obtaining one programatically from the License.jar file in the classpath. |
void |
setLocale(java.util.Locale locale)
Sets the formatting for dates, numbers and currency to the specified locale. |
void |
setRepeatBlock(java.lang.Object[][] jaggedArray,
java.lang.String[] columnNames,
java.lang.String bookmark)
Sets data source for the given repeat block to a jagged array of objects. |
void |
setRepeatBlock(java.lang.Object[][] jaggedArray,
java.lang.String[] columnNames,
java.lang.String bookmark,
int maxRows,
boolean transpose)
Sets data source for the given repeat block to a jagged array of objects. |
void |
setRepeatBlock(java.lang.Object[] dataRow,
java.lang.String[] fieldNames,
java.lang.String bookmark)
Sets data source for the given repeat block to an array of objects. |
void |
setRepeatBlock(java.sql.ResultSet rs,
java.lang.String bookmark)
Sets data source for the given repeat block (an arbitrary document fragment to be repeated with each row in a data source) to Resultset passed as a parameter. |
void |
setRepeatBlock(java.sql.ResultSet rs,
java.lang.String bookmark,
int maxRows)
Sets data source for the given repeat block (an arbitrary document fragment to be repeated with each row in a data source) to Resultset passed as a parameter. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int ALL_ROWS
| Constructor Detail |
public WordTemplate()
| Method Detail |
public void open(java.lang.String templateFileName)
throws java.io.FileNotFoundException,
java.lang.NullPointerException,
java.lang.SecurityException,
java.lang.Exception
templateFileName - file name for the WordWriter template to open
java.lang.NullPointerException - if an argument is null of empty string
java.io.FileNotFoundException - if path is invalid or file access denied
java.lang.SecurityException - if a security manager exists and its checkRead method denies read access to the template file
java.lang.Exception - if file is not a valid WordWriter template, or another error
public void open(java.io.InputStream templateStream)
throws java.lang.NullPointerException,
java.lang.Exception
templateStream - java.io.InputStream with WordWriter template.
java.lang.NullPointerException - if an argument is null
java.lang.Exception - if the stream does not contain a valid WordWriter template, or another errorpublic void setLocale(java.util.Locale locale)
locale - java.util.Locale, or null to set the Locale to system default
public void setDataSource(java.sql.ResultSet rs,
java.lang.String name)
throws java.sql.SQLException,
java.lang.Exception
rs - Resultset to be used as a data sourcename - The name of the data source. This is used for referencing the
data source in a field using the WordWriter field syntax.
1
java.sql.SQLException - if SQL error occurs
java.lang.Exception
public void setDataSource(java.sql.ResultSet rs)
throws java.sql.SQLException,
java.lang.Exception
rs - Resultset to be used as a data source
1
java.sql.SQLException - if SQL error occurs
java.lang.Exception
public void setDataSource(java.lang.Object[] dataRow,
java.lang.String[] fieldNames,
java.lang.String name)
throws java.lang.NullPointerException,
java.lang.Exception
null
dataRow - array of objectsfieldNames - Names of the objects in the arrayname - The name of the data source. This is used for referencing the
data source in a field using the WordWriter field syntax.
java.lang.NullPointerException - if dataRow or fieldNames is null or empty
java.lang.Exception - if dataRow is different length than fieldNames
public void setDataSource(java.lang.Object[] dataRow,
java.lang.String[] fieldNames)
throws java.lang.NullPointerException,
java.lang.Exception
null
dataRow - array of objectsfieldNames - Names of the objects in the array
java.lang.NullPointerException - if dataRow or fieldNames is null or empty
java.lang.Exception - if dataRow is different length than fieldNames
public void process()
throws java.lang.Exception
open and setDataSource and/or, setRepeatBlock and
optional setLocale must precede this call.
java.lang.Exception - if template is not open, data source not set, or if other error occurs
public void save(java.io.OutputStream outputStream)
throws java.lang.NullPointerException,
java.lang.Exception
outputStream - java.io.OutputStream
java.lang.NullPointerException - if an argument is null
java.lang.Exception - if an error occurs (due to invalid WordWriter Template file or otherwise).
public void save(java.lang.String outputFileName)
throws java.lang.NullPointerException,
java.io.FileNotFoundException,
java.lang.SecurityException,
java.lang.Exception
outputFileName - path for the output Word document file
java.lang.NullPointerException - if an argument is null
java.io.FileNotFoundException - if the output file can not be created or opened for writing
java.lang.SecurityException - if a security manager exists and its checkWrite method denies write access to the output file
java.lang.Exception - if a fatal error occurs (due to invalid WordWriter template file or otherwise).
public void save(javax.servlet.http.HttpServletResponse response)
throws java.lang.NullPointerException,
java.lang.Exception
response - javax.servlet.http.HttpServletResponse
java.lang.NullPointerException - if an argument is null
java.lang.Exception - if an error occurs
public void save(javax.servlet.http.HttpServletResponse response,
java.lang.String attachmentName,
boolean openInBrowser)
throws java.lang.NullPointerException,
java.lang.Exception
openInBrowser specifies if resulting document will be open in browser, or in stand-alone instance of Word or Word viewer.
Use this signature to explicitly specify the output file name and to control response content disposition.
response - javax.servlet.http.HttpServletResponseattachmentName - generated file name (passed to content disposition), or null for default file nameopenInBrowser - if true, sets content disposition to "inline". Resulting document will be opened
in the client's browser. If false, sets content disposition to "attachment". Resulting
documemnt will be opened in a stand-alone instance of Word or Word viewer.
java.lang.NullPointerException - if response is null
java.lang.Exception - if an error occurs.
public void setRepeatBlock(java.sql.ResultSet rs,
java.lang.String bookmark)
throws java.lang.NullPointerException,
java.lang.Exception
rs - Resultset to use as a data source for the given repeat blockbookmark - bookmark in the document template that marks the repeat block boundaries
java.lang.NullPointerException
java.lang.Exception
public void setRepeatBlock(java.sql.ResultSet rs,
java.lang.String bookmark,
int maxRows)
throws java.sql.SQLException,
java.lang.NullPointerException,
java.lang.Exception
rs - Resultset to use as a data source for the given repeat blockbookmark - bookmark in the document template that marks the repeat block boundariesmaxRows - the maximum number of data rows to be fetched from the data source
java.sql.SQLException
java.lang.NullPointerException
java.lang.Exception
public void setRepeatBlock(java.lang.Object[] dataRow,
java.lang.String[] fieldNames,
java.lang.String bookmark)
throws java.lang.NullPointerException,
java.lang.Exception
null
dataRow - array of objectsfieldNames - array of corresponding MergeField namesbookmark - bookmark in the document template that marks the repeat block boundaries
java.lang.NullPointerException
java.lang.Exception
public void setRepeatBlock(java.lang.Object[][] jaggedArray,
java.lang.String[] columnNames,
java.lang.String bookmark)
throws java.lang.NullPointerException,
java.lang.Exception
jaggedArray - array of objects. The first dimension is column index, the second dimension is a row indexcolumnNames - array of corresponding MergeField namesbookmark - bookmark in the document template that marks the repeat block boundaries
java.lang.NullPointerException
java.lang.Exception
public void setRepeatBlock(java.lang.Object[][] jaggedArray,
java.lang.String[] columnNames,
java.lang.String bookmark,
int maxRows,
boolean transpose)
throws java.lang.NullPointerException,
java.lang.Exception
jaggedArray - array of objects. The first dimension is column index, the second dimension is a row indexcolumnNames - array of corresponding MergeField namesbookmark - bookmark in the document template that marks the repeat block boundariesmaxRows - the maximum number of data rows to be fetched from the data sourcetranspose - set to true to have WordWriter interpret the source array as transposed, i.e.
first dimension is row, second dimension is column
java.lang.NullPointerException
java.lang.Exceptionpublic java.lang.String getVersion()
SoftArtisans.ProductName Edition Major.Minor.Patch.Build (mmddyyyy-hhmmss-buildMachineId)
where:
public java.lang.String getLicenseKey()
throws com.softartisans.wordwriter.LicenseKeyException
LicenseKeyException - if license key is not found or invalid
public void setLicenseKey(java.lang.String licenseKey)
throws java.lang.Exception
licenseKey - the license key to use for the duration of this instance.
java.lang.Exception - if the license key is invalid for any reason.public java.lang.String getContentType()
public void setContentType(java.lang.String contentType)
contentType - new Content Type stringpublic int getDocumentsCreatedToday()
public java.lang.String[] getBookmarks()
throws java.lang.Exception
java.lang.Exception - If open is not called first.
public java.lang.String[] getFieldMarkers()
throws java.lang.Exception
java.lang.Exception - If open is not called first.
public java.lang.String[] getFieldMarkers(java.lang.String aBookmark)
throws java.lang.Exception
aBookmark - The name of the bookmark that contains the mergefields.
java.lang.Exception - If open is not called first.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||