Package uk.ac.starlink.ttools.jel
Class ColumnIdentifier
- java.lang.Object
-
- uk.ac.starlink.ttools.jel.ColumnIdentifier
-
public class ColumnIdentifier extends java.lang.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 (seeJELRowReader
) 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean[]
getColumnFlags(java.lang.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(java.lang.String colid)
Returns the index of a column given an identifying string.int[]
getColumnIndices(java.lang.String colidList)
Returns an array of column indices from a<colid-list>
string.static java.util.regex.Pattern
globToRegex(java.lang.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.
-
-
-
Method Detail
-
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(java.lang.String colid) throws java.io.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:
java.io.IOException
- if colid does not name a column
-
getColumnIndices
public int[] getColumnIndices(java.lang.String colidList) throws java.io.IOException
Returns an array of column indices from a<colid-list>
string. The string is split up into whitespace-separated tokens, 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.- Parameters:
colidList
- string containing a representation of a list of columns- Returns:
- array of column indices
- Throws:
java.io.IOException
- if colid doesn't look like a colid-list specifier
-
getColumnFlags
public boolean[] getColumnFlags(java.lang.String colIdList) throws java.io.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 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:
java.io.IOException
- if colid doesn't look like a colid-list specifier
-
globToRegex
public static java.util.regex.Pattern globToRegex(java.lang.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: 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
-
-