excelExporter.excelParser.dataModel

## Class CellObject

- java.lang.Object
- - excelExporter.excelParser.dataModel.CellObject

-     public class CellObject
      extends java.lang.Object

  The representation of a single cell of the Excel worksheet.

  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.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `CellObject.CellType` An enumeration describing the possible data types of the cell contents.

  - ### Field Summary

    Fields
    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 Summary

    Constructors
    Constructor and Description
    `CellObject()` Create a cell object, which represents a blank Excel cell.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### objId

          public final int objId

      The ID of this object. Each object in the data model gets a unique ID, which can be useful for having related data objects in the generated code with individual names.

    - #### i0

          public int i0

      The null based index of the object in a collection. The index can be used to support the implementation of arrays of objects or enumerations by a list of #define's in the generated code.

      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.

    - #### i

          public int i

      The one based index of the attribute in a collection. The value is `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.

    - #### name

          public Identifier name

      The name of the cell object is the name of the property of the row object, which is represented by this cell. Normally, this is the title of the column the cell was found in.
      Remark:
        The name is stored as an object of type `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.

    - #### type

          public CellObject.CellType type

      The data type of the cell contents.
      Remark:
        Empty cells are not added to the data model. The access from a template to such a cell will evaluate to null. Therefore, the enumeration value `blank` will never be seen from a template. See `isNotBlank` for a more detailed consideration.

    - #### isNotBlank

          public boolean isNotBlank

      The data type of the cell contents as Boolean flag.

      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.

    - #### isInt

          public boolean isInt

      The data type of the cell contents as Boolean flag.

      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.

    - #### isReal

          public boolean isReal

      The data type of the cell contents as Boolean flag.

      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.

    - #### isDate

          public boolean isDate

      The data type of the cell contents as Boolean flag.

      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.

    - #### isText

          public boolean isText

      The data type of the cell contents as Boolean flag.

      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.

    - #### isBool

          public boolean isBool

      The data type of the cell contents as Boolean flag.

      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.

    - #### isError

          public boolean isError

      The data type of the cell contents as Boolean flag.

      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.

    - #### text

          public java.lang.String text

      The text contents of a cell, mainly used if it is of type `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.

    - #### ident

          public java.lang.String ident

      The text contents modified such that it becomes an identifier as defined in many programming languages, e.g. C. The first character may be a letter or the underscore, all others may be the same or a decimal digit.

      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.

    - #### identStrict

          public java.lang.String identStrict

      The text contents modified such that it becomes a more restricted identifier as for `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.

    - #### identEquals

          public boolean identEquals

      This flag indicates whether the text contents of the cell and the modification into identifier `ident` are identical. It'll always be `false` if `isText` is `false`.

    - #### identStrictEquals

          public boolean identStrictEquals

      This flag indicates whether the text contents of the cell and the modification into identifier `identStrict` are identical. It'll always be `false` if `isText` is `false`.

    - #### d

          public java.lang.Long d

      The integer value of a numeric cell if it is of type `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.

    - #### n

          public 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`. `null` for non numeric cell types.

    - #### date

          public java.util.Calendar date

      The value of a numeric cell if it is of type `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.

      Remark:
        It's hard to find explicit documentation on how the format string needs to look like. Most likely, it's an extended definition of Java's `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"`

    - #### bool

          public boolean bool

      The Boolean value of a cell of `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.

    - #### comment

          public java.lang.String comment

      The comment, which is attached to the cell or null if no such comment exists.

    - #### authorOfComment

          public java.lang.String authorOfComment

      The author of comment `comment` if there is one, otherwise null.

    - #### iRow

          public int iRow

      The one based index of the row, which the cell is located in.

    - #### i0Row

          public int i0Row

      The null based index of the row, which the cell is located in.

    - #### iCol

          public int iCol

      The one based index of the column, which the cell is located in.

    - #### i0Col

          public int i0Col

      The null based index of the column, which the cell is located in.

  - ### Constructor Detail

    - #### CellObject

          public CellObject()

      Create a cell object, which represents a blank Excel cell.

  - ### Method Detail

    - #### getI0_

          public int getI0_()

      The usual name of an object's null based index-in-collection in the data model is `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.

    - #### getI_

          public int getI_()

      The usual name of an object's one based index-in-collection in the data model is `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.

    - #### getName_

          public Identifier getName_()

      The usual name of an object's name in the data model is `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.

    - #### setIndexInCollection

          public void setIndexInCollection(int i0)

      Set the index-in-collection.
      Parameters:
        `i0` - The new value for the null based index of this object in an embedding collection.

    - #### compare

          public static int compare(CellObject a,
                                    CellObject b,
                                    SortOrder.Order sortOrder)

      Compare two cell objects. This function supports the sorting algorithms from Java's Collections. Cell objects can be compare according to different sort orders.
      Parameters:
        `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`.
      Returns:
        Get -1 if a should precede b, 0 if they are equal in the sense of the sort order and 1 if a should follow b.

    - #### toString

          public java.lang.String toString()

      Get the string representation of the cell. From a StringTemplate V4 template this representation of the object is accessed as `<cell>`.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        The string value.