Class 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 (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

      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 in colIdList.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ColumnIdentifier

        public ColumnIdentifier​(uk.ac.starlink.table.StarTable table)
        Constructor.
        Parameters:
        table - table whose columns this identifier can identify
    • 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, 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:
        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 in colIdList. This convenience function just works on the result of getColumnIndices(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: 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