org.ujac.print.tag
Class PrintTableTag

java.lang.Object
  extended by org.ujac.print.BaseDocumentTag
      extended by org.ujac.print.tag.BaseElementTag
          extended by org.ujac.print.tag.BaseLoopTag
              extended by org.ujac.print.tag.PrintTableTag
All Implemented Interfaces:
CommonAttributesHolder, Condition, DocumentEventRecorder, FontHolder, PdfCellContainer, PdfTableHolder, StyleHolder

public class PrintTableTag
extends BaseLoopTag
implements PdfCellContainer, PdfTableHolder, FontHolder, Condition, StyleHolder

Name: PrintTableTag
Description: A class iterating over a given table and repeats the nested body for each element of the table.

Author:
lauerc

Nested Class Summary
 class PrintTableTag.DummyColumn
          Name: DummyColumn
Description: A class for dummy columns which are added through the insert-column tag.
 
Field Summary
static int DIRECTION_AFTER
          Constant for the insert direction 'after'.
static int DIRECTION_BEFORE
          Constant for the insert direction 'before'.
static int MAX_SEGMENT_SIZE
          The maximum number of lines for a table segment.
protected  boolean outputStarted
          Tells whether the output has already been started or not.
static String TAG_NAME
          The item's name.
 
Fields inherited from class org.ujac.print.tag.BaseLoopTag
insertItems, iterationIdx, sequenceHolder, sequenceIterator
 
Fields inherited from class org.ujac.print.BaseDocumentTag
actualContent, attributes, condition, content, customAttributes, DEFAULT_FONT, DEFAULT_FONT_COLOR, DEFAULT_FONT_ENCODING, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FONT_STYLE, DEFAULT_LEADING, DEFAULT_LINE_SPACING, depth, documentHandler, IMAGE_CHUNK_ATTR, log, NUMBER_OF_PAGES_TEMPLATES, parentItem, previousItem, styleParent, supportedAttributeMap, supportedChildMap, supportedStyleAttributeMap, tagFactory
 
Constructor Summary
PrintTableTag()
          Constructs a PrintTableTag instance with no specific attributes.
 
Method Summary
 void addCell(BaseDocumentTag item, com.lowagie.text.pdf.PdfPCell cell)
          Adds a cell to the table.
 void addHeaderCell(BaseDocumentTag item, com.lowagie.text.pdf.PdfPCell cell)
          Adds a header cell to the table.
 void alterColumn(String name, float width, int hAlign, String title, String defaultContents)
          Alters a column at the table.
protected  AttributeDefinitionMap buildSupportedAttributes()
          Gets the list of supported attributes.
 ChildDefinitionMap buildSupportedChilds()
          Gets the list of supported childs.
protected  AttributeDefinitionMap buildSupportedStyleAttributes()
          Gets the list of supported style attributes.
 void closeItem()
          Closes the item.
 void defineColumn(String name, float width, int hAlign, String title, String defaultContents)
          Defines a column for the table.
 boolean fitsPage()
          Checks whether the table fits the current page or not.
 CellAttributes getCellAttributes()
          Gets the cell attributes.
protected  int getColumnIndex(String columnName)
          Gets the index of the given column.
protected  String getDefaultContent(int idx)
          Gets the default contents for the given column.
 String getDescription()
          Gets a brief description for the item.
 float getLeading()
          Gets the leading.
 float getLineSpacing()
          Gets the line spacing.
 int getNumColumns()
          Gets the number of columns by row to print.
 int getNumContentRows()
          Gets the number of content rows, that have been added to the current table so far.
protected  int getNumRows()
          Gets the number of rows, printed so far within the current row segment.
 PdfTableHolder getPdfTable()
          Gets the PDF table holder.
 int getRemainingPdfColumns()
          Gets the number of remaining columns of the current row.
protected  com.lowagie.text.pdf.PdfPTable getTable()
          Gets the PDF table.
 Column[] getVisibleColumns()
          Gets all visible columns.
 void initialize()
          Initializes the item.
 void insertColumn(String name, float width, int hAlign, String title, String reference, int direction, String defaultContents)
          Inserts a column into the table.
 boolean isOutputStarted()
          Checks whether the table output has been started or not.
 boolean isStyleable()
          Tells whether or not this tag does respect style attributes or not.
 boolean isTextBodyAllowed()
          Tells whether textual content is allowed for the tag or not.
 void openItem()
          Opens the item.
 void openItem(boolean resetData)
          Opens the item.
protected  void postLoopChildItems()
          Method called after the child items are printed.
protected  void postRepeatChildItems()
          Post-processes the child items of the foreach item.
protected  void preLoopChildItems()
          Method called before the child items are printed.
protected  boolean preRepeatChildItems()
          Pre-processes the child items of the foreach item.
 void removeColumn(String name)
          Removes a column from the table.
 boolean splitTable(boolean newPage, boolean keepHeader)
          Splits the table vertically.
 
Methods inherited from class org.ujac.print.tag.BaseLoopTag
getCurrentValue, getLoopIdxVariable, getLoopVariable, getSequenceHolder, hasNext, isFirstLoop, isTrue, recordEvent, repeatChildItems, setCurrentValue, setLoopVariable, setSequenceHolder
 
Methods inherited from class org.ujac.print.tag.BaseElementTag
getElementContainer
 
Methods inherited from class org.ujac.print.BaseDocumentTag
addAttributeDefinition, addChunk, addChunk, addChunk, addContent, addContent, addStyleAttributeDefinition, addToLatestCellContainer, addToLatestElementContainer, addToLatestPdfCellContainer, checkAttributes, colorFromString, createChunk, createFont, ensureNumberOfPagesTemplate, evalAttribute, evalAttribute, extendLeading, extendLeading, extendLeading, extendLeading, filterContents, flushContent, getActualContent, getAttribute, getAttribute, getAttributeDefinition, getAttributeHandler, getAttributes, getBackgroundColor, getBooleanAttribute, getBooleanAttribute, getBorderAttribute, getBorderAttribute, getColorAttribute, getColorAttribute, getCommonAttributesHolder, getContent, getCustomAttributes, getDepth, getDimensionAttribute, getDimensionAttribute, getDimensionAttribute, getDocumentHandler, getExamples, getFloatAttribute, getFloatAttribute, getFont, getHorizontalAlignmentAttribute, getHorizontalAlignmentAttribute, getIntegerAttribute, getIntegerAttribute, getLocalAttribute, getLocalFont, getLocalStyleAttribute, getName, getParentItem, getPhraseContent, getPhraseHeight, getPhraseWidth, getPreviousItem, getRawAttribute, getSortedAttributeDefinitions, getSortedStyleAttributeDefinitions, getStringAttribute, getStringAttribute, getStringAttribute, getStyle, getStyleAttribute, getStyleAttribute, getStyleAttributeDefinition, getStyleAttributes, getStyleClass, getSupportedAttributes, getSupportedChilds, getSupportedChildTags, getSupportedStyleAttributes, getTagFactory, getTextAttribute, getTextAttribute, getTrimmedContent, getVerticalAlignmentAttribute, getVerticalAlignmentAttribute, handleContent, handleFontAttributes, hasContent, int2FontStyle, isAttributeDefined, isAttributeDefined, isAttributeDefined, isAttributeDefined, isAttributeSupported, isAttributeSupported, isAttributeSupported, isAttributeSupported, isDocumentRoot, isEmptyContent, isEmptyString, isIgnoreFlush, isItemClosed, isItemOpened, isPhraseEmpty, isRendered, isStructureChecksDisabled, isStyleAttributeDefined, isTrimBody, isTrimNextHead, isValid, isVirtualContainer, locator, preInitialize, printPhrase, processContents, processContents, resetContent, rotatePhrase, setAttributes, setBackgroundColor, setCustomAttributes, setDepth, setDocumentHandler, setItemClosed, setItemOpened, setLocalFont, setLocalFont, setName, setParentItem, setPreviousItem, setTagFactory, setTrimBody, setTrimNextHead, trimContentHead, trimContentTail, typeCastValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ujac.print.FontHolder
getFont
 
Methods inherited from interface org.ujac.print.Condition
isTrue
 
Methods inherited from interface org.ujac.print.StyleHolder
getStyleAttribute
 

Field Detail

DIRECTION_BEFORE

public static final int DIRECTION_BEFORE
Constant for the insert direction 'before'.

See Also:
Constant Field Values

DIRECTION_AFTER

public static final int DIRECTION_AFTER
Constant for the insert direction 'after'.

See Also:
Constant Field Values

TAG_NAME

public static final String TAG_NAME
The item's name.

See Also:
Constant Field Values

MAX_SEGMENT_SIZE

public static final int MAX_SEGMENT_SIZE
The maximum number of lines for a table segment. In case this size is reached, an automnatic table split is performed to keep the memory consumption low.

See Also:
Constant Field Values

outputStarted

protected boolean outputStarted
Tells whether the output has already been started or not.

Constructor Detail

PrintTableTag

public PrintTableTag()
Constructs a PrintTableTag instance with no specific attributes.

Method Detail

getDescription

public String getDescription()
Gets a brief description for the item.

Specified by:
getDescription in class BaseDocumentTag
Returns:
The item's description.

buildSupportedAttributes

protected AttributeDefinitionMap buildSupportedAttributes()
Gets the list of supported attributes.

Overrides:
buildSupportedAttributes in class BaseElementTag
Returns:
The attribute definitions.

buildSupportedStyleAttributes

protected AttributeDefinitionMap buildSupportedStyleAttributes()
Gets the list of supported style attributes.

Overrides:
buildSupportedStyleAttributes in class BaseDocumentTag
Returns:
The attribute definitions.

buildSupportedChilds

public ChildDefinitionMap buildSupportedChilds()
Gets the list of supported childs.

Overrides:
buildSupportedChilds in class BaseDocumentTag
Returns:
The child definitions.

isStyleable

public boolean isStyleable()
Tells whether or not this tag does respect style attributes or not.

Overrides:
isStyleable in class BaseDocumentTag
Returns:
always true.

isTextBodyAllowed

public boolean isTextBodyAllowed()
Tells whether textual content is allowed for the tag or not.

Overrides:
isTextBodyAllowed in class BaseDocumentTag
Returns:
true if the item is allowed to contain textual content, else false.

getVisibleColumns

public Column[] getVisibleColumns()
Gets all visible columns.

Returns:
An array holding all visible columns.

initialize

public void initialize()
                throws DocumentHandlerException
Initializes the item.

Overrides:
initialize in class BaseLoopTag
Throws:
DocumentHandlerException - If something went badly wrong.

openItem

public void openItem()
              throws DocumentHandlerException
Opens the item.

Overrides:
openItem in class BaseLoopTag
Throws:
DocumentHandlerException - Thrown in case something went wrong while opening the foreach item.

openItem

public void openItem(boolean resetData)
              throws DocumentHandlerException
Opens the item.

Parameters:
resetData - tells whether to reset some specific data or not (don't blame for this silly comment).
Throws:
DocumentHandlerException - Thrown in case something went wrong while opening the document item.

closeItem

public void closeItem()
               throws DocumentHandlerException
Closes the item.

Overrides:
closeItem in class BaseLoopTag
Throws:
DocumentHandlerException - Thrown in case something went wrong while closing the foreach item.

preRepeatChildItems

protected boolean preRepeatChildItems()
                               throws DocumentHandlerException
Pre-processes the child items of the foreach item.

Overrides:
preRepeatChildItems in class BaseLoopTag
Returns:
Tells, whether or not to repeat the child items, returning false skips the execution for the current item.
Throws:
DocumentHandlerException - Thrown in case something went wrong.

postRepeatChildItems

protected void postRepeatChildItems()
                             throws DocumentHandlerException
Post-processes the child items of the foreach item.

Overrides:
postRepeatChildItems in class BaseLoopTag
Throws:
DocumentHandlerException - Thrown in case something went wrong.

preLoopChildItems

protected void preLoopChildItems()
                          throws DocumentHandlerException
Method called before the child items are printed.

Overrides:
preLoopChildItems in class BaseLoopTag
Throws:
DocumentHandlerException - Thrown in case something went wrong.

postLoopChildItems

protected void postLoopChildItems()
                           throws DocumentHandlerException
Method called after the child items are printed.

Overrides:
postLoopChildItems in class BaseLoopTag
Throws:
DocumentHandlerException - Thrown in case something went wrong.

getDefaultContent

protected String getDefaultContent(int idx)
Gets the default contents for the given column.

Parameters:
idx - The index of the column to get the default contents for.
Returns:
The index of the column.

isOutputStarted

public boolean isOutputStarted()
Checks whether the table output has been started or not.

Returns:
true if the table output has been started, else false.

addCell

public void addCell(BaseDocumentTag item,
                    com.lowagie.text.pdf.PdfPCell cell)
             throws DocumentHandlerException
Adds a cell to the table.

Specified by:
addCell in interface PdfCellContainer
Parameters:
item - The tag which performed the cell adding.
cell - The cell to be added.
Throws:
DocumentHandlerException - If something went wrong when adding the cell.

getRemainingPdfColumns

public int getRemainingPdfColumns()
Gets the number of remaining columns of the current row.

Specified by:
getRemainingPdfColumns in interface PdfCellContainer
Returns:
The number of remaining column to the end of the current row.

getPdfTable

public PdfTableHolder getPdfTable()
Gets the PDF table holder.

Specified by:
getPdfTable in interface PdfCellContainer
Returns:
The component that really holds a PDF table.

addHeaderCell

public void addHeaderCell(BaseDocumentTag item,
                          com.lowagie.text.pdf.PdfPCell cell)
                   throws DocumentHandlerException
Adds a header cell to the table.

Parameters:
item - The tag which performed the cell adding.
cell - The header cell to be added.
Throws:
DocumentHandlerException - If something went wrong when adding the header cell.

fitsPage

public boolean fitsPage()
                 throws DocumentHandlerException
Checks whether the table fits the current page or not.

Specified by:
fitsPage in interface PdfTableHolder
Returns:
true if there's room enough for the table on the current page, else false.
Throws:
DocumentHandlerException - In case something went wrong.

splitTable

public boolean splitTable(boolean newPage,
                          boolean keepHeader)
                   throws DocumentHandlerException
Splits the table vertically.

Specified by:
splitTable in interface PdfTableHolder
Parameters:
newPage - Tells whether to start a new page or not.
keepHeader - Tells whether to keep the old header or not.
Returns:
true if a split has been really performed, else false.
Throws:
DocumentHandlerException - If something went wrong while splitting the table.

defineColumn

public void defineColumn(String name,
                         float width,
                         int hAlign,
                         String title,
                         String defaultContents)
                  throws DocumentHandlerException
Defines a column for the table.

Parameters:
name - The name of the column.
width - The width of the column.
hAlign - The horizontal alignment of the column.
title - The title of the column.
defaultContents - The default contents to use for this column.
Throws:
DocumentHandlerException - In case the given reference column does not exist.

insertColumn

public void insertColumn(String name,
                         float width,
                         int hAlign,
                         String title,
                         String reference,
                         int direction,
                         String defaultContents)
                  throws DocumentHandlerException
Inserts a column into the table.

Parameters:
name - The name of the new column.
width - The width of the new column.
hAlign - The horizontal alignment of the new column.
title - The title of the column.
reference - The column at which to insert the new column.
direction - The insert direction.
defaultContents - The default contents to use for this column.
Throws:
DocumentHandlerException - In case the given reference column does not exist.
See Also:
DIRECTION_BEFORE, DIRECTION_AFTER

alterColumn

public void alterColumn(String name,
                        float width,
                        int hAlign,
                        String title,
                        String defaultContents)
                 throws DocumentHandlerException
Alters a column at the table.

Parameters:
name - The name of the new column.
width - The width of the new column.
hAlign - The horizontal alignment of the new column.
title - The title of the column.
defaultContents - The default contents to use for this column.
Throws:
DocumentHandlerException - In case the given reference column does not exist.

removeColumn

public void removeColumn(String name)
                  throws DocumentHandlerException
Removes a column from the table.

Parameters:
name - The name of the new column.
Throws:
DocumentHandlerException - In case the given column does not exist.

getTable

protected com.lowagie.text.pdf.PdfPTable getTable()
Gets the PDF table.

Returns:
The PDF table.

getNumRows

protected int getNumRows()
Gets the number of rows, printed so far within the current row segment.

Returns:
The number of rows, printed so far within the current row segment.

getNumColumns

public int getNumColumns()
Gets the number of columns by row to print.

Specified by:
getNumColumns in interface PdfTableHolder
Returns:
The number of columns by row.

getNumContentRows

public int getNumContentRows()
Gets the number of content rows, that have been added to the current table so far.

Specified by:
getNumContentRows in interface PdfTableHolder
Returns:
The number of content rows, that have been added to the current table so far.

getColumnIndex

protected int getColumnIndex(String columnName)
Gets the index of the given column.

Parameters:
columnName - The name of the column to get the index for.
Returns:
The index of the column.

getCellAttributes

public CellAttributes getCellAttributes()
Gets the cell attributes.

Specified by:
getCellAttributes in interface PdfCellContainer
Returns:
The cell attributes.

getLineSpacing

public float getLineSpacing()
Gets the line spacing.

Specified by:
getLineSpacing in interface CommonAttributesHolder
Returns:
The current line spacing.

getLeading

public float getLeading()
Gets the leading.

Specified by:
getLeading in interface CommonAttributesHolder
Returns:
The current leading.


Copyright © 2003-2004 UJAC.org. All Rights Reserved.