Package uk.ac.starlink.topcat.contrib.gavo

## Class GavoCSVTableParser

- java.lang.Object
- - uk.ac.starlink.topcat.contrib.gavo.GavoCSVTableParser

-     public class GavoCSVTableParser
      extends java.lang.Object

  Class for a parser that can parse CSV input streams, such as those produced by GAVO's database query web apps.

  We follow and expand on the specification for CSV files as detailed in http://www.edoceo.com/utilis/csv-file-format.php. We expand on this by allowing zero, one or more header lines. If header lines are there, we assume the last one to give the names of the columns. By default we assume 1 header line is available, the actual number may be set in the appropriate parseCSV method.

  We do allow for delimiters different from a comma, but we treat their occurence exactly as otherwise the comma would be treated according to the specification.

  We do NOT allow for string demarcations different from the double-quote.

  A a final touch we allow for "comment" lines starting with a comment string. Lines starting with the comment string (e.g. ";;") will be ignored (but see next paragraph). This is needed in order to be able to successfully parse CSV files as output by CDS/Vizier, or the GAVO "simpledb" web applications.

  Addition: we assume that there are comment lines starting with "#COLUMN" which indicate metadata about all the columns. We assume that the first line without "#" symbol contains the column names. All subsequent rows are data.

  Author:
    Gerard Lemson, Hans-Martin Adorf, Gerard Lemson, Mark Taylor

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `GavoCSVTableParser.RecursiveDescentParser` | Recursive descent parser for parsing a single line

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static java.lang.String` | `DEFAULT_COMMENT_PREFIX` | The default comment prefix
    `static java.lang.String` | `DEFAULT_DELIMITER` | The default delimiter between table entries

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `GavoCSVTableParser​(uk.ac.starlink.table.StoragePolicy storage, java.awt.Component parent)` | Creates a new instance of CSVTableParser
    `GavoCSVTableParser​(uk.ac.starlink.table.StoragePolicy storage, java.awt.Component parent, java.lang.String delimiter)` | Creates a new instance of CSVTableParser

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static java.lang.Class` | `classForJDBCType​(int jdbcType)` |
    `java.lang.String` | `getCommentPrefix()` | Getter for property commentPrefix.
    `java.lang.String` | `getDelimiter()` | Gets the delimiter.
    `static java.lang.Object` | `objectForJDBCType​(int jdbcType, java.lang.String value)` |
    `uk.ac.starlink.table.StarTable` | `parse​(java.io.InputStream stream)` |
    `java.util.List` | `parseLine​(java.lang.String line)` | Return a List of tokens (Strings) from the specified line, delimited by the specified delimiter.
    `void` | `setDelimiter​(java.lang.String delimiter)` | Sets the delimiter to use.

    - ### Methods inherited from class java.lang.Object

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

- - ### Field Detail

    - #### DEFAULT_DELIMITER

          public static final java.lang.String DEFAULT_DELIMITER

      The default delimiter between table entries
      See Also:
        Constant Field Values

    - #### DEFAULT_COMMENT_PREFIX

          public static final java.lang.String DEFAULT_COMMENT_PREFIX

      The default comment prefix
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### GavoCSVTableParser

          public GavoCSVTableParser​(uk.ac.starlink.table.StoragePolicy storage,
                                    java.awt.Component parent)

      Creates a new instance of CSVTableParser

    - #### GavoCSVTableParser

          public GavoCSVTableParser​(uk.ac.starlink.table.StoragePolicy storage,
                                    java.awt.Component parent,
                                    java.lang.String delimiter)

      Creates a new instance of CSVTableParser
      Parameters:
        `parent` - component controlling this parser (may be null)
        `delimiter` - the character delimiter ('separator')

  - ### Method Detail

    - #### getCommentPrefix

          public java.lang.String getCommentPrefix()

      Getter for property commentPrefix.
      Returns:
        Value of property commentPrefix.

    - #### setDelimiter

          public void setDelimiter​(java.lang.String delimiter)

      Sets the delimiter to use.
      Parameters:
        `delimiter` - the delimiter.

    - #### getDelimiter

          public java.lang.String getDelimiter()

      Gets the delimiter.
      Returns:
        a String with the delimiter.

    - #### parseLine

          public java.util.List parseLine​(java.lang.String line)

      Return a List of tokens (Strings) from the specified line, delimited by the specified delimiter.
      Parameters:
        `line` - a String with the line to parse
      Returns:
        a List with the tokens

    - #### parse

          public uk.ac.starlink.table.StarTable parse​(java.io.InputStream stream)
                                               throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### classForJDBCType

          public static java.lang.Class classForJDBCType​(int jdbcType)

    - #### objectForJDBCType

          public static java.lang.Object objectForJDBCType​(int jdbcType,
                                                           java.lang.String value)

Copyright © 2003-2018 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.