com.tibbo.aggregate.common.datatable

## Class TableFormat

- java.lang.Object
- - com.tibbo.aggregate.common.datatable.TableFormat

- All Implemented Interfaces:
    PublicCloneable, StringEncodable, java.lang.Cloneable, java.lang.Iterable<FieldFormat>

      public final class TableFormat
      extends java.lang.Object
      implements java.lang.Iterable<FieldFormat>, java.lang.Cloneable, PublicCloneable, StringEncodable

  `TableFormat` describes fields and other options of a `DataTable` or a `DataRecord`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_MAX_RECORDS`
    `static int` | `DEFAULT_MIN_RECORDS`
    `static TableFormat` | `EMPTY_FORMAT`
    `static char` | `RECORD_VALIDATOR_KEY_FIELDS`
    `static char` | `TABLE_VALIDATOR_EXPRESSION`
    `static char` | `TABLE_VALIDATOR_KEY_FIELDS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TableFormat()` Constructs a default empty `TableFormat`.
    `TableFormat(boolean reorderable)` Constructs a `TableFormat` with specified reorderable flag.
    `TableFormat(FieldFormat ff)` Constructs a `TableFormat` with a single field specified by `FieldFormat`.
    `TableFormat(int minRecords, int maxRecords)` Constructs a `TableFormat` with specified minimum and maximum number of records.
    `TableFormat(int minRecords, int maxRecords, FieldFormat fieldFormat)`
    `TableFormat(int minRecords, int maxRecords, java.lang.String fieldFormat)`
    `TableFormat(java.lang.String format, ClassicEncodingSettings settings)`
    `TableFormat(java.lang.String format, ClassicEncodingSettings settings, boolean validate)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addBinding(Binding binding)` Adds new binding.
    `void` | `addBinding(Reference target, Expression expression)` Adds new binding.
    `void` | `addBinding(java.lang.String target, java.lang.String expression)` Adds new binding.
    `void` | `addField(char type, java.lang.String name)` Adds new field to format.
    `TableFormat` | `addField(char type, java.lang.String name, int index)` Note, that modifying table format of an existing table by inserting fields anywhere except appending them to the end may cause `DataTable` to become invalid.
    `TableFormat` | `addField(char type, java.lang.String name, java.lang.String description)` Adds new field to format.
    `TableFormat` | `addField(char type, java.lang.String name, java.lang.String description, java.lang.Object defaultValue)` Adds new field to format.
    `TableFormat` | `addField(char type, java.lang.String name, java.lang.String description, java.lang.Object defaultValue, boolean nullable)` Adds new field to format.
    `TableFormat` | `addField(char type, java.lang.String name, java.lang.String description, java.lang.Object defaultValue, boolean nullable, java.lang.String group)` Adds new field to format.
    `TableFormat` | `addField(char type, java.lang.String name, java.lang.String description, java.lang.Object defaultValue, java.lang.String group)` Adds new field to format.
    `TableFormat` | `addField(FieldFormat ff)` Adds new field to format.
    `TableFormat` | `addField(FieldFormat ff, int index)` Adds new field to format at the specified index.
    `TableFormat` | `addField(java.lang.String encodedFormat)` Adds new field to format.
    `TableFormat` | `addFields(FieldFormat[] fieldFormats)` Adds new fields to format.
    `TableFormat` | `addFields(java.util.List<FieldFormat> fieldFormats)` Adds new fields to format.
    `void` | `addRecordValidator(RecordValidator rv)` Adds new record validator to the format.
    `void` | `addTableValidator(TableValidator tv)` Adds new table validator to the format.
    `void` | `applyCachedFormat(FormatCache formatCache, java.util.function.Consumer<TableFormat> formatSetter)`
    `TableFormat` | `clone()`
    `TableFormat` | `cloneIfImmutable()`
    `boolean` | `containsDataBlocksOrTables()`
    `void` | `createTableValidators(java.lang.String source, ClassicEncodingSettings settings)`
    `java.lang.String` | `encode(boolean useVisibleSeparators)`
    `java.lang.String` | `encode(ClassicEncodingSettings settings)`
    `java.lang.String` | `encode(ClassicEncodingSettings settings, java.lang.Boolean isTransferEncode, java.lang.Integer encodeLevel)`
    `java.lang.StringBuilder` | `encode(java.lang.StringBuilder builder, ClassicEncodingSettings settings, java.lang.Boolean isTransferEncode, java.lang.Integer encodeLevel)`
    `boolean` | `equals(java.lang.Object obj)`
    `boolean` | `extend(TableFormat other)` Returns true if this format extends the `other` format.
    `java.lang.String` | `extendMessage(TableFormat other)`
    `java.util.List<Binding>` | `getBindings()` Returns modifiable list of table bindings.
    `java.lang.String` | `getEncodedTableValidators(ClassicEncodingSettings settings)`
    `FieldFormat` | `getField(int index)` Returns format of field with specified index.
    `FieldFormat` | `getField(java.lang.String fieldName)` Returns format of field with specified name.
    `int` | `getFieldCount()` Returns number of fields in table format.
    `int` | `getFieldIndex(java.lang.String name)` Returns index of field with the specified name or -1 if it does not exist.
    `java.util.Map<java.lang.String,java.lang.Integer>` | `getFieldLookup()`
    `java.lang.String` | `getFieldName(int index)` Returns name of field at the specified index.
    `java.util.List<FieldFormat>` | `getFields()` Returns list of fields in table format.
    `char` | `getFieldType(int index)` Returns type of field at the specified index.
    `java.lang.Integer` | `getId()`
    `java.util.List<java.lang.String>` | `getKeyFields()` Returns list of key field names.
    `int` | `getMaxRecords()` Returns maximal number of records allowed by format.
    `int` | `getMinRecords()` Returns minimal number of records allowed by format.
    `Expression` | `getNamingExpression()` Returns naming expression.
    `java.util.List<RecordValidator>` | `getRecordValidators()` Returns modifiable list of record validators.
    `java.util.List<TableValidator>` | `getTableValidators()` Returns modifiable list of table validators.
    `boolean` | `hasField(java.lang.String name)` Returns true if table format contains field with specified name.
    `boolean` | `hasFields(char type)` Returns true if table format contains fields of the specified type.
    `int` | `hashCode()`
    `boolean` | `hasReadOnlyFields()` Returns true if format has read-only fields
    `boolean` | `isAdvanced()`
    `boolean` | `isAttachedToAnotherCache(FormatCache formatCache)`
    `boolean` | `isBindingsEditable()`
    `boolean` | `isCachedLocally()`
    `boolean` | `isEmpty()`
    `boolean` | `isGrouped()`
    `boolean` | `isImmutable()`
    `boolean` | `isReadonly()`
    `boolean` | `isReorderable()` Returns true if format allows record reordering.
    `boolean` | `isReplicated()`
    `boolean` | `isSingleCell()`
    `boolean` | `isSingleField()`
    `boolean` | `isSingleRecord()`
    `boolean` | `isUnresizable()`
    `java.util.Iterator<FieldFormat>` | `iterator()`
    `void` | `makeImmutable(DataTable immutabilizer)`
    `void` | `removeBinding(Binding binding)` Removes the binding.
    `TableFormat` | `removeField(java.lang.String name)` Removes field from format.
    `TableFormat` | `renameField(java.lang.String oldName, java.lang.String newName)` Renames a field.
    `TableFormat` | `resetAllowedRecords()` Resets allowed number of records to defaults.
    `void` | `setBindings(java.util.List<Binding> in_bindings)` Set the bindings.
    `void` | `setBindingsEditable(boolean bindingsEditable)`
    `void` | `setFormatCacheIdentityHashCode(int formatCacheIdentityHashCode)`
    `void` | `setId(java.lang.Integer id)`
    `TableFormat` | `setMaxRecords(int maxRecords)` Sets maximum allowed number of records.
    `TableFormat` | `setMinRecords(int minRecords)` Sets minimum allowed number of records.
    `TableFormat` | `setNamingExpression(Expression namingExpression)` Sets naming expression.
    `TableFormat` | `setNamingExpression(java.lang.String namingExpression)` Sets naming expression.
    `TableFormat` | `setReorderable(boolean reorderable)` Sets reorderable flag that allows table record reordering.
    `void` | `setUnresizable(boolean unresizable)`
    `java.lang.String` | `toString()`

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

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Field Detail

    - #### EMPTY_FORMAT

          public static final TableFormat EMPTY_FORMAT

    - #### DEFAULT_MIN_RECORDS

          public static final int DEFAULT_MIN_RECORDS

      See Also:
        Constant Field Values

    - #### DEFAULT_MAX_RECORDS

          public static final int DEFAULT_MAX_RECORDS

      See Also:
        Constant Field Values

    - #### TABLE_VALIDATOR_KEY_FIELDS

          public static final char TABLE_VALIDATOR_KEY_FIELDS

      See Also:
        Constant Field Values

    - #### TABLE_VALIDATOR_EXPRESSION

          public static final char TABLE_VALIDATOR_EXPRESSION

      See Also:
        Constant Field Values

    - #### RECORD_VALIDATOR_KEY_FIELDS

          public static final char RECORD_VALIDATOR_KEY_FIELDS

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TableFormat

          public TableFormat()

      Constructs a default empty `TableFormat`.

    - #### TableFormat

          public TableFormat(boolean reorderable)

      Constructs a `TableFormat` with specified reorderable flag.

    - #### TableFormat

          public TableFormat(int minRecords,
                             int maxRecords)

      Constructs a `TableFormat` with specified minimum and maximum number of records.

    - #### TableFormat

          public TableFormat(FieldFormat ff)

      Constructs a `TableFormat` with a single field specified by `FieldFormat`.

    - #### TableFormat

          public TableFormat(java.lang.String format,
                             ClassicEncodingSettings settings)

    - #### TableFormat

          public TableFormat(java.lang.String format,
                             ClassicEncodingSettings settings,
                             boolean validate)

    - #### TableFormat

          public TableFormat(int minRecords,
                             int maxRecords,
                             java.lang.String fieldFormat)

    - #### TableFormat

          public TableFormat(int minRecords,
                             int maxRecords,
                             FieldFormat fieldFormat)

  - ### Method Detail

    - #### addFields

          public TableFormat addFields(FieldFormat[] fieldFormats)

      Adds new fields to format.

    - #### addFields

          public TableFormat addFields(java.util.List<FieldFormat> fieldFormats)

      Adds new fields to format.

    - #### addField

          public TableFormat addField(FieldFormat ff)

      Adds new field to format.

    - #### addField

          public TableFormat addField(java.lang.String encodedFormat)

      Adds new field to format.

    - #### addField

          public void addField(char type,
                               java.lang.String name)
                        throws DataTableException

      Adds new field to format.
      Throws:
        `DataTableException`

    - #### addField

          public TableFormat addField(char type,
                                      java.lang.String name,
                                      java.lang.String description)

      Adds new field to format.

    - #### addField

          public TableFormat addField(char type,
                                      java.lang.String name,
                                      java.lang.String description,
                                      java.lang.Object defaultValue)

      Adds new field to format.

    - #### addField

          public TableFormat addField(char type,
                                      java.lang.String name,
                                      java.lang.String description,
                                      java.lang.Object defaultValue,
                                      java.lang.String group)

      Adds new field to format.

    - #### addField

          public TableFormat addField(char type,
                                      java.lang.String name,
                                      java.lang.String description,
                                      java.lang.Object defaultValue,
                                      boolean nullable)

      Adds new field to format.

    - #### addField

          public TableFormat addField(char type,
                                      java.lang.String name,
                                      java.lang.String description,
                                      java.lang.Object defaultValue,
                                      boolean nullable,
                                      java.lang.String group)

      Adds new field to format.

    - #### addField

          public TableFormat addField(FieldFormat ff,
                                      int index)

      Adds new field to format at the specified index. Note, that modifying table format of an existing table by inserting fields anywhere except appending them to the end may cause `DataTable` to become invalid.

    - #### addField

          public TableFormat addField(char type,
                                      java.lang.String name,
                                      int index)
                               throws DataTableException

      Note, that modifying table format of an existing table by inserting fields anywhere except appending them to the end may cause `DataTable` to become invalid.
      Throws:
        `DataTableException`

    - #### removeField

          public TableFormat removeField(java.lang.String name)

      Removes field from format.

    - #### renameField

          public TableFormat renameField(java.lang.String oldName,
                                         java.lang.String newName)

      Renames a field.

    - #### getFieldType

          public char getFieldType(int index)

      Returns type of field at the specified index.

    - #### getFieldName

          public java.lang.String getFieldName(int index)

      Returns name of field at the specified index.

    - #### getFieldIndex

          public int getFieldIndex(java.lang.String name)

      Returns index of field with the specified name or -1 if it does not exist.

    - #### getFieldCount

          public int getFieldCount()

      Returns number of fields in table format.

    - #### getFields

          public java.util.List<FieldFormat> getFields()

      Returns list of fields in table format.

    - #### getRecordValidators

          public java.util.List<RecordValidator> getRecordValidators()

      Returns modifiable list of record validators.

    - #### getTableValidators

          public java.util.List<TableValidator> getTableValidators()

      Returns modifiable list of table validators.

    - #### getMaxRecords

          public int getMaxRecords()

      Returns maximal number of records allowed by format.

    - #### getMinRecords

          public int getMinRecords()

      Returns minimal number of records allowed by format.

    - #### isReorderable

          public boolean isReorderable()

      Returns true if format allows record reordering.

    - #### isUnresizable

          public boolean isUnresizable()

    - #### setUnresizable

          public void setUnresizable(boolean unresizable)

    - #### isBindingsEditable

          public boolean isBindingsEditable()

    - #### setBindingsEditable

          public void setBindingsEditable(boolean bindingsEditable)

    - #### getBindings

          public java.util.List<Binding> getBindings()

      Returns modifiable list of table bindings.

    - #### addBinding

          public void addBinding(Binding binding)

      Adds new binding.

    - #### addBinding

          public void addBinding(Reference target,
                                 Expression expression)

      Adds new binding.

    - #### addBinding

          public void addBinding(java.lang.String target,
                                 java.lang.String expression)

      Adds new binding.

    - #### removeBinding

          public void removeBinding(Binding binding)

      Removes the binding.

    - #### setBindings

          public void setBindings(java.util.List<Binding> in_bindings)

      Set the bindings.

    - #### getNamingExpression

          public Expression getNamingExpression()

      Returns naming expression.

    - #### encode

          public java.lang.String encode(boolean useVisibleSeparators)

    - #### encode

          public java.lang.String encode(ClassicEncodingSettings settings)

    - #### encode

          public java.lang.String encode(ClassicEncodingSettings settings,
                                         java.lang.Boolean isTransferEncode,
                                         java.lang.Integer encodeLevel)

    - #### encode

          public java.lang.StringBuilder encode(java.lang.StringBuilder builder,
                                                ClassicEncodingSettings settings,
                                                java.lang.Boolean isTransferEncode,
                                                java.lang.Integer encodeLevel)

      Specified by:
        `encode` in interface `StringEncodable`

    - #### getFieldLookup

          public java.util.Map<java.lang.String,java.lang.Integer> getFieldLookup()

    - #### getEncodedTableValidators

          public java.lang.String getEncodedTableValidators(ClassicEncodingSettings settings)

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### getField

          public FieldFormat getField(int index)

      Returns format of field with specified index.

    - #### getField

          public FieldFormat getField(java.lang.String fieldName)

      Returns format of field with specified name.

    - #### hasField

          public boolean hasField(java.lang.String name)

      Returns true if table format contains field with specified name.

    - #### hasFields

          public boolean hasFields(char type)

      Returns true if table format contains fields of the specified type.

    - #### hasReadOnlyFields

          public boolean hasReadOnlyFields()

      Returns true if format has read-only fields

    - #### getKeyFields

          public java.util.List<java.lang.String> getKeyFields()

      Returns list of key field names.

    - #### extend

          public boolean extend(TableFormat other)

      Returns true if this format extends the `other` format.

    - #### extendMessage

          public java.lang.String extendMessage(TableFormat other)

    - #### addTableValidator

          public void addTableValidator(TableValidator tv)

      Adds new table validator to the format.

    - #### addRecordValidator

          public void addRecordValidator(RecordValidator rv)

      Adds new record validator to the format.

    - #### createTableValidators

          public void createTableValidators(java.lang.String source,
                                            ClassicEncodingSettings settings)

    - #### iterator

          public java.util.Iterator<FieldFormat> iterator()

      Specified by:
        `iterator` in interface `java.lang.Iterable<FieldFormat>`

    - #### isReplicated

          public boolean isReplicated()

    - #### isReadonly

          public boolean isReadonly()

    - #### isGrouped

          public boolean isGrouped()

    - #### isAdvanced

          public boolean isAdvanced()

    - #### isSingleRecord

          public boolean isSingleRecord()

    - #### isSingleField

          public boolean isSingleField()

    - #### isSingleCell

          public boolean isSingleCell()

    - #### isEmpty

          public boolean isEmpty()

    - #### isImmutable

          public boolean isImmutable()

    - #### resetAllowedRecords

          public TableFormat resetAllowedRecords()

      Resets allowed number of records to defaults.

    - #### setMaxRecords

          public TableFormat setMaxRecords(int maxRecords)

      Sets maximum allowed number of records.

    - #### setMinRecords

          public TableFormat setMinRecords(int minRecords)

      Sets minimum allowed number of records.

    - #### setReorderable

          public TableFormat setReorderable(boolean reorderable)

      Sets reorderable flag that allows table record reordering.

    - #### setNamingExpression

          public TableFormat setNamingExpression(Expression namingExpression)

      Sets naming expression.

    - #### setNamingExpression

          public TableFormat setNamingExpression(java.lang.String namingExpression)

      Sets naming expression.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### equals

          public boolean equals(java.lang.Object obj)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### cloneIfImmutable

          public TableFormat cloneIfImmutable()

    - #### clone

          public TableFormat clone()

      Specified by:
        `clone` in interface `PublicCloneable`
      Overrides:
        `clone` in class `java.lang.Object`

    - #### makeImmutable

          public void makeImmutable(DataTable immutabilizer)

    - #### getId

          public java.lang.Integer getId()

    - #### setId

          public void setId(java.lang.Integer id)

    - #### applyCachedFormat

          public void applyCachedFormat(FormatCache formatCache,
                                        java.util.function.Consumer<TableFormat> formatSetter)

    - #### setFormatCacheIdentityHashCode

          public void setFormatCacheIdentityHashCode(int formatCacheIdentityHashCode)

    - #### isAttachedToAnotherCache

          public boolean isAttachedToAnotherCache(FormatCache formatCache)

    - #### isCachedLocally

          public boolean isCachedLocally()

    - #### containsDataBlocksOrTables

          public boolean containsDataBlocksOrTables()