Package com.storedobject.office
Class ODT.Table
java.lang.Object
com.storedobject.office.ODT.Element
com.storedobject.office.ODT.Table
Represents a table in the context of open document template (ODT) processing. If the
customizeTable(ODT.Table table) method is defined, it will be called to customize the table.
You may use one or more of the methods of this class to control the output.
The table could be removed entirely from the output by invoking remove() method.- Author:
- Syam
-
Method Summary
Modifier and TypeMethodDescriptionvoidadd(ODT.InputTableRow row, int variableIndex) Adds a table row to the output with array variables adjusted as per the variable index.voidadd(ODT.InputTableRow row, int variableIndex, Object data) Adds a table row to the output with array variables adjusted as per the variable index.voidAdd a blank row to the output.voidaddBlankRow(ODT.InputTableRow modelRow) Add a blank row to the output, optionally using a model row for cell structure.voidBuilds and outputs rows to the table based on the current class configuration.voidbuildOutput(int headerRowCount, int bodyRowCount, boolean appendBlankIfNoOutput) Builds and outputs rows to the table based on specified parameters.voidbuildOutput(int headerRowCount, int bodyRowCount, int footerRowCount, boolean appendBlankIfNoOutput) Builds and outputs rows to the table based on specified parameters.voidcopy()Copy all rows to the output.voidcopy(int index) Copies the row at the specified index and adds it to the output as such.voidcopy(int index, int count) Copies a specified number of rows starting from a given index.voidCopies a specified number of rows starting from a given index.voidCopies the row at the specified index and adds it to the output as such.voidCopy all rows to the output.Get the first row of the input table.Get the last row of the input table.intGet the number of rows in the output table.getRow(int n) Retrieves a specific row from the input table by its index.intGet the number of rows in the input table.booleanremove()Removes this element from the output.voidsetBlankRowIfEmpty(boolean blankRowIfEmpty) Sets whether a blank row should be added to the output when the input table is empty.voidsetBodyRowCount(int bodyRowCount) Specifies the number of body rows to output from the input table.voidSets the data for the table.voidsetFooterRowCount(int footerRowCount) Specifies the number of footer rows to output from the input table.voidsetHeaderRowCount(int headerRowCount) Specifies the number of header rows to output from the input table.Methods inherited from class com.storedobject.office.ODT.Element
getCell, getDocument, getName, getParent, getParentCell, getParentRow, getParentSection, getParentTable
-
Method Details
-
setHeaderRowCount
public void setHeaderRowCount(int headerRowCount) Specifies the number of header rows to output from the input table.- Parameters:
headerRowCount- Header row count.
-
setBodyRowCount
public void setBodyRowCount(int bodyRowCount) Specifies the number of body rows to output from the input table.- Parameters:
bodyRowCount- Body row count.
-
setBlankRowIfEmpty
public void setBlankRowIfEmpty(boolean blankRowIfEmpty) Sets whether a blank row should be added to the output when the input table is empty.- Parameters:
blankRowIfEmpty-trueto add a blank row to the output if the input table is empty;falseto leave the output empty in such cases.
-
getOutputRowCount
public int getOutputRowCount()Get the number of rows in the output table.- Returns:
- Number of rows in the output table.
-
getRowCount
public int getRowCount()Get the number of rows in the input table.- Returns:
- Number of rows in the input table.
-
getFirstRow
Get the first row of the input table.- Returns:
- First row in the table, or
nullif the table is empty.
-
getLastRow
Get the last row of the input table.- Returns:
- Last row in the table, or
nullif the table is empty.
-
getRow
Retrieves a specific row from the input table by its index.- Parameters:
n- The zero-based index of the row to retrieve. Must be within the range of existing rows (0 to the number of rows - 1).- Returns:
- A
ODT.TableRowobject representing the row at the specified index, ornullif the index is out of bounds or the row cannot be retrieved.
-
addBlankRow
public void addBlankRow()Add a blank row to the output. -
addBlankRow
Add a blank row to the output, optionally using a model row for cell structure.- Parameters:
modelRow- Model row to use for cell structure, ornullif it should be generated.
-
add
Adds a table row to the output with array variables adjusted as per the variable index.- Parameters:
row- the InputTableRow object to be added; must not be nullvariableIndex- index of the array variables
-
add
Adds a table row to the output with array variables adjusted as per the variable index.- Parameters:
row- the InputTableRow object to be added; must not be nullvariableIndex- index of the array variablesdata- Data to be associated with the table row.
-
copy
public void copy(int index) Copies the row at the specified index and adds it to the output as such.- Parameters:
index- the index of the row to be copied
-
copy
Copies the row at the specified index and adds it to the output as such.- Parameters:
index- the index of the row to be copieddata- Data to be associated with the copied row.
-
copy
public void copy(int index, int count) Copies a specified number of rows starting from a given index.- Parameters:
index- the starting index from which copying beginscount- the number of rows to be copied. If count == Integer.MAX_VALUE, all remaining rows will be copied.
-
copy
Copies a specified number of rows starting from a given index.- Parameters:
index- the starting index from which copying beginscount- the number of rows to be copied. If count == Integer.MAX_VALUE, all remaining rows will be copied.data- Data to be associated with the copied rows. (The same data will be associated with all copied rows)
-
copy
public void copy()Copy all rows to the output. -
copy
Copy all rows to the output.- Parameters:
data- Data to be associated with the copied rows. (The same data will be associated with all copied rows)
-
remove
public boolean remove()Description copied from class:ODT.ElementRemoves this element from the output.- Overrides:
removein classODT.Element- Returns:
- Returns
trueunless the element was already removed.
-
setData
Sets the data for the table. This method assigns the provided data to the table, unless the table has already been built. If the table is built, an exception is thrown. If the data isnull, no body rows will be generated.- Parameters:
data- The data to be assigned to the table. All the rows in the table will be populated with the same data unless the data is an array of objects, collection, or any iterable. In this case, each row will be populated with the corresponding element of the iterable by adding required body rows.- Throws:
SORuntimeException- If the data is null or the table has already been built.
-
buildOutput
public void buildOutput()Builds and outputs rows to the table based on the current class configuration. This method uses the pre-configured values of header row count, body row count, and whether a blank row should be added if the output is empty. It serves as a convenience wrapper around the overloadedbuildOutput(int, int, boolean)method, automatically passing the properties of the class as parameters. -
buildOutput
public void buildOutput(int headerRowCount, int bodyRowCount, boolean appendBlankIfNoOutput) Builds and outputs rows to the table based on specified parameters. This method facilitates defining the number of header rows, body rows, and whether to append a blank row if no output is generated.- Parameters:
headerRowCount- The number of header rows to include in the output.bodyRowCount- The number of body rows to include in the output.appendBlankIfNoOutput- Determines whether a blank row should be appended if no output rows are generated. Iftrue, a blank row will be added; otherwise, no rows will be added, and the table will be removed.
-
buildOutput
public void buildOutput(int headerRowCount, int bodyRowCount, int footerRowCount, boolean appendBlankIfNoOutput) Builds and outputs rows to the table based on specified parameters. This method facilitates defining the number of header rows, body rows, and whether to append a blank row if no output is generated.- Parameters:
headerRowCount- The number of header rows to include in the output.bodyRowCount- The number of body rows to include in the output.footerRowCount- The number of footer rows from the bottom of the input rows to include in the output.appendBlankIfNoOutput- Determines whether a blank row should be appended if no output rows are generated. Iftrue, a blank row will be added; otherwise, no rows will be added, and the table will be removed.
-