Class DataRowLayout

java.lang.Object
org.apache.cayenne.DataRowLayout
All Implemented Interfaces:
Serializable

public final class DataRowLayout extends Object implements Serializable
The layout of a DataRow: the column names in column order, with a lookup of a name to its position. A row holds its values by position in its layout, and all the rows of one result set share a layout. Layouts are immutable and compared by identity, so two rows share a layout only when they came from the same reader. A layout is serializable, and the rows serialized in one stream keep sharing theirs.

A consumer that needs a fixed set of columns from rows of any layouts builds a layout of those names and reads them through a DataRowLayout.Reader of it.

Since:
5.0
See Also:
  • Method Details

    • of

      public static DataRowLayout of(String... names)
      Returns a layout of the given column names, in the given order. A repeated name is deduplicated: the last occurrence keeps the name, the way the last put wins in a map, and each earlier one is renamed with an underscore appended until it is unique.
    • size

      public int size()
      Returns the number of columns.
    • indexOf

      public int indexOf(String name)
      Returns the position of the named column, or -1 if there is no such column.
    • nameAt

      public String nameAt(int index)
      Returns the name of the column at the given position.
    • reader

      public DataRowLayout.Reader reader()
      Returns a reader of the columns of this layout from rows of any layouts.
    • toString

      public String toString()
      Overrides:
      toString in class Object