com.sas.servlet.beans
Class BaseTable

java.lang.Object
  |
  +--com.sas.Component
        |
        +--com.sas.servlet.beans.BaseTransformation
              |
              +--com.sas.servlet.beans.BaseTable
Direct Known Subclasses:
Table, Table

public abstract class BaseTable
extends BaseTransformation
implements TableInterface

Transformation bean base object for creating 2-dimensional table.

The Table Transformation Bean requires a model that implements com.sas.table.StaticTableInterface. If the model implements other interfaces they will be utilized as well:

com.sas.table.StaticColumnLabelInterface Used for accessing the column labels com.sas.table.StaticFormattedDataInterface Used for accessing the formatted data of the table (such as dates), as opposed to simply the raw data representation. com.sas.table.StaticColumnInfoInterface Used for accessing the meta data for the column.

Template are used to specify either the column formats for a row, or the template for the entire row. Column heading templates can also be supplied. Each template can embed column data using special markers (such as ## for the data from the current column, #<column name># for the data from a given column name, or #<column number># for the data from a given 1-based column index. Special meta data tags can also be used to retrieve information about the underlying table

Valid meta data tags are:

META_NAME The name of the column. If com.sas.table.StaticColumnInfoInterface is not supported the column name will be COLUMN, where is the 1-based column number. META_LABEL The label of the column. If com.sas.table.StaticColumnInfoInterface is not supported an IOException will be thrown. META_LENGTH The length of the column. If com.sas.table.StaticColumnInfoInterface is not supported an IOException will be thrown. META_FORMAT The format of the column. If com.sas.table.StaticColumnInfoInterface is not supported an IOException will be thrown. META_INFORMAT The informat of the column. If com.sas.table.StaticColumnInfoInterface is not supported an IOException will be thrown. META_ROWID The 1-based row number of the current row. This meta data tag is always supported.

For example, a simple 2-D table with no special formatting may set the columnFormat as:

setColumnFormat(" ## "); This would direct the Table Transformation Bean to insert the data from the current column between the markers, repeat for each column, and then repeat for each row.

See Also:
Serialized Form

Field Summary
static String MARKER
           
static String MARKER_ESC
           
static String MARKER_META
           
static String MARKER_META_ROWID
           
 
Constructor Summary
BaseTable()
           
 
Method Summary
protected  String formatRow(long rowNumber, String format)
          Replaces the markers (column names, index values, and meta data) with data from the model.
 String getBeginRowFormat()
          Gets the format to begin a new table row
 int getBorderWidth()
          Gets the width of the outer border around the table.
protected  String getCell(StaticTableInterface model, long row, int cell)
          Returns the string representation of the given cell from the current row in the table.
 int getCellPadding()
          Gets the number of pixels between the border of a cell and the cell's contents.
 int getCellSpacing()
          Gets the number of pixels between the border of each cell.
protected  int getColumnCount(StaticTableInterface model)
          Gets the number of columns in the current table
 String getColumnFormat()
          Gets the format to be applied to each data element in a row.
 String getColumnFormat(int index)
          Gets the format to be applied to a single data element in a row.
 String getColumnFormat(int columnIndex, long rowIndex)
          Gets the format to be applied to a single data element in the given row.
protected  String getColumnFormat(String format, int index)
          Replaces the default markers (those without a column name or index) with the given column index
 String getColumnHeadingColumnFormat()
          Gets the format to be applied to each column heading column
 String getColumnHeadingColumnFormat(int index)
          Gets the format to be applied to a single column heading column.
 String getColumnHeadingFormat()
          Gets the format for the column heading row.
protected  int getColumnIndex(StaticTableInterface model, String name)
          Returns the column index for the given column name
protected  int getColumnIndex(String s)
          Determine if the given string is a column index.
protected  Object getColumnInfo(StaticTableInterface model, int col, String columnInfoName)
          Returns the column info for the given column
 String getEndRowFormat()
          Gets the format to end table row
 long getMaxRows()
          Gets the maximum number of rows to be formatted when writing a table.
 Vector getRequiredInterfaces()
          Sets the required interface that a model must implement in order to attach to this bean.
 String getRowFormat()
          Gets the format for each row in the table.
 String getRowFormat(long index)
          Gets the format for the given row in the table.
 boolean getUseColumnHeadings()
          Returns true if column headings should be written.
 int getWidth()
          Gets the width of the table in pixels.
 int getWidthPercentage()
          Gets the width of the table as a percentage
protected  boolean hasRepeatingFormats()
          Determines if there are any repeating formats specified (either column or row)
 boolean isLastWriteTruncated()
          Determines if the last writing of a table exceeded the maximum number of rows.
protected  boolean isMetaTag(String tag)
          Determines if the given tag is a META tag
protected  boolean rowExists(StaticTableInterface model, long rowNumber)
          Determines if the given row exists
 void setBeginRowFormat(String format)
          Sets the format to begin a new table row
 void setBorderWidth(int border)
          Sets the width of the outer border around the table in pixels.
 void setCellPadding(int padding)
          Sets the number of pixels between the border of a cell and the cell's contents.
 void setCellSpacing(int spacing)
          Sets the number of pixels between the border of each cell.
 void setColumnFormat(String format)
          Sets the format to be applied to each data element in a row.
 void setColumnFormat(String format, int index)
          Sets the format to be applied to an individual data element in a row.
 void setColumnFormat(String format, int index, int repeatColumn)
          Sets the format to be applied to an individual data element in a row.
 void setColumnFormat(String format, int index, int repeatColumn, long startingRow, int repeatRow)
          Sets the format to be applied to an individual data element in the given row.
 void setColumnFormat(String format, int index, long startingRow, int repeatRow)
          Sets the format to be applied to an individual data element in the given row.
 void setColumnHeadingColumnFormat(String format)
          Sets the format to be applied to each column heading column.
 void setColumnHeadingColumnFormat(String format, int index)
          Sets the format to be applied to a single column heading column.
 void setColumnHeadingFormat(String format)
          Sets the format for the column heading row.
 void setEndRowFormat(String format)
          Sets the format to end a table row
 void setMaxRows(long n)
          Sets the maximum number of rows to be formatted when writing a table.
 void setModelInterface(ModelInterface newValue)
          Specifies the model to display in the view.
 void setRowFormat(String format)
          Sets the format for each row in the table.
 void setRowFormat(String format, long startingRow, int repeatRow)
          Sets the format for a given 1-based row number in the table.
 void setUseColumnHeadings(boolean enable)
          Turns on/off the use of column headings.
 void setWidth(int pixels)
          Sets the width of the table in pixels.
 void setWidthPercentage(int width)
          Sets the width of the table as a percentage
 void write(PrintWriter out)
          Writes the transformed representation of the object
 void writeColumnHeadings(OutputStream out)
          Writes the column headings
 void writeColumnHeadings(PrintWriter out)
          Writes the column headings
 void writeColumnHeadings(Writer out)
          Writes the column headings
 void writeRow(long row, OutputStream out)
          Writes a single row of the formatted table.
 void writeRow(long rowNumber, PrintWriter out)
          Writes a single row of the formatted table.
 void writeRow(long row, Writer out)
          Writes a single row of the formatted table.
protected  void writeTable(PrintWriter out)
          Formats and writes the contents of the entire table
 void writeTableFooter(OutputStream out)
          Writes the table footer
 void writeTableFooter(Writer out)
          Writes the table footer
 void writeTableHeader(OutputStream out)
          Writes the table header
 void writeTableHeader(Writer out)
          Writes the table header
 
Methods inherited from class com.sas.servlet.beans.BaseTransformation
getCustomAttributes, getDescription, getName, getParent, getRequest, getResponse, setCustomAttributes, setDescription, setName, setParent, setRequest, setResponse, toString, write, write, write
 
Methods inherited from class com.sas.Component
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, beansIsDesignTime, beansSetDesignTime, clone, clone, detachModel, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getExtendedBeanInfo, getLinkInfo, getModelInterface, getResources, getStringResource, getViewInterfaceSupportInfo, initialize, initializeComponent, isDesignTime, isLinked, propertyChange, queryLinks, queryLinks, refresh, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setComponentDescription, setComponentSupportInfo, setDefaultValues, setLinkInfo, setRequiredInterfaces, setViewInterfaceSupportInfo, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, validateObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MARKER

public static final String MARKER

MARKER_ESC

public static final String MARKER_ESC

MARKER_META

public static final String MARKER_META

MARKER_META_ROWID

public static final String MARKER_META_ROWID
Constructor Detail

BaseTable

public BaseTable()
Method Detail

getRequiredInterfaces

public Vector getRequiredInterfaces()
Sets the required interface that a model must implement in order to attach to this bean. Models must implement com.sas.table.StaticTableInterface in order to be used by this transformation bean
Returns:
An array of interface names
Overrides:
getRequiredInterfaces in class Component

setModelInterface

public void setModelInterface(ModelInterface newValue)
Specifies the model to display in the view. Models must implement com.sas.table.StaticTableInterface in order to be used by this transformation bean Pass null to disassociate the view from its model.
Parameters:
newValue - The new value to assign the modelInterface property.
Overrides:
setModelInterface in class Component

setMaxRows

public void setMaxRows(long n)
Sets the maximum number of rows to be formatted when writing a table. A value of -1 indicates no maximum
Specified by:
setMaxRows in interface TableInterface
Parameters:
max - The maximum number of rows

getMaxRows

public long getMaxRows()
Gets the maximum number of rows to be formatted when writing a table.
Specified by:
getMaxRows in interface TableInterface
Returns:
The maximum number of rows, or -1 for unlimited

isLastWriteTruncated

public boolean isLastWriteTruncated()
Determines if the last writing of a table exceeded the maximum number of rows.
Specified by:
isLastWriteTruncated in interface TableInterface
Returns:
true if the table was truncated

setRowFormat

public void setRowFormat(String format)
Sets the format for each row in the table. The exact details of the format are implementation-specific. Tags can be used as markers for variable data read out of a database table. Markers can supply either a column name, such as #NAME#, or a 1-based column index, such as #1#. Database meta data can be used with the markers #META_NAME <column>#, #META_LABEL <column>#, and #META_LENGTH <column>#. Setting the rowFormat will override the columnFormat.
Specified by:
setRowFormat in interface TableInterface
Parameters:
format - The format string

getRowFormat

public String getRowFormat()
Gets the format for each row in the table. null indicates that a columnFormat is being used
Specified by:
getRowFormat in interface TableInterface
Returns:
The format string

setRowFormat

public void setRowFormat(String format,
                         long startingRow,
                         int repeatRow)
Sets the format for a given 1-based row number in the table. This method also allows the format to be repeated every 'n' rows. Setting the rowFormat for a row will override the global format set by setRowFormat(String format). If a conflict exists when repeating rows (mulitple setRowFormat calls apply to the same row), the first format that was set will be applied.
Specified by:
setRowFormat in interface TableInterface
Parameters:
format - The format string, or null to remove the format
startingRow - The 1-based row number that will first use the format
repeatRow - The number of rows until the format is repeated, or -1 for no repeating.

getRowFormat

public String getRowFormat(long index)
Gets the format for the given row in the table. null indicates that no format was specified for the specific row; getRowFormat() can be used to query whether a global row format was set.
Specified by:
getRowFormat in interface TableInterface
Parameters:
index - The 1-based row index
Returns:
The format string

setBeginRowFormat

public void setBeginRowFormat(String format)
Sets the format to begin a new table row
Specified by:
setBeginRowFormat in interface TableInterface
Parameters:
The - format string

getBeginRowFormat

public String getBeginRowFormat()
Gets the format to begin a new table row
Specified by:
getBeginRowFormat in interface TableInterface
Returns:
The format string

setColumnFormat

public void setColumnFormat(String format)
Sets the format to be applied to each data element in a row. Use regular parameter markers with no name or index to indicate the location of the data (such as ##, or #META_NAME#). Setting the columnFormat will override the rowFormat.
Specified by:
setColumnFormat in interface TableInterface
Parameters:
format - The format string to be applied to each data element

setColumnFormat

public void setColumnFormat(String format,
                            int index)
Sets the format to be applied to an individual data element in a row. Use regular parameter markers with no name or index to indicate the location of the data (such as ##, or #META_NAME#). Only valid if the rowFormat is not currently in use.
Specified by:
setColumnFormat in interface TableInterface
Parameters:
format - The format string to be applied to a single data element, or null to remove the format
index - The 1-based column index, or -1 for all columns

setColumnFormat

public void setColumnFormat(String format,
                            int index,
                            int repeatColumn)
Sets the format to be applied to an individual data element in a row. This method also allows the format to be repeated every 'n' columns. Only valid if the rowFormat is not currently in use.
Specified by:
setColumnFormat in interface TableInterface
Parameters:
format - The format string to be applied to a single data element, or null to remove the format
index - The 1-based column index that will first use the format
repeatColumn - The number of columns until the format is repeated, or -1 for no repeating

setColumnFormat

public void setColumnFormat(String format,
                            int index,
                            long startingRow,
                            int repeatRow)
Sets the format to be applied to an individual data element in the given row. This method also allows the format to be repeated every 'n' rows. Only valid if the rowFormat is not currently in use.
Specified by:
setColumnFormat in interface TableInterface
Parameters:
format - The format string to be applied to a single data element, or null to remove the format
index - The 1-based column index or -1 for all columns
startingRow - The 1-based row number that will first use the format
repeatRow - The number of rows until the format is repeated, or -1

setColumnFormat

public void setColumnFormat(String format,
                            int index,
                            int repeatColumn,
                            long startingRow,
                            int repeatRow)
Sets the format to be applied to an individual data element in the given row. This method also allows the format to be repeated every 'n' columns and every 'n' rows. Only valid if the rowFormat is not currently in use.
Specified by:
setColumnFormat in interface TableInterface
Parameters:
format - The format string to be applied to a single data element, or null to remove the format
index - The 1-based column index or -1 for all columns
repeatColumn - The number of columns until the format is repeated, or -1 for no repeating
startingRow - The 1-based row number that will first use the format
repeatRow - The number of rows until the format is repeated, or -1 for no repeating

getColumnFormat

public String getColumnFormat(int index)
Gets the format to be applied to a single data element in a row. Returns null if a format has not been applied to the given column.
Specified by:
getColumnFormat in interface TableInterface
Parameters:
index - The 1-based column index
Returns:
The format string

getColumnFormat

public String getColumnFormat(int columnIndex,
                              long rowIndex)
Gets the format to be applied to a single data element in the given row. Returns null if a format has not been applied to the given column.
Specified by:
getColumnFormat in interface TableInterface
Parameters:
columnIndex - The 1-based column index
rowIndex - The 1-based row index
Returns:
The format string

getColumnFormat

public String getColumnFormat()
Gets the format to be applied to each data element in a row.
Specified by:
getColumnFormat in interface TableInterface
Returns:
The format string

setEndRowFormat

public void setEndRowFormat(String format)
Sets the format to end a table row
Specified by:
setEndRowFormat in interface TableInterface
Parameters:
The - format string

getEndRowFormat

public String getEndRowFormat()
Gets the format to end table row
Specified by:
getEndRowFormat in interface TableInterface
Returns:
The format string

write

public void write(PrintWriter out)
           throws IOException
Writes the transformed representation of the object
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs
Overrides:
write in class BaseTransformation

writeTable

protected void writeTable(PrintWriter out)
                   throws IOException
Formats and writes the contents of the entire table
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

hasRepeatingFormats

protected boolean hasRepeatingFormats()
Determines if there are any repeating formats specified (either column or row)

rowExists

protected boolean rowExists(StaticTableInterface model,
                            long rowNumber)
Determines if the given row exists
Parameters:
rowNumber - The 1-based row to check

writeRow

public void writeRow(long rowNumber,
                     PrintWriter out)
              throws IOException
Writes a single row of the formatted table. The data from the current row in the table will be used.
Specified by:
writeRow in interface TableInterface
Parameters:
row - The 1-based row number to write
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

getColumnCount

protected int getColumnCount(StaticTableInterface model)
                      throws IOException
Gets the number of columns in the current table
Parameters:
model - The table model
Returns:
The number of columns
Throws:
IOException - Thrown if some type of I/O error occurs

writeColumnHeadings

public void writeColumnHeadings(PrintWriter out)
                         throws IOException
Writes the column headings
Specified by:
writeColumnHeadings in interface TableInterface
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

getColumnFormat

protected String getColumnFormat(String format,
                                 int index)
Replaces the default markers (those without a column name or index) with the given column index
Parameters:
format - The data format
index - The 1-based column index

formatRow

protected String formatRow(long rowNumber,
                           String format)
                    throws IOException
Replaces the markers (column names, index values, and meta data) with data from the model. Data from the current row of the model will be used.
Parameters:
row - The 1-based row number to write
format - The data format
Throws:
IOException - Thrown if some type of I/O error occurs

getColumnInfo

protected Object getColumnInfo(StaticTableInterface model,
                               int col,
                               String columnInfoName)
                        throws IOException
Returns the column info for the given column
Parameters:
model - The table model
column - The 1-based column number
columnInfoName - The info to gather
Throws:
IOException - Thrown if some type of I/O error occurs

getColumnIndex

protected int getColumnIndex(StaticTableInterface model,
                             String name)
                      throws IOException
Returns the column index for the given column name
Parameters:
model - The table model
name - The column name
Returns:
The 1-based column index
Throws:
IOException - Thrown if some type of I/O error occurs

getCell

protected String getCell(StaticTableInterface model,
                         long row,
                         int cell)
                  throws IOException
Returns the string representation of the given cell from the current row in the table.
Parameters:
model - The table model
row - The 1-based row number
cell - The 1-based cell number
Returns:
The string representation of the cell
Throws:
IOException - Thrown if some type of I/O error occurs

isMetaTag

protected boolean isMetaTag(String tag)
Determines if the given tag is a META tag

getColumnIndex

protected int getColumnIndex(String s)
Determine if the given string is a column index. If not, return -1

writeRow

public void writeRow(long row,
                     Writer out)
              throws IOException
Writes a single row of the formatted table. The data from the current row in the table will be used.
Parameters:
row - The 1-based row number to write
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

writeRow

public void writeRow(long row,
                     OutputStream out)
              throws IOException
Writes a single row of the formatted table. The data from the current row in the table will be used.
Parameters:
row - The 1-based row number to write
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

writeColumnHeadings

public void writeColumnHeadings(Writer out)
                         throws IOException
Writes the column headings
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

writeColumnHeadings

public void writeColumnHeadings(OutputStream out)
                         throws IOException
Writes the column headings
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

writeTableHeader

public void writeTableHeader(Writer out)
                      throws IOException
Writes the table header
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

writeTableHeader

public void writeTableHeader(OutputStream out)
                      throws IOException
Writes the table header
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

writeTableFooter

public void writeTableFooter(Writer out)
                      throws IOException
Writes the table footer
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

writeTableFooter

public void writeTableFooter(OutputStream out)
                      throws IOException
Writes the table footer
Parameters:
out - The output stream
Throws:
IOException - Thrown if some type of I/O error occurs

setWidth

public void setWidth(int pixels)
Sets the width of the table in pixels.
Specified by:
setWidth in interface TableInterface
Parameters:
width - The width in pixels

getWidth

public int getWidth()
Gets the width of the table in pixels.
Specified by:
getWidth in interface TableInterface
Returns:
The width in pixels

setWidthPercentage

public void setWidthPercentage(int width)
Sets the width of the table as a percentage
Specified by:
setWidthPercentage in interface TableInterface
Parameters:
width - The width as a percentage

getWidthPercentage

public int getWidthPercentage()
Gets the width of the table as a percentage
Specified by:
getWidthPercentage in interface TableInterface
Returns:
The width as a percentage

setBorderWidth

public void setBorderWidth(int border)
Sets the width of the outer border around the table in pixels. The default is 0.
Specified by:
setBorderWidth in interface TableInterface
Parameters:
border - The border width in pixels

getBorderWidth

public int getBorderWidth()
Gets the width of the outer border around the table.
Specified by:
getBorderWidth in interface TableInterface
Returns:
The border width in pixels

setCellSpacing

public void setCellSpacing(int spacing)
Sets the number of pixels between the border of each cell. The default is 1.
Specified by:
setCellSpacing in interface TableInterface
Parameters:
spacing - The number of pixels between each cell

getCellSpacing

public int getCellSpacing()
Gets the number of pixels between the border of each cell.
Specified by:
getCellSpacing in interface TableInterface
Returns:
The number of pixels between each cell

setCellPadding

public void setCellPadding(int padding)
Sets the number of pixels between the border of a cell and the cell's contents. The default is 0.
Specified by:
setCellPadding in interface TableInterface
Parameters:
padding - The number of pixels between the cell border and the cell content

getCellPadding

public int getCellPadding()
Gets the number of pixels between the border of a cell and the cell's contents.
Specified by:
getCellPadding in interface TableInterface
Returns:
The number of pixels between the cell border and the cell content

setColumnHeadingColumnFormat

public void setColumnHeadingColumnFormat(String format)
Sets the format to be applied to each column heading column. Use regular parameter markers with no name or index to indicate the location of the meta data (such as #META_NAME#). Setting the columnHeadingColumnFormat will override the columnHeadingFormat.
Specified by:
setColumnHeadingColumnFormat in interface TableInterface
Parameters:
The - column heading column format

setColumnHeadingColumnFormat

public void setColumnHeadingColumnFormat(String format,
                                         int index)
Sets the format to be applied to a single column heading column. Use regular parameter markers with no name or index to indicate the location of the meta data (such as #META_NAME#). Only valid if the rowFormat is not currently in use
Specified by:
setColumnHeadingColumnFormat in interface TableInterface
Parameters:
The - column heading column format to be applied to a single column, or null to remove the format
index - The 1-based column index

getColumnHeadingColumnFormat

public String getColumnHeadingColumnFormat(int index)
Gets the format to be applied to a single column heading column. Returns null if a format has not been applied to the given column
Specified by:
getColumnHeadingColumnFormat in interface TableInterface
Parameters:
index - The 1-based column index
Returns:
The column heading column format

getColumnHeadingColumnFormat

public String getColumnHeadingColumnFormat()
Gets the format to be applied to each column heading column
Specified by:
getColumnHeadingColumnFormat in interface TableInterface
Returns:
The column heading column format

setColumnHeadingFormat

public void setColumnHeadingFormat(String format)
Sets the format for the column heading row.
Specified by:
setColumnHeadingFormat in interface TableInterface
Parameters:
The - column heading format

getColumnHeadingFormat

public String getColumnHeadingFormat()
Gets the format for the column heading row.
Specified by:
getColumnHeadingFormat in interface TableInterface
Returns:
The column heading format

setUseColumnHeadings

public void setUseColumnHeadings(boolean enable)
Turns on/off the use of column headings. The default is false.
Specified by:
setUseColumnHeadings in interface TableInterface
Parameters:
enable - true if headings should be written

getUseColumnHeadings

public boolean getUseColumnHeadings()
Returns true if column headings should be written.
Specified by:
getUseColumnHeadings in interface TableInterface
Parameters:
true - if headings should be written


Version: 1.2.20000317.001 Formatted: 2000/07/06 15:57:33PM