com.tibbo.aggregate.common.datatable

## Class SimpleDataTable

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

- All Implemented Interfaces:
    DataTable, AttributedObject, PublicCloneable, StringEncodable, java.lang.Cloneable, java.lang.Comparable<DataTable>, java.lang.Iterable<DataRecord>

      public class SimpleDataTable
      extends AbstractDataTable
      implements java.lang.Comparable<DataTable>, java.lang.Cloneable

  `DataTable` is a tabular structure that consist of `TableFormat` describing table fields and other options and a number of `DataRecord` objects representing individual records.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static DataTable` | `EMPTY_TABLE`

    - ### Fields inherited from class com.tibbo.aggregate.common.datatable.AbstractDataTable

      `DEFAULT_FORMAT, ELEMENT_ID`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleDataTable()` Constructs a default `DataTable` with empty `TableFormat` and zero records.
    `SimpleDataTable(DataRecord record)` Constructs a `DataTable` with one record specified by `record` parameter.
    `SimpleDataTable(ElementList elements, ClassicEncodingSettings settings, boolean validate)`
    `SimpleDataTable(java.lang.String data)` Decodes `DataTable` from string.
    `SimpleDataTable(java.lang.String data, boolean validate)` Decodes `DataTable` from string and checks its validity.
    `SimpleDataTable(java.lang.String data, ClassicEncodingSettings settings, boolean validate)`
    `SimpleDataTable(TableFormat format)` Constructs a `DataTable` with specified `TableFormat` and zero records.
    `SimpleDataTable(TableFormat format, boolean createEmptyRecords)` Constructs a `DataTable` with specified `TableFormat` and adds empty records to it.
    `SimpleDataTable(TableFormat format, int emptyRecords)` Constructs a `DataTable` with specified `TableFormat` and adds `emptyRecords` of empty records to it.
    `SimpleDataTable(TableFormat format, java.lang.Object... firstRowData)` Constructs a `DataTable` with specified `TableFormat`, adds one record and fills it with data.
    `SimpleDataTable(TableFormat format, java.lang.String dataString, ClassicEncodingSettings settings)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DataRecord` | `addRecord()` Adds new record to the table.
    `DataTable` | `addRecord(DataRecord record)` Adds new record to the table.
    `DataTable` | `addRecord(int index, DataRecord record)` Adds new record to the table at the specified index.
    `DataRecord` | `addRecord(java.lang.Object... fieldValues)` Adds new record to the table.
    `DataTable` | `clone()`
    `int` | `compareTo(DataTable other)`
    `java.lang.String` | `conformMessage(TableFormat rf)`
    `java.lang.String` | `dataAsString(boolean showFieldNames, boolean showHiddenFields, boolean showPasswords)`
    `boolean` | `equals(java.lang.Object obj)`
    `java.lang.Integer` | `findIndex(DataTableQuery query)`
    `java.lang.Object` | `get()` Returns value of first field in first record of the table.
    `DataRecord` | `getRecord(int number)` Returns record with specified index.
    `java.lang.Integer` | `getRecordCount()` Returns number of records in the table.
    `java.util.List<DataRecord>` | `getRecords()` Returns list of table records.
    `int` | `hashCode()`
    `boolean` | `isOneCellTable()` Returns true if table has exactly one record and one field.
    `boolean` | `isSimple()`
    `java.util.Iterator<DataRecord>` | `iterator()`
    `java.util.Iterator<DataRecord>` | `iterator(int index)`
    `void` | `joinFormats()`
    `DataTable` | `makeImmutable()`
    `protected DataRecord` | `removeRecordImpl(int index)`
    `void` | `removeRecords(DataRecord rec)` Removes all records equal to the rec parameter from the table.
    `void` | `removeRecordsByIds(java.util.Collection<java.lang.String> ids)` Removes all records from the table which contain in ids.
    `void` | `reorderRecord(DataRecord record, int index)` Moves specified record to position specified by `index` argument.
    `void` | `setId(java.lang.Long id)` Sets table ID.
    `DataTable` | `setRecord(int index, DataRecord record)` Replaces record at the specified index.
    `void` | `sort(java.util.Comparator<DataRecord> comparator)`
    `void` | `sort(DataTableSorter sorter)`
    `void` | `splitFormat()`
    `java.util.stream.Stream<DataRecord>` | `stream()`
    `void` | `swapRecords(int index1, int index2)` Swaps two records.
    `java.lang.String` | `toDefaultString()`

    - ### Methods inherited from class com.tibbo.aggregate.common.datatable.AbstractDataTable

      `addRecords, append, applyCachedFormat, cloneIfImmutable, close, conform, dataAsString, dataAsString, encode, encode, encode, encode, findIndex, findIndex, fixRecords, getDescription, getEncodedData, getEncodedData, getFieldCount, getFormat, getFormat, getFormat, getId, getInvalidationMessage, getQuality, getRecordById, getTimestamp, getValue, hasField, isImmutable, isInvalid, rec, removeRecord, select, select, selectAll, setFormat, setInvalidationMessage, setQuality, setTimestamp, sort, toString, validate, validateRecord`

    - ### 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_TABLE

          public static final DataTable EMPTY_TABLE

  - ### Constructor Detail

    - #### SimpleDataTable

          public SimpleDataTable()

      Constructs a default `DataTable` with empty `TableFormat` and zero records.

    - #### SimpleDataTable

          public SimpleDataTable(TableFormat format)

      Constructs a `DataTable` with specified `TableFormat` and zero records.

    - #### SimpleDataTable

          public SimpleDataTable(TableFormat format,
                                 int emptyRecords)

      Constructs a `DataTable` with specified `TableFormat` and adds `emptyRecords` of empty records to it.

    - #### SimpleDataTable

          public SimpleDataTable(TableFormat format,
                                 boolean createEmptyRecords)

      Constructs a `DataTable` with specified `TableFormat` and adds empty records to it. If `createEmptyRecords` parameter is true, a minimal number of empty records specified by `TableFormat` is added to the table.

    - #### SimpleDataTable

          public SimpleDataTable(DataRecord record)

      Constructs a `DataTable` with one record specified by `record` parameter. `TableFormat` of resulting table is taken from format of `record`.

    - #### SimpleDataTable

          public SimpleDataTable(TableFormat format,
                                 java.lang.String dataString,
                                 ClassicEncodingSettings settings)
                          throws DataTableException

      Throws:
        `DataTableException`

    - #### SimpleDataTable

          public SimpleDataTable(TableFormat format,
                                 java.lang.Object... firstRowData)

      Constructs a `DataTable` with specified `TableFormat`, adds one record and fills it with data. Data to be put into the first record is specified by `firstRowData` parameter.

    - #### SimpleDataTable

          public SimpleDataTable(java.lang.String data)
                          throws DataTableException

      Decodes `DataTable` from string.
      Throws:
        `DataTableException`

    - #### SimpleDataTable

          public SimpleDataTable(java.lang.String data,
                                 boolean validate)
                          throws DataTableException

      Decodes `DataTable` from string and checks its validity.
      Throws:
        `DataTableException`

    - #### SimpleDataTable

          public SimpleDataTable(java.lang.String data,
                                 ClassicEncodingSettings settings,
                                 boolean validate)
                          throws DataTableException

      Throws:
        `DataTableException`

    - #### SimpleDataTable

          public SimpleDataTable(ElementList elements,
                                 ClassicEncodingSettings settings,
                                 boolean validate)
                          throws DataTableException

      Throws:
        `DataTableException`

  - ### Method Detail

    - #### getRecordCount

          public java.lang.Integer getRecordCount()

      Returns number of records in the table.
      Specified by:
        `getRecordCount` in interface `DataTable`

    - #### setId

          public void setId(java.lang.Long id)

      Sets table ID.
      Specified by:
        `setId` in interface `DataTable`

    - #### addRecord

          public DataTable addRecord(DataRecord record)

      Adds new record to the table.
      Specified by:
        `addRecord` in interface `DataTable`

    - #### addRecord

          public DataRecord addRecord(java.lang.Object... fieldValues)

      Adds new record to the table.
      Specified by:
        `addRecord` in interface `DataTable`

    - #### addRecord

          public DataTable addRecord(int index,
                                     DataRecord record)

      Adds new record to the table at the specified index.
      Specified by:
        `addRecord` in interface `DataTable`

    - #### addRecord

          public DataRecord addRecord()

      Adds new record to the table.
      Specified by:
        `addRecord` in interface `DataTable`

    - #### setRecord

          public DataTable setRecord(int index,
                                     DataRecord record)

      Replaces record at the specified index.
      Specified by:
        `setRecord` in interface `DataTable`

    - #### 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`
      Overrides:
        `swapRecords` in class `AbstractDataTable`

    - #### getRecords

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

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

    - #### getRecord

          public DataRecord getRecord(int number)

      Returns record with specified index.
      Specified by:
        `getRecord` in interface `DataTable`

    - #### removeRecordImpl

          protected DataRecord removeRecordImpl(int index)

      Specified by:
        `removeRecordImpl` in class `AbstractDataTable`

    - #### 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`
      Overrides:
        `removeRecordsByIds` in class `AbstractDataTable`

    - #### removeRecords

          public void removeRecords(DataRecord rec)

      Removes all records equal to the rec parameter from the table.
      Specified by:
        `removeRecords` in interface `DataTable`

    - #### reorderRecord

          public void reorderRecord(DataRecord record,
                                    int index)

      Moves specified record to position specified by `index` argument. `record`must belong to this table, otherwise method will throw an `IllegalStateException```
      Specified by:
        `reorderRecord` in interface `DataTable`

    - #### equals

          public boolean equals(java.lang.Object obj)

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

    - #### hashCode

          public int hashCode()

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

    - #### toDefaultString

          public java.lang.String toDefaultString()

      Specified by:
        `toDefaultString` in interface `DataTable`

    - #### dataAsString

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

      Specified by:
        `dataAsString` in interface `DataTable`

    - #### isOneCellTable

          public boolean isOneCellTable()

      Returns true if table has exactly one record and one field.
      Specified by:
        `isOneCellTable` in interface `DataTable`

    - #### conformMessage

          public java.lang.String conformMessage(TableFormat rf)

      Specified by:
        `conformMessage` in interface `DataTable`
      Overrides:
        `conformMessage` in class `AbstractDataTable`

    - #### findIndex

          public java.lang.Integer findIndex(DataTableQuery query)

      Specified by:
        `findIndex` in interface `DataTable`

    - #### sort

          public void sort(DataTableSorter sorter)

      Specified by:
        `sort` in interface `DataTable`

    - #### sort

          public void sort(java.util.Comparator<DataRecord> comparator)

      Specified by:
        `sort` in interface `DataTable`

    - #### get

          public java.lang.Object get()

      Description copied from class: `AbstractDataTable`
      Returns value of first field in first record of the table.
      Specified by:
        `get` in interface `DataTable`
      Overrides:
        `get` in class `AbstractDataTable`

    - #### splitFormat

          public void splitFormat()

      Specified by:
        `splitFormat` in interface `DataTable`
      Overrides:
        `splitFormat` in class `AbstractDataTable`

    - #### joinFormats

          public void joinFormats()

      Specified by:
        `joinFormats` in interface `DataTable`
      Overrides:
        `joinFormats` in class `AbstractDataTable`

    - #### iterator

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

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

    - #### iterator

          public java.util.Iterator<DataRecord> iterator(int index)

      Specified by:
        `iterator` in interface `DataTable`

    - #### clone

          public DataTable clone()

      Specified by:
        `clone` in interface `DataTable`
      Specified by:
        `clone` in interface `PublicCloneable`
      Overrides:
        `clone` in class `AbstractDataTable`

    - #### compareTo

          public int compareTo(DataTable other)

      Specified by:
        `compareTo` in interface `DataTable`
      Specified by:
        `compareTo` in interface `java.lang.Comparable<DataTable>`

    - #### makeImmutable

          public DataTable makeImmutable()

      Specified by:
        `makeImmutable` in interface `DataTable`

    - #### isSimple

          public boolean isSimple()

      Specified by:
        `isSimple` in interface `DataTable`

    - #### stream

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

      Specified by:
        `stream` in interface `DataTable`
      Overrides:
        `stream` in class `AbstractDataTable`