com.tibbo.aggregate.common.datatable

## Class AbstractDataTable

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

- All Implemented Interfaces:
    DataTable, AttributedObject, PublicCloneable, StringEncodable, java.lang.Cloneable, java.lang.Iterable<DataRecord>
  Direct Known Subclasses:
    AbstractBigDataTable, SimpleDataTable

      public abstract class AbstractDataTable
      extends java.lang.Object
      implements DataTable, java.lang.Cloneable, PublicCloneable

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static TableFormat` | `DEFAULT_FORMAT`
    `static java.lang.String` | `ELEMENT_ID`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractDataTable()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DataTable` | `addRecords(java.util.List<DataRecord> records)` Adds new records to the table.
    `void` | `append(DataTable src)`
    `boolean` | `applyCachedFormat(java.util.Optional<FormatCache> formatCacheOpt)`
    `DataTable` | `clone()`
    `DataTable` | `cloneIfImmutable()`
    `void` | `close()`
    `boolean` | `conform(TableFormat rf)`
    `java.lang.String` | `conformMessage(TableFormat rf)`
    `java.lang.String` | `dataAsString()`
    `java.lang.String` | `dataAsString(boolean showFieldNames, boolean showHiddenFields)`
    `java.lang.String` | `encode()`
    `java.lang.String` | `encode(boolean useVisibleSeparators)`
    `java.lang.String` | `encode(ClassicEncodingSettings settings)`
    `java.lang.StringBuilder` | `encode(java.lang.StringBuilder finalSB, ClassicEncodingSettings settings, java.lang.Boolean isTransferEncode, java.lang.Integer encodeLevel)`
    `java.lang.Integer` | `findIndex(DataRecord record)` Returns the index of the first occurrence of `record` in this Data Table, or null if this Data Table does not contain the specified record.
    `java.lang.Integer` | `findIndex(java.lang.String field, java.lang.Object value)`
    `void` | `fixRecords()`
    `java.lang.Object` | `get()` Returns value of first field in first record of the table.
    `java.lang.String` | `getDescription()` Returns human-readable description of the table.
    `java.lang.String` | `getEncodedData(ClassicEncodingSettings settings)`
    `java.lang.StringBuilder` | `getEncodedData(java.lang.StringBuilder finalSB, ClassicEncodingSettings settings, java.lang.Boolean isTransferEncode, java.lang.Integer encodeLevel)`
    `int` | `getFieldCount()` Returns number of fields in the table.
    `TableFormat` | `getFormat()` Returns format of the table.
    `FieldFormat` | `getFormat(int field)` Returns format of field with specified index.
    `FieldFormat` | `getFormat(java.lang.String name)` Returns format of field with specified name.
    `java.lang.Long` | `getId()` Returns table ID.
    `java.lang.String` | `getInvalidationMessage()`
    `java.lang.Integer` | `getQuality()`
    `DataRecord` | `getRecordById(java.lang.String id)`
    `java.util.List<DataRecord>` | `getRecords()` Returns list of table records.
    `java.util.Date` | `getTimestamp()`
    `java.lang.Object` | `getValue()`
    `boolean` | `hasField(java.lang.String field)`
    `boolean` | `isImmutable()`
    `boolean` | `isInvalid()`
    `void` | `joinFormats()`
    `DataRecord` | `rec()` Returns first record of the table.
    `DataRecord` | `removeRecord(int index)` Removes record with specified index from the table.
    `protected abstract DataRecord` | `removeRecordImpl(int index)`
    `void` | `removeRecordsByIds(java.util.Collection<java.lang.String> ids)` Removes all records from the table which contain in ids.
    `DataRecord` | `select(DataTableQuery query)`
    `DataRecord` | `select(java.lang.String field, java.lang.Object value)`
    `java.util.List<DataRecord>` | `selectAll(DataTableQuery query)`
    `DataTable` | `setFormat(TableFormat format)` Sets new format for the table.
    `void` | `setInvalidationMessage(java.lang.String invalidationMessage)`
    `void` | `setQuality(java.lang.Integer quality)`
    `void` | `setTimestamp(java.util.Date timestamp)`
    `void` | `sort(java.lang.String field, boolean ascending)`
    `void` | `splitFormat()`
    `java.util.stream.Stream<DataRecord>` | `stream()`
    `void` | `swapRecords(int index1, int index2)` Swaps two records.
    `java.lang.String` | `toString()`
    `void` | `validate(Context context, ContextManager contextManager, CallerController caller)` Executes table validators to make sure table data is valid.
    `void` | `validateRecord(DataRecord record)` Executes validators of a specific record to make sure its data is valid.

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

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

    - ### Methods inherited from interface com.tibbo.aggregate.common.datatable.DataTable

      `addRecord, addRecord, addRecord, addRecord, compareTo, dataAsString, equals, findIndex, getRecord, getRecordCount, hashCode, isOneCellTable, isSimple, iterator, iterator, makeImmutable, removeRecords, reorderRecord, setId, setRecord, sort, sort, toDefaultString`

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

      `forEach, spliterator`

- - ### Field Detail

    - #### ELEMENT_ID

          public static final java.lang.String ELEMENT_ID

      See Also:
        Constant Field Values

    - #### DEFAULT_FORMAT

          public static final TableFormat DEFAULT_FORMAT

  - ### Constructor Detail

    - #### AbstractDataTable

          public AbstractDataTable()

  - ### Method Detail

    - #### getFieldCount

          public int getFieldCount()

      Returns number of fields in the table.
      Specified by:
        `getFieldCount` in interface `DataTable`

    - #### getFormat

          public TableFormat getFormat()

      Returns format of the table.
      Specified by:
        `getFormat` in interface `DataTable`

    - #### getFormat

          public FieldFormat getFormat(int field)

      Returns format of field with specified index.
      Specified by:
        `getFormat` in interface `DataTable`

    - #### getFormat

          public FieldFormat getFormat(java.lang.String name)

      Returns format of field with specified name.
      Specified by:
        `getFormat` in interface `DataTable`

    - #### setFormat

          public DataTable setFormat(TableFormat format)

      Sets new format for the table. Note, that resulting table is not checked for validity. Format of existing records may be incompatible with new format of table.
      Specified by:
        `setFormat` in interface `DataTable`

    - #### addRecords

          public DataTable addRecords(java.util.List<DataRecord> records)

      Description copied from interface: `DataTable`
      Adds new records to the table.
      Specified by:
        `addRecords` in interface `DataTable`

    - #### applyCachedFormat

          public boolean applyCachedFormat(java.util.Optional<FormatCache> formatCacheOpt)

      Specified by:
        `applyCachedFormat` in interface `DataTable`

    - #### getId

          public java.lang.Long getId()

      Returns table ID.
      Specified by:
        `getId` in interface `DataTable`

    - #### hasField

          public boolean hasField(java.lang.String field)

      Specified by:
        `hasField` in interface `DataTable`

    - #### validate

          public void validate(Context context,
                               ContextManager contextManager,
                               CallerController caller)
                        throws DataTableException

      Description copied from interface: `DataTable`
      Executes table validators to make sure table data is valid. Throws an error if validation fails.
      Specified by:
        `validate` in interface `DataTable`
      Throws:
        `DataTableException`

    - #### validateRecord

          public void validateRecord(DataRecord record)
                              throws ValidationException

      Description copied from interface: `DataTable`
      Executes validators of a specific record to make sure its data is valid. Throws an error if validation fails.
      Specified by:
        `validateRecord` in interface `DataTable`
      Throws:
        `ValidationException`

    - #### swapRecords

          public void swapRecords(int index1,
                                  int index2)

      Swaps two records. Both records must belong to this table, otherwise method will throw an `IllegalStateException`
      Specified by:
        `swapRecords` in interface `DataTable`

    - #### getRecords

          public java.util.List<DataRecord> getRecords()

      Returns list of table records.
      Specified by:
        `getRecords` in interface `DataTable`

    - #### isInvalid

          public boolean isInvalid()

      Specified by:
        `isInvalid` in interface `DataTable`

    - #### getInvalidationMessage

          public java.lang.String getInvalidationMessage()

      Specified by:
        `getInvalidationMessage` in interface `DataTable`

    - #### setInvalidationMessage

          public void setInvalidationMessage(java.lang.String invalidationMessage)

      Specified by:
        `setInvalidationMessage` in interface `DataTable`

    - #### getTimestamp

          public java.util.Date getTimestamp()

      Specified by:
        `getTimestamp` in interface `DataTable`
      Specified by:
        `getTimestamp` in interface `AttributedObject`

    - #### setTimestamp

          public void setTimestamp(java.util.Date timestamp)

      Specified by:
        `setTimestamp` in interface `DataTable`
      Specified by:
        `setTimestamp` in interface `AttributedObject`

    - #### getQuality

          public java.lang.Integer getQuality()

      Specified by:
        `getQuality` in interface `DataTable`
      Specified by:
        `getQuality` in interface `AttributedObject`

    - #### setQuality

          public void setQuality(java.lang.Integer quality)

      Specified by:
        `setQuality` in interface `DataTable`
      Specified by:
        `setQuality` in interface `AttributedObject`

    - #### getValue

          public java.lang.Object getValue()

      Specified by:
        `getValue` in interface `DataTable`
      Specified by:
        `getValue` in interface `AttributedObject`

    - #### getRecordById

          public DataRecord getRecordById(java.lang.String id)

      Specified by:
        `getRecordById` in interface `DataTable`

    - #### removeRecordsByIds

          public void removeRecordsByIds(java.util.Collection<java.lang.String> ids)

      Description copied from interface: `DataTable`
      Removes all records from the table which contain in ids.
      Specified by:
        `removeRecordsByIds` in interface `DataTable`

    - #### removeRecord

          public DataRecord removeRecord(int index)

      Removes record with specified index from the table.
      Specified by:
        `removeRecord` in interface `DataTable`

    - #### removeRecordImpl

          protected abstract DataRecord removeRecordImpl(int index)

    - #### getEncodedData

          public java.lang.String getEncodedData(ClassicEncodingSettings settings)

      Specified by:
        `getEncodedData` in interface `DataTable`

    - #### getEncodedData

          public java.lang.StringBuilder getEncodedData(java.lang.StringBuilder finalSB,
                                                        ClassicEncodingSettings settings,
                                                        java.lang.Boolean isTransferEncode,
                                                        java.lang.Integer encodeLevel)

      Specified by:
        `getEncodedData` in interface `DataTable`

    - #### encode

          public java.lang.String encode()

      Specified by:
        `encode` in interface `DataTable`

    - #### encode

          public java.lang.String encode(boolean useVisibleSeparators)

      Specified by:
        `encode` in interface `DataTable`

    - #### encode

          public java.lang.String encode(ClassicEncodingSettings settings)

      Specified by:
        `encode` in interface `DataTable`

    - #### encode

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

      Specified by:
        `encode` in interface `DataTable`
      Specified by:
        `encode` in interface `StringEncodable`

    - #### toString

          public java.lang.String toString()

      Specified by:
        `toString` in interface `DataTable`
      Overrides:
        `toString` in class `java.lang.Object`

    - #### getDescription

          public java.lang.String getDescription()

      Returns human-readable description of the table.
      Specified by:
        `getDescription` in interface `DataTable`

    - #### fixRecords

          public void fixRecords()

      Specified by:
        `fixRecords` in interface `DataTable`

    - #### dataAsString

          public java.lang.String dataAsString()

      Specified by:
        `dataAsString` in interface `DataTable`

    - #### dataAsString

          public java.lang.String dataAsString(boolean showFieldNames,
                                               boolean showHiddenFields)

      Specified by:
        `dataAsString` in interface `DataTable`

    - #### conform

          public boolean conform(TableFormat rf)

      Specified by:
        `conform` in interface `DataTable`

    - #### conformMessage

          public java.lang.String conformMessage(TableFormat rf)

      Specified by:
        `conformMessage` in interface `DataTable`

    - #### selectAll

          public java.util.List<DataRecord> selectAll(DataTableQuery query)

      Specified by:
        `selectAll` in interface `DataTable`

    - #### select

          public DataRecord select(DataTableQuery query)

      Specified by:
        `select` in interface `DataTable`

    - #### select

          public DataRecord select(java.lang.String field,
                                   java.lang.Object value)

      Specified by:
        `select` in interface `DataTable`

    - #### findIndex

          public java.lang.Integer findIndex(java.lang.String field,
                                             java.lang.Object value)

      Specified by:
        `findIndex` in interface `DataTable`

    - #### findIndex

          public java.lang.Integer findIndex(DataRecord record)

      Returns the index of the first occurrence of `record` in this Data Table, or null if this Data Table does not contain the specified record.
      Specified by:
        `findIndex` in interface `DataTable`

    - #### sort

          public void sort(java.lang.String field,
                           boolean ascending)

      Specified by:
        `sort` in interface `DataTable`

    - #### rec

          public DataRecord rec()

      Returns first record of the table.
      Specified by:
        `rec` in interface `DataTable`

    - #### get

          public java.lang.Object get()

      Returns value of first field in first record of the table.
      Specified by:
        `get` in interface `DataTable`

    - #### splitFormat

          public void splitFormat()

      Specified by:
        `splitFormat` in interface `DataTable`

    - #### joinFormats

          public void joinFormats()

      Specified by:
        `joinFormats` in interface `DataTable`

    - #### clone

          public DataTable clone()

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

    - #### append

          public void append(DataTable src)

      Specified by:
        `append` in interface `DataTable`

    - #### cloneIfImmutable

          public DataTable cloneIfImmutable()

      Specified by:
        `cloneIfImmutable` in interface `DataTable`

    - #### isImmutable

          public boolean isImmutable()

      Specified by:
        `isImmutable` in interface `DataTable`

    - #### close

          public void close()

      Specified by:
        `close` in interface `DataTable`

    - #### stream

          public java.util.stream.Stream<DataRecord> stream()

      Specified by:
        `stream` in interface `DataTable`