Package org.h2.table

# Class IndexColumn

java.lang.Object
org.h2.table.IndexColumn

public class IndexColumn extends Object
This represents a column item of an index. This is required because some indexes support descending sorted columns.

## Field Summary

Fields
Modifier and Type
Field
Description
`Column`
`column`
The column, or null if not set.
`final String`
`columnName`
The column name.
`int`
`sortType`
The sort type.
`static final int`
`SQL_NO_ORDER`
Do not append ordering.

## Constructor Summary

Constructors
Constructor
Description
`IndexColumn(String columnName)`
Creates a new instance with the specified name.
`IndexColumn(String columnName, int sortType)`
Creates a new instance with the specified name.
`IndexColumn(Column column)`
Creates a new instance with the specified column.

## Method Summary

Modifier and Type
Method
Description
`StringBuilder`
`getSQL(StringBuilder builder, int sqlFlags)`
Appends the SQL snippet for this index column to the specified string builder.
`static void`
`mapColumns(IndexColumn[] indexColumns, Table table)`
Map the columns using the column names and the specified table.
`String`
`toString()`
`static IndexColumn[]`
`wrap(Column[] columns)`
Create an array of index columns from a list of columns.
`static StringBuilder`
`writeColumns(StringBuilder builder, IndexColumn[] columns, int sqlFlags)`
Appends the specified columns to the specified builder.
`static StringBuilder`
`writeColumns(StringBuilder builder, IndexColumn[] columns, int startOffset, int endOffset, int sqlFlags)`
Appends the specified columns to the specified builder.
`static StringBuilder`
`writeColumns(StringBuilder builder, IndexColumn[] columns, String separator, String suffix, int sqlFlags)`
Appends the specified columns to the specified builder.

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

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

## Field Details

### SQL_NO_ORDER

public static final int SQL_NO_ORDER
Do not append ordering.

See Also:
  - Constant Field Values

### columnName

public final String columnName
The column name.

### column

public Column column
The column, or null if not set.

### sortType

public int sortType
The sort type. Ascending (the default) and descending are supported; nulls can be sorted first or last.

## Constructor Details

### IndexColumn

public IndexColumn(String columnName)
Creates a new instance with the specified name.

Parameters:
  `columnName` - the column name

### IndexColumn

public IndexColumn(String columnName, int sortType)
Creates a new instance with the specified name.

Parameters:
  `columnName` - the column name
  `sortType` - the sort type

### IndexColumn

public IndexColumn(Column column)
Creates a new instance with the specified column.

Parameters:
  `column` - the column

## Method Details

### writeColumns

public static StringBuilder writeColumns(StringBuilder builder, IndexColumn[] columns, int sqlFlags)
Appends the specified columns to the specified builder.

Parameters:
  `builder` - string builder
  `columns` - index columns
  `sqlFlags` - formatting flags
Returns:
  the specified string builder

### writeColumns

public static StringBuilder writeColumns(StringBuilder builder, IndexColumn[] columns, int startOffset, int endOffset, int sqlFlags)
Appends the specified columns to the specified builder.

Parameters:
  `builder` - string builder
  `columns` - index columns
  `startOffset` - start offset, inclusive
  `endOffset` - end offset, exclusive
  `sqlFlags` - formatting flags
Returns:
  the specified string builder

### writeColumns

public static StringBuilder writeColumns(StringBuilder builder, IndexColumn[] columns, String separator, String suffix, int sqlFlags)
Appends the specified columns to the specified builder.

Parameters:
  `builder` - string builder
  `columns` - index columns
  `separator` - separator
  `suffix` - additional SQL to append after each column
  `sqlFlags` - formatting flags
Returns:
  the specified string builder

### getSQL

public StringBuilder getSQL(StringBuilder builder, int sqlFlags)
Appends the SQL snippet for this index column to the specified string builder.

Parameters:
  `builder` - string builder
  `sqlFlags` - formatting flags
Returns:
  the specified string builder

### wrap

public static IndexColumn[] wrap(Column[] columns)
Create an array of index columns from a list of columns. The default sort type is used.

Parameters:
  `columns` - the column list
Returns:
  the index column array

### mapColumns

public static void mapColumns(IndexColumn[] indexColumns, Table table)
Map the columns using the column names and the specified table.

Parameters:
  `indexColumns` - the column list with column names set
  `table` - the table from where to map the column names to columns

### toString

public String toString()

Overrides:
  `toString` in class `Object`