public class CellObject
extends java.lang.Object
Note, empty cells are not added to the data model at all. The access from a template
to such a cell will always evaluate to null. Commonly available cell information, like
row and column index, is not available for blank cells. Refer to isNotBlank for a detailed consideration how to handle the distinction from a
template.
| Modifier and Type | Class and Description |
|---|---|
static class |
CellObject.CellType
An enumeration describing the possible data types of the cell contents.
|
| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
authorOfComment
The author of comment
comment if there is one, otherwise null. |
boolean |
bool
The Boolean value of a cell of
CellObject.CellType.bool. |
java.lang.String |
comment
The comment, which is attached to the cell or null if no such comment exists.
|
java.lang.Long |
d
The integer value of a numeric cell if it is of type
CellObject.CellType.integer or
CellObject.CellType.bool. |
java.util.Calendar |
date
The value of a numeric cell if it is of type
CellObject.CellType.date or null for non dates. |
int |
i
The one based index of the attribute in a collection.
|
int |
i0
The null based index of the object in a collection.
|
int |
i0Col
The null based index of the column, which the cell is located in.
|
int |
i0Row
The null based index of the row, which the cell is located in.
|
int |
iCol
The one based index of the column, which the cell is located in.
|
java.lang.String |
ident
The text contents modified such that it becomes an identifier as defined in many
programming languages, e.g.
|
boolean |
identEquals
This flag indicates whether the text contents of the cell and the modification into
identifier
ident are identical. |
java.lang.String |
identStrict
The text contents modified such that it becomes a more restricted identifier as for
ident. |
boolean |
identStrictEquals
This flag indicates whether the text contents of the cell and the modification into
identifier
identStrict are identical. |
int |
iRow
The one based index of the row, which the cell is located in.
|
boolean |
isBool
The data type of the cell contents as Boolean flag.
|
boolean |
isDate
The data type of the cell contents as Boolean flag.
|
boolean |
isError
The data type of the cell contents as Boolean flag.
|
boolean |
isInt
The data type of the cell contents as Boolean flag.
|
boolean |
isNotBlank
The data type of the cell contents as Boolean flag.
|
boolean |
isReal
The data type of the cell contents as Boolean flag.
|
boolean |
isText
The data type of the cell contents as Boolean flag.
|
java.lang.Double |
n
The floating point value of a numeric cell if it is of type
CellObject.CellType.real,
CellObject.CellType.integer, CellObject.CellType.bool or CellObject.CellType.date. |
Identifier |
name
The name of the cell object is the name of the property of the row object, which is
represented by this cell.
|
int |
objId
The ID of this object.
|
java.lang.String |
text
The text contents of a cell, mainly used if it is of type
CellObject.CellType.text. |
CellObject.CellType |
type
The data type of the cell contents.
|
| Constructor and Description |
|---|
CellObject()
Create a cell object, which represents a blank Excel cell.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
compare(CellObject a,
CellObject b,
SortOrder.Order sortOrder)
Compare two cell objects.
|
int |
getI_()
The usual name of an object's one based index-in-collection in the data model is
i0. |
int |
getI0_()
The usual name of an object's null based index-in-collection in the data model is
i0. |
Identifier |
getName_()
The usual name of an object's name in the data model is
name. |
void |
setIndexInCollection(int i0)
Set the index-in-collection.
|
java.lang.String |
toString()
Get the string representation of the cell.
|
public final int objId
public int i0
If the reference to an object is held in more than one collection, then the index relates to the most important collection.
The value is -1 if the object is not element of a collection.
public int i
i0+1.If the reference to an object is held in more than one collection, then the index relates to the most important collection.
The value is -1 if the object is not element of a collection.
public Identifier name
Identifier. If is is
rendered like <cell.name> in a StringTemplate V4 template you will not get
the given name but the C identifier, which is most similar to the given name - this
can even be identical to the name. If you really want to get the given name then
you'd rather put <cell.name.givenName> into your template.public CellObject.CellType type
blank will never be seen from a template. See isNotBlank for a more
detailed consideration.public boolean isNotBlank
To support conditional code in the templates the cell type is represented as a
set of Booleans, too. (See e.g. isInt or isDate.) Since empty
cells are not added to the data model at all, it is difficult to have an according
flag, e.g. isBlank for empty cells. The logically inverted information has
been added instead. It enables conditional template expressions in a readable
manner, like <if(!myCell.isNotBlank)> although it is - technically spoken -
not really working: For any cell object in the data model the field is true. For empty cells there is no CellObject object in the data model and the
expression myCell.isNotBlank evaluates to null, which is interpreted as
false. The behavior is as expected in either case.
public boolean isInt
To support conditional code in the templates the cell type is represented as a
set of Booleans, too. One and only one of these will be set. See enumerated value
type, too.
public boolean isReal
To support conditional code in the templates the cell type is represented as a
set of Booleans, too. One and only one of these will be set. See enumerated value
type, too.
public boolean isDate
To support conditional code in the templates the cell type is represented as a
set of Booleans, too. One and only one of these will be set. See enumerated value
type, too.
public boolean isText
To support conditional code in the templates the cell type is represented as a
set of Booleans, too. One and only one of these will be set. See enumerated value
type, too.
public boolean isBool
To support conditional code in the templates the cell type is represented as a
set of Booleans, too. One and only one of these will be set. See enumerated value
type, too.
public boolean isError
To support conditional code in the templates the cell type is represented as a
set of Booleans, too. One and only one of these will be set. See enumerated value
type, too.
public java.lang.String text
CellObject.CellType.text. For
other types this field will contain a suitable textual representation of the cell
contents. It is null for empty/blank/error cells.public java.lang.String ident
All groups of unpermitted characters in text are replaced by a single
character x and an underscore prepends the resut if it should begin with a
digit.
This field is available only for text cells, i.e. if isText is true, otherwise it's null.
public java.lang.String identStrict
ident. The first character may be a letter, all others may be the same or
a decimal digit.All groups of unpermitted characters are replaced by a single character x and a further x prepends the result if it should begin with a digit.
This field is available only for text cells, i.e. if isText is true, otherwise it's null.
public boolean identEquals
public boolean identStrictEquals
identStrict are identical. It'll always be false if isText is false.public java.lang.Long d
CellObject.CellType.integer or
CellObject.CellType.bool. For CellObject.CellType.real (and including date
representations) this will contain the rounded off numeric value. null for non
numeric cell types.public java.lang.Double n
CellObject.CellType.real,
CellObject.CellType.integer, CellObject.CellType.bool or CellObject.CellType.date. null for non numeric cell types.public java.util.Calendar date
CellObject.CellType.date or null for non dates. The use of this field enables applying the StringTemplate V4
date renderer to render a date in the variants of any locale, e.g.:
<cell.date; format="MMM dd, yyyy HH:mm">
Note, if a cell contains a date then you can also put <cell> into your
template. This expression will use the default representation of the CellObject object, which makes use of the Excel format information stored in and
retrieved from the worksheet. Ideally, this representation should be identical to
the cell representation visible in the Excel application but in fact it only
resembles it; the format string handling of Excel and Java's POI are not fully
compatible.
Note, if a cell contains a date then you can also put <cell.date> into your
template. This expression will use the default representation of the Calendar object, which is a short format with date and time
information.
SimpleDateFormat (see e.g.
https://docs.oracle.com/javase/tutorial/i18n/format/simpleDateFormat.html).
Besides the SimpleDateFormat formatting characters you may use some predefined
format strings. (This information is not for granted):
"short" "medium" "long" "full"
"date:short" "date:medium" "date:long" "date:full"
"time:short" "time:medium" "time:long" "time:full"
public boolean bool
CellObject.CellType.bool.
For numeric cell types it is true if the numeric value is not equal to
null and false otherwise.
For text cells it is true if the cell contents are equal to one out of
"true", "yes", "okay" or "ok" and false otherwise. String comparison is
done case insensitive.
It is false for empty/blank/error cells.
public java.lang.String comment
public java.lang.String authorOfComment
comment if there is one, otherwise null.public int iRow
public int i0Row
public int iCol
public int i0Col
public CellObject()
public int getI0_()
i0. However, for some of the objects and to avoid name clashes with Excel
input data, we can't permit such a common designation and need to append an
underscore. This makes the data model unavoidably inconsistent. To improve the
situation we offer the object's index for all unaffected objects under the second
designation, too. For this object, <obj.i0_> would mean just the same as
<obj.i0>. This makes that for any kind of object a template can refer to
the index by the former expression.public int getI_()
i0. However, for some of the objects and to avoid name clashes with Excel
input data, we can't permit such a common designation and need to append an
underscore. This makes the data model unavoidably inconsistent. To improve the
situation we offer the object's index for all unaffected objects under the second
designation, too. For this object, <obj.i_> would mean just the same as
<obj.i>. This makes that for any kind of object a template can refer to
the index by the former expression.public Identifier getName_()
name. However, for
some of the objects and to avoid name clashes with Excel input data, we can't
permit such a common designation and need to append an underscore. This makes the
data model unavoidably inconsistent. To improve the situation we offer the object
name for all unaffected objects under the second designation, too. For this object,
<obj.name_> would mean just the same as <obj.name>. This makes
that for any kind of named object a template can refer to the name by the former
expression.public void setIndexInCollection(int i0)
i0 - The new value for the null based index of this object in an embedding
collection.public static int compare(CellObject a, CellObject b, SortOrder.Order sortOrder)
a - The first operand.b - The second operand.sortOrder - The sorder, which should be yielded by this comparison. Details about the different
supported sort order can be faound in the explanation of the named values of the
enumeration SortOrder.Order.public java.lang.String toString()
<cell>.toString in class java.lang.Object