public class RowObject extends ObjectMap<CellObject>
The row obect has additional fields, which represent predefined properties (e.g. the coordinates of the cell in the worksheet) or support the iteration along all cell based properties.
An object of this class contains the results of parsing one row of a worksheet in an Excel input file. The object is passed as part of the data model to the template engine for rendering the information in the wanted format.
Formally, an RowObject object is a Java Map, which contains Excel cells,
looked up by (property) name. The name of a property is subject to the application
configuration. It might be the contents of the top most cell of the column in the Excel
worksheet but this is not a must and not even common practice. If the application has
parsed an Excel worksheet with two columns "A" and "B", then the related properties of
the row object would be accessed from a StringTemplate V4 template with an expression
like <row.A> or <row.B>.
Note, empty cells in the Excel worksheet are not added to the RowObject
object. They are not represented by CellObject objects. If a template expression
like <row.A> hits an empty cell then the expression evaluates to null.
Consequently, commonly available cell information like row and column index is not
available for empty cells. Refer to CellObject.isNotBlank for a detailed
consideration how to handle the distinction between empty and non empty cells from a
template.
The row object provides more information to the rendering process. The map of cells or
properties is extended by some so-called "pseudo-fields", which can be accessed from a
template by means of the same dot notation. As an example, the row object has a row
number and this number can be accessed by the template expression <row.iRow>;
where iRow denotes a pseudo-field. (It's impossible to name a property (i.e. to
title a column) "iRow", this is a reserved keyword.)
The list of all supported pseudo-fields is documented as enumeration RowObject.PseudoFieldName.
RowObject is derived from its base class and the base class' pseudo-fields are
inherited and can be accessed in the same way. They are documented as enumeration ObjectMap.PseudoFieldName.
| Modifier and Type | Class and Description |
|---|---|
static class |
RowObject.PseudoFieldName
This is the list of pseudo-fields of class
RowObject that can be
accessed from a StringTemplate V4 template. |
| Modifier and Type | Field and Description |
|---|---|
int |
i0Row
The null based index of the row in the worksheet.
|
int |
iRow
The one based index of the row in the worksheet.
|
| Constructor and Description |
|---|
RowObject(excelExporter.excelParser.ErrorCounter errCnt,
java.lang.String logContext,
int idxRow)
Create a new row object.
|
| Modifier and Type | Method and Description |
|---|---|
static SortOrder.Comparator<RowObject> |
createComparator(SortOrder.Order sortOrder,
java.lang.String propName)
A comparator for sorting row objects in a collection is created and returned.
|
boolean |
putCell(java.lang.String propName,
CellObject cellObj)
Add a cell object to the map.
|
containsKey, createComparator, entrySet, get, getNoItems, put, putItem, setIndexInCollection, toStringpublic final int i0Row
public final int iRow
public RowObject(excelExporter.excelParser.ErrorCounter errCnt,
java.lang.String logContext,
int idxRow)
errCnt - A client supplied error counter. The use case is to permit consecutive error
counting across different phases of parsing.logContext - A string used to precede all logging statements of this module. Pass null if not
needed.idxRow - The null based index of the row in the worksheet.public boolean putCell(java.lang.String propName,
CellObject cellObj)
propName - A cell represents a property of the row object. This is the name
of the property; the name is the key into the map to later access it.cellObj - The object to add.public static SortOrder.Comparator<RowObject> createComparator(SortOrder.Order sortOrder, java.lang.String propName)
sortOrder - The desired sort order.propName - The row objects can be sorted according to the values of a single property. The name
of the property is passed in. Objects, which don't have the property at all will
come behind those having the property.