Module org.firebirdsql.jaybird
Package org.firebirdsql.gds.ng.fields

# Class RowValue

java.lang.Object
org.firebirdsql.gds.ng.fields.RowValue

public sealed class RowValue extends Object
Collection of values of fields. Usually row or parameter values.

Since:
  3.0
Author:
  Mark Rotteveel

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final RowValue`
  `EMPTY_ROW_VALUE`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final RowValue`
  `deepCopy()`
  Copies this `RowValue` and the values it contains.
  `static RowValue`
  `defaultFor(RowDescriptor rowDescriptor)`
  Convenience method for creating a default, uninitialized, row value for a `RowDescriptor`.
  `static RowValue`
  `deletedRowMarker(int count)`
  Creates a row value that can serve as a deleted row marker.
  `final int`
  `getCount()`
  `final byte[]`
  `getFieldData(int index)`
  Get the data of the field with `index`.
  `final int`
  `initializedCount()`
  `final void`
  `initializeFields()`
  Initializes uninitialized fields with `null`.
  `boolean`
  `isDeletedRowMarker()`
  Does this row value serve as a deleted row marker.
  `final boolean`
  `isInitialized(int index)`
  Is the field with `index` initialized.
  `static RowValue`
  `of(byte[]... rowData)`
  Convenience method for populating a row value from byte arrays.
  `static RowValue`
  `of(RowDescriptor rowDescriptor, byte[]... rowData)`
  Convenience method for populating a row value from a RowDescriptor and byte arrays.
  `void`
  `reset()`
  Resets the state of this row value to uninitialized.
  `void`
  `setFieldData(int index, byte[] data)`
  Sets the data of the field with `index`.

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

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

- ## Field Details

  - ### EMPTY_ROW_VALUE

    public static final RowValue EMPTY_ROW_VALUE

- ## Method Details

  - ### getCount

    public final int getCount()
    Returns:
      The number of fields.

  - ### setFieldData

    public void setFieldData(int index, byte[] data)
    Sets the data of the field with `index`.
    Parameters:
      `index` - Index of the field
      `data` - byte array with data for field, or `null`
    Throws:
      `IndexOutOfBoundsException` - if index is not `0 <= index > getCount()`

  - ### getFieldData

    public final byte[] getFieldData(int index)
    Get the data of the field with `index`.

    For uninitialized fields, returns `null`. To distinguish between uninitialized or initialized with `null`, use `isInitialized(int)`.

    Parameters:
      `index` - Index of the field
    Returns:
      byte array with data for field, or `null`
    Throws:
      `IndexOutOfBoundsException` - if index is not `0 <= index > getCount()`

  - ### reset

    public void reset()
    Resets the state of this row value to uninitialized.
    Since:
      4

  - ### isDeletedRowMarker

    public boolean isDeletedRowMarker()
    Does this row value serve as a deleted row marker.

    This is not general purpose functionality, but exists solely to detect deleted rows in updatable result sets.

    Returns:
      `true` if this a deleted row marker, `false` otherwise
    Since:
      5

  - ### initializeFields

    public final void initializeFields()
    Initializes uninitialized fields with `null`.
    Since:
      5

  - ### isInitialized

    public final boolean isInitialized(int index)
    Is the field with `index` initialized.
    Parameters:
      `index` - Index of the field
    Returns:
      `true` if the field is initialized
    Throws:
      `IndexOutOfBoundsException` - if index is not `0 <= index > getCount()`
    Since:
      4

  - ### initializedCount

    public final int initializedCount()
    Returns:
      number of initialized fields in this row value
    Since:
      6

  - ### defaultFor

    public static RowValue defaultFor(RowDescriptor rowDescriptor)
    Convenience method for creating a default, uninitialized, row value for a `RowDescriptor`.
    Parameters:
      `rowDescriptor` - The row descriptor
    Returns:
      `RowValue` object
    Since:
      4

  - ### of

    public static RowValue of(RowDescriptor rowDescriptor, byte[]... rowData)
    Convenience method for populating a row value from a RowDescriptor and byte arrays.

    Note this method is mainly intended for use in `FBDatabaseMetaData`.

    Compared to `of(byte[][])`, this method has the advantage that it checks if the number of byte arrays is consistent with the row descriptor.

    Parameters:
      `rowDescriptor` - The row descriptor
      `rowData` - An array of byte arrays with the field data.
    Returns:
      new `RowValue` object
    Throws:
      `IllegalArgumentException` - If the `rowData` byte array count does not match field count of the row descriptor

  - ### deletedRowMarker

    public static RowValue deletedRowMarker(int count)
    Creates a row value that can serve as a deleted row marker.

    All fields have a value of `null`, and updates will fail with an `UnsupportedOperationException`.

    Parameters:
      `count` - The number of columns
    Returns:
      `RowValue` object
    Since:
      5

  - ### of

    public static RowValue of(byte[]... rowData)
    Convenience method for populating a row value from byte arrays.

    This method is mainly intended for use with direct manipulation in the low-level gds-ng API.

    Parameters:
      `rowData` - An array of byte arrays with the field data.
    Returns:
      new `RowValue` object
    See Also:
      - `of(RowDescriptor, byte[][])`

  - ### deepCopy

    public final RowValue deepCopy()
    Copies this `RowValue` and the values it contains.

    As the field values are mutable, it is important to consider whether you need to be able to see modifications to the field data, or if you need fields with the same original data. If the former, pass the original, if the latter use this method to obtain a copy.

    Returns:
      Copy of this object with cloned field values, for empty rows (count is 0) `EMPTY_ROW_VALUE`.