## org.eclipse.datatools.connectivity.oda
Class SortSpec

    java.lang.Object
      org.eclipse.datatools.connectivity.oda.SortSpec

    public class SortSpec

extends java.lang.Object

A class that encapsulates one or more sort keys for association with an IQuery. The class is designed to be extendable to accommodate additional ways of expressing a sort mode or key.

Field Summary
`static int` `sortAsc` The constant indicating ascending sort order.
`static int` `sortDesc` The constant indicating descending sort order.

Constructor Summary
`SortSpec(int sortMode)` Instantiates a `SortSpec` object for the defined `sortMode`.

Method Summary
`void` `addSortKey(java.lang.String columnName, int sortOrder)` Specifies the dynamic sort criteria in this sort mode.
`java.lang.String` `getSortColumn(int index)` Returns the result set column name of the sort key at the `index` position.
`java.lang.String[]` `getSortColumns()` Returns an array of all column names for the sort key of a `sortModeSingleOrder` `SortSpec` object.
`int` `getSortKeyCount()` Returns the number of sort keys associated with this `SortSpec` object.
`int` `getSortMode()` Returns the sort mode of this `SortSpec` object.
`int` `getSortOrder()` Returns the sort order for the sort keys of a `sortModeSingleOrder` `SortSpec` object.
`int` `getSortOrder(int index)` Returns the sort order of the sort key at the `index` position.
`void` `setLocale(ULocale locale)` Deprecated. obsolete; migrated to use NLS Messages class
`java.lang.String` `toString()` Returns a string representation of this `SortSpec`.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### sortAsc

    public static final int sortAsc

  The constant indicating ascending sort order.

  See Also:
    Constant Field Values

### sortDesc

    public static final int sortDesc

  The constant indicating descending sort order.

  See Also:
    Constant Field Values

Constructor Detail

### SortSpec

    public SortSpec(int sortMode)

  Instantiates a `SortSpec` object for the defined `sortMode`.

  Parameters:
    `sortMode` - the sort mode of this `SortSpec`; one of `IDataSetMetaData.sortModeNone`, `IDataSetMetaData.sortModeSingleOrder`, `IDataSetMetaData.sortModeColumnOrder`, `IDataSetMetaData.sortModeSingleColumn`.
  Throws:
    `java.lang.IllegalArgumentException` - if the `sortMode` is not a valid value.

Method Detail

### addSortKey

    public void addSortKey(java.lang.String columnName,
                           int sortOrder)

  Specifies the dynamic sort criteria in this sort mode. The sort criteria are specified by an ODA consumer, using an ordered list of one or more sort keys. The adding sequence of each sortKey corresponds to the major-to-minor ordering. Validation is done against this `SortSpec`'s sortMode; i.e. the method throws an exception when adding a sort key that does not conform to the sortMode of this `SortSpec` object.

  Parameters:
    `columnName` - name of the result set column to apply dynamic sorting on. The specified column should be one of the columns retrieved in a result set.
    `sortOrder` - value that represents the sorting order; one of `sortAsc`, `sortDesc`.
  Throws:
    `java.lang.NullPointerException` - if `columnName` is null.
    `java.lang.IllegalArgumentException` - if `columnName` is empty; or if `sortOrder` is not `sortAsc` or `sortDesc`.
    `java.lang.IllegalStateException` - if the sortMode of this `SortSpec` is `IDataSetMetaData.sortModeNone`; or if the sortMode of this `SortSpec` is `IDataSetMetaData.sortModeSingleColumn`, and a sort key is already associated; or if the sortMode of this `SortSpec` is `IDataSetMetaData.sortModeSingleOrder` and the sort order does not match existing sort orders.

### getSortMode

    public int getSortMode()

  Returns the sort mode of this `SortSpec` object.

  Returns:
    the sort mode of this `SortSpec`; one of `IDataSetMetaData.sortModeNone`, `IDataSetMetaData.sortModeSingleOrder`, `IDataSetMetaData.sortModeColumnOrder`, `IDataSetMetaData.sortModeSingleColumn`.

### getSortKeyCount

    public int getSortKeyCount()

  Returns the number of sort keys associated with this `SortSpec` object.

  Returns:
    the number of sort keys associated with this `SortSpec` object.

### getSortColumn

    public java.lang.String getSortColumn(int index)

  Returns the result set column name of the sort key at the `index` position.

  Parameters:
    `index` - index of the sort key (1-based).
  Returns:
    the name of the result set column for the specified sort key.
  Throws:
    `java.lang.IndexOutOfBoundsException` - if `index` is out of range (index < 1 || index > getSortKeyCount()).

### getSortOrder

    public int getSortOrder(int index)

  Returns the sort order of the sort key at the `index` position.

  Parameters:
    `index` - index of the sort key (1-based).
  Returns:
    the sort order for the specified sort key.
  Throws:
    `java.lang.IndexOutOfBoundsException` - if `index` is out of range (index < 1 || index > getSortKeyCount()).

### getSortColumns

    public java.lang.String[] getSortColumns()

  Returns an array of all column names for the sort key of a `sortModeSingleOrder` `SortSpec` object.

  Returns:
    an array of all column names for the sort keys of a `sortModeSingleOrder` `SortSpec` object; an empty array if no sort keys are associated with this `SortSpec`.
  Throws:
    `java.lang.IllegalStateException` - if this `SortSpec`'s sort mode is not `sortModeSingleOrder`.

### getSortOrder

    public int getSortOrder()

  Returns the sort order for the sort keys of a `sortModeSingleOrder` `SortSpec` object.

  Returns:
    the sort order for the sort keys of a `sortModeSingleOrder` `SortSpec` object; the default value, `sortAsc`, if no sort keys are associated with this `SortSpec`.
  Throws:
    `java.lang.IllegalStateException` - if this `SortSpec`'s sort mode is not `sortModeSingleOrder`.

### setLocale

    public void setLocale(ULocale locale)

  Deprecated. obsolete; migrated to use NLS Messages class

  Sets the locale of this `SortSpec`. Enables this `SortSpec` to return localized error messages. The default locale is `en_US`.

  Parameters:
    `locale` - the locale used for localizing error messages.

### toString

    public java.lang.String toString()

  Returns a string representation of this `SortSpec`.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    a string representation of this `SortSpec`.

Copyright © 2006 -- 2008 Actuate, IBM Corporation, Sybase, Inc. and others. All rights reserved.