com.actuate.ExternalText
Class TextEntryList

java.lang.Object
  extended bycom.actuate.ExternalText.TextEntryList

public class TextEntryList
extends java.lang.Object

This is the main interface to retrieving externalized text fields from a database through JDBC. The general calling sequence is:

TextEntryList() constructor

connectDB() to specify the JDBC connection parameters

setAttribute() to specify anything that will be substituted into the SQL string placeholders later on (locale, reportname, etc)

addList() to specify all of the text keys to lookup in one shot

addStringKey() alternatively to specify a single lookup key that is character based

addIntKey alternatively to specify a single lookup key that is a number

translate() to specify the generic SQL query and cause a lookup of whatever keys have been added so far

next() to iterate through the retruned resultset rows

getString() and getInt() to get the specific returned fields on the current row

disconnectDB to close the DBconnection


Constructor Summary
TextEntryList()
          Creates a new instance of TextEntryList.
 
Method Summary
 void addIntKey(int intKeyName)
          Adds a single integer (label) key.
 void addList(java.lang.String MultipleKeyNames)
          Adds an entire list of keys.
 void addStringKey(java.lang.String textKeyName)
          Adds a single text (label) key.
 void connectDB()
          Establishes a JDBC connection to the database.
 void disconnectDB()
          Closes the current DB resultset, statement, and disconnects from the database.
 int getInt(java.lang.String colName)
          Gets a specific integer value back from the current resultset row.
 java.lang.String getString(java.lang.String colName)
          Gets a specific string value back from the current resultset row.
 boolean next()
          Allows iterating through the resultset rows of translated labels.
 void setAttribute(java.lang.String attributeName, java.lang.String attributeValue)
          Sets an attribute for later substitution into the SQL string.
 void translate()
          Provides the generic SQL string with attribute placeholders, and executes the translation SQL query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextEntryList

public TextEntryList()
              throws java.io.FileNotFoundException,
                     java.io.IOException
Creates a new instance of TextEntryList.

This also causes the reading in of important properties from a properties file; ActuateI18NText.properties

The properties that need to be in this file are:

actuate.externText.JDBCDriverName

actuate.externText.JDBCConnectionURL

actuate.externText.username

actuate.externText.password

actuate.externText.SQLString - This is the generic version of the SQL that is used to lookup the external text. When specifying this input SQL string, there should be placeholder for each attribute that you set using setAttribute, and a special placeholder of ":_TextList:" to be the placeholder for the list of textkeys that was formed by calls to addStringKey, addIntKey, or addList.

Method Detail

connectDB

public void connectDB()
               throws java.sql.SQLException,
                      java.lang.ClassNotFoundException
Establishes a JDBC connection to the database.

Returns:
void
Throws:
java.sql.SQLException
java.lang.ClassNotFoundException

disconnectDB

public void disconnectDB()
                  throws java.sql.SQLException
Closes the current DB resultset, statement, and disconnects from the database.

Returns:
void
Throws:
java.sql.SQLException

addStringKey

public void addStringKey(java.lang.String textKeyName)
Adds a single text (label) key. This method is generally used repetitively to build up a list of label "keys" that will ultimately be used in the whereclause of the SQL that is retrieving translated labels.

A label key should be a unique identifier for the text of a label to be translated. Sometimes this database table key field will be stored in a character (like varchar) format, and sometimes it will be an integer. use this particular method if it stored in character format. Further processing will automatically put quotes around each string key that is submitted, and comma delimit them in order to form the final SQL.

Example: addStringKey( "Work Order") will ultimately look up the one label called "Work Order" in the translation table for the appropriate locale.

Parameters:
textKeyName - A string field to be used as a key in the SQL lookup for translation.
Returns:
void

addIntKey

public void addIntKey(int intKeyName)
Adds a single integer (label) key. This method is generally used repetitively to build up a list of label "keys" that will ultimately be used in the whereclause of the SQL that is retrieving translated labels.

A label key should be a unique identifier for the text of a label to be translated. Sometimes this database table key field will be stored in a character (like varchar) format, and sometimes it will be an integer. use this particular method if it stored in integer format. Further processing will automatically put these together in order to form the final SQL.

Example: addIntKey( 1231 ) will ultimately look up the one label called with key 1231 in the translation table for the appropriate locale.

Parameters:
intKeyName - An integer field to be used as a key in the SQL lookup for translation.
Returns:
void

addList

public void addList(java.lang.String MultipleKeyNames)
Adds an entire list of keys. This method is generally used by itself to build up a list of label "keys" that will ultimately be used in the whereclause of the SQL that is retrieving translated labels.

A label key should be a unique identifier for the text of a label to be translated.

Example: addList( "1231,1232,1233,1234") will ultimately look up these four integer-keyed labels. in the translation table for the appropriate locale.

Example: addList( "\'Work Order\',\'Due Date\',\'Authorized By\'") will ultimately look up these three test-keyed labels. The single quote is mandatory for SQL and the backslash escape syntax shown is Java-specific. Actuate Basic can drop the backslashes.

Parameters:
MultipleKeyNames - A String list of keys to be used as is in the SQL lookup for translation.
Returns:
void

setAttribute

public void setAttribute(java.lang.String attributeName,
                         java.lang.String attributeValue)
Sets an attribute for later substitution into the SQL string.

This method is generally called repetitively to specify attributes such as Locale or Language, ReportName, etc. When specifying the SQL string as a parameter to the translate method, the attribute names should appear within colons. For example: ":Locale:".

Parameters:
attributeName - The name for this attribute, eg. "Locale"
attributeValue - The value for this attribute, eg. "de_DE"
Returns:
void

translate

public void translate()
               throws java.sql.SQLException
Provides the generic SQL string with attribute placeholders, and executes the translation SQL query.

This method is called once to execute the translation SQL.

Returns:
void
Throws:
java.sql.SQLException

next

public boolean next()
             throws java.sql.SQLException
Allows iterating through the resultset rows of translated labels.

This method is called in a loop to increment the internal cursor that is kept on the resulting rows of translated labels and returns true while there are still rows to process. For each of these method executions, you should use getString() and getInt() methods to get the specific fields from the query.

Returns:
true if there's another row and false if past last row.
Throws:
java.sql.SQLException

getString

public java.lang.String getString(java.lang.String colName)
                           throws java.sql.SQLException
Gets a specific string value back from the current resultset row.

This method is generally called repetitively (and with getInt) to get the individual fields back from the resultset row. An example call might be: getString("TranslatedLabel"); or getString("FontFaceName");

Parameters:
colName - The name of the column to get from this resultset row. This must correspond exactly (case insensitive) with a column that is being returned by the SQL statement.
Returns:
String value of this field for the current resultset row.
Throws:
java.sql.SQLException

getInt

public int getInt(java.lang.String colName)
           throws java.sql.SQLException
Gets a specific integer value back from the current resultset row.

This method is generally called repetitively (and with getString) to get the individual fields back from the resultset row. An example call might be: getInt("FieldWidth"); or getInt("FontSize");

Parameters:
colName - The name of the column to get from this resultset row. This must correspond exactly (case insensitive) with a column that is being returned by the SQL statement.
Returns:
Integer value of this field for the current resultset row.
Throws:
java.sql.SQLException