# Class ColumnIdentifier

java.lang.Object
uk.ac.starlink.ttools.jel.ColumnIdentifier

public class ColumnIdentifier extends Object
Can identify columns of a table using string identifiers. Permitted identifiers are (currently) column name (case insensitive), column index (1-based), ucd$* / utype$* style UCD/Utype specifiers (see `JELRowReader`) and where requested cases simple wildcarding expressions.

Since:
  2 Mar 2005
Author:
  Mark Taylor (Starlink)

## Constructor Summary

Constructors
Constructor
Description
`ColumnIdentifier(uk.ac.starlink.table.StarTable table)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`boolean[]`
`getColumnFlags(String colIdList)`
Returns an array of flags, the same length as the number of columns in the table, with an element set true for each column which is specified in `colIdList`.
`int`
`getColumnIndex(String colid)`
Returns the index of a column given an identifying string.
`int[]`
`getColumnIndices(String colidList)`
Returns an array of column indices from a `<colid-list>` string.
`static Pattern`
`globToRegex(String glob, boolean caseSensitive)`
Turns a glob-type pattern into a regular expression Pattern.
`boolean`
`isCaseSensitive()`
Determines whether case is significant in column names.
`void`
`setCaseSensitive(boolean caseSensitive)`
Sets whether case is significant in column names.

### Methods inherited from class Object

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

## Constructor Details

### ColumnIdentifier

public ColumnIdentifier(uk.ac.starlink.table.StarTable table)
Constructor.

Parameters:
  `table` - table whose columns this identifier can identify

## Method Details

### setCaseSensitive

public void setCaseSensitive(boolean caseSensitive)
Sets whether case is significant in column names. By default it is not.

Parameters:
  `caseSensitive` - is matching case sensitive?

### isCaseSensitive

public boolean isCaseSensitive()
Determines whether case is significant in column names. By default it is not.

Returns:
  true iff matching is case sensitive

### getColumnIndex

public int getColumnIndex(String colid) throws IOException
Returns the index of a column given an identifying string. If the string can't be identified as a column of this object's table, an `IOException` is thrown.

Parameters:
  `colid` - identifying string
Returns:
  column index
Throws:
  `IOException` - if `colid` does not name a column

### getColumnIndices

public int[] getColumnIndices(String colidList) throws IOException
Returns an array of column indices from a `<colid-list>` string. The string is split up into whitespace-separated tokens, each of which must be one of:

- identifier for an individual column
- glob-like pattern containing "*", matching zero or more columns
- column range of the form <col1>-<colN> (inclusive)

and each element must either be the identifier of an individual column or a non-trivial glob-like pattern which may match zero or more columns, or a column range.

Parameters:
  `colidList` - string containing a representation of a list of columns
Returns:
  array of column indices
Throws:
  `IOException` - if `colid` doesn't look like a colid-list specifier

### getColumnFlags

public boolean[] getColumnFlags(String colIdList) throws IOException
Returns an array of flags, the same length as the number of columns in the table, with an element set true for each column which is specified in `colIdList`. This convenience function just works on the result of `getColumnIndices(String)`.

Parameters:
  `colIdList` - string containing a representation of a list of columns
Returns:
  array of column inclusion flags
Throws:
  `IOException` - if `colid` doesn't look like a colid-list specifier

### globToRegex

public static Pattern globToRegex(String glob, boolean caseSensitive)
Turns a glob-type pattern into a regular expression Pattern. Currently the only construction recognised is a "*" at one or more places in the string, which will match any sequence of characters. Note: If `glob` contains no wildcards, `null` will be returned.

Parameters:
  `glob` - glob pattern
  `caseSensitive` - whether matching should be case sensitive
Returns:
  equivalent regular expression pattern, or null if `glob` is trivial