Package uk.ac.starlink.ttools.jel
Class ColumnIdentifier
java.lang.Object
uk.ac.starlink.ttools.jel.ColumnIdentifier
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 -
Method Summary
Modifier and TypeMethodDescriptionboolean[]
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 incolIdList
.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
Determines whether case is significant in column names.void
setCaseSensitive
(boolean caseSensitive) Sets whether case is significant in column names.
-
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
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, anIOException
is thrown.- Parameters:
colid
- identifying string- Returns:
- column index
- Throws:
IOException
- ifcolid
does not name a column
-
getColumnIndices
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)
- Parameters:
colidList
- string containing a representation of a list of columns- Returns:
- array of column indices
- Throws:
IOException
- ifcolid
doesn't look like a colid-list specifier
-
getColumnFlags
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 incolIdList
. This convenience function just works on the result ofgetColumnIndices(java.lang.String)
.- Parameters:
colIdList
- string containing a representation of a list of columns- Returns:
- array of column inclusion flags
- Throws:
IOException
- ifcolid
doesn't look like a colid-list specifier
-
globToRegex
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: Ifglob
contains no wildcards,null
will be returned.- Parameters:
glob
- glob patterncaseSensitive
- whether matching should be case sensitive- Returns:
- equivalent regular expression pattern, or null if
glob
is trivial
-