Package com.netrics.likeit

## Class NetricsCSVReader

- java.lang.Object
- - com.netrics.likeit.NetricsCSVReader

- All Implemented Interfaces:
    `NetricsFieldedReader`

      public class NetricsCSVReader
      extends java.lang.Object
      implements NetricsFieldedReader

  Implement NetricsFieldedReader for CSV files. This is a simple CSV file reader that handles the same CSV format as the server side CSV reader. It implements the NetricsFieldedReader interface used by the ibi™ Patterns - Search Thesaurus classes and internally by the NetricsCSVRecSrc class.
  See Also:
    `NetricsThesaurus`, `NetricsCombinedThesaurus`, `NetricsWeightedDictionary`

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `NetricsCSVReader​(java.io.BufferedReader in_stream)` | Create a CSV Reader from an already opened stream.
    `NetricsCSVReader​(java.lang.String file_name, java.lang.String char_set_name)` | Create a reader for a Named CSV file.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | Closes files opened by this object.
    `java.lang.String` | `curLine()` | Return the text of the last line processed.
    `int` | `curLineNum()` | Return the line number (1 based) of the next line to read.
    `java.lang.String[]` | `readRecord()` | Read a single logical CSV record.
    `void` | `reset()` | Reset the read back to the first record.

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

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

- - ### Constructor Detail

    - #### NetricsCSVReader

          public NetricsCSVReader​(java.lang.String file_name,
                                  java.lang.String char_set_name)
                           throws java.io.FileNotFoundException,
                                  NetricsFileFormatException

      Create a reader for a Named CSV file. This creates a CSV file reader for a CSV file specified by a file name and a character set encoding name.
      Parameters:
        `file_name` - The name of a file to be read as a CSV file.
        `char_set_name` - The name of the character encoding for the file. If null the default character set of latin-1 (ISO-8859-1) is used.
      Throws:
        `java.io.FileNotFoundException` - if file_name does not exist.
        `NetricsFileFormatException` - if file_name contains improperly formatted data.

    - #### NetricsCSVReader

          public NetricsCSVReader​(java.io.BufferedReader in_stream)

      Create a CSV Reader from an already opened stream. This creates a CSV Reader on the given input stream reader.
      Parameters:
        `in_stream` - The input stream the CSV data is read from.

  - ### Method Detail

    - #### curLineNum

          public int curLineNum()

      Return the line number (1 based) of the next line to read.
      Specified by:
        `curLineNum` in interface `NetricsFieldedReader`
      Returns:
        the line/record number about to be read.

    - #### curLine

          public java.lang.String curLine()

      Return the text of the last line processed.
      Returns:
        the text of the last line processed.

    - #### reset

          public void reset()
                     throws NetricsFileFormatException

      Reset the read back to the first record. This resets reading of the file to the first record in the file so they can be read again. This can only be used if the file was opened by this object, if the CSV data is being read from a passed in stream this will throw an exception.
      Specified by:
        `reset` in interface `NetricsFieldedReader`
      Throws:
        `NetricsFileFormatException` - if there was an error resetting the sequence.

    - #### close

          public void close()
                     throws NetricsFileFormatException

      Closes files opened by this object. This closes any files opened by this object.
      Specified by:
        `close` in interface `NetricsFieldedReader`
      Throws:
        `NetricsFileFormatException` - if there was an error closing the sequence.

    - #### readRecord

          public java.lang.String[] readRecord()
                                        throws NetricsFileFormatException

      Read a single logical CSV record. This reads a CSV record, which could be more than one physical line in the file.
      Specified by:
        `readRecord` in interface `NetricsFieldedReader`
      Returns:
        An array of strings representing the fields of the CSV record. Returns null on EOF.
      Throws:
        `NetricsFileFormatException` - if there was an error reading the record.