ur_rna.Utilities

## Class ExtendedBufferedReader

- java.lang.Object
- - java.io.Reader
  - - java.io.BufferedReader
    - - ur_rna.Utilities.ExtendedBufferedReader

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Readable

      final class ExtendedBufferedReader
      extends java.io.BufferedReader

  A special buffered reader which tracks the current character position and line index.

  The reader also contains a peek method, which allows you to see the next char returned by

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private boolean` | `closed` Whether or not this reader has been closed.
    `static int` | `CR`
    `private long` | `currentLine` The current line index.
    `private static int` | `defaultGuessLineLength`
    `static int` | `EOF`
    `private int` | `lastReadChar` The last char returned from read() (or an overload) Usage: If lastReadChar is CR and a LF is encountered next, the currentLine should NOT be incremented.
    `static int` | `LF`
    `private long` | `position` The position, which is number of characters read so far
    `static int` | `UNKNOWN`

    - ### Fields inherited from class java.io.Reader

      `lock`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExtendedBufferedReader(java.io.Reader reader)` Created extended buffered reader using default buffer-size

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes the stream.
    `(package private) long` | `getCurrentLineNumber()` Returns the current line number
    `(package private) int` | `getLastChar()` Returns the last character that was read as an integer (0 to 65535).
    `(package private) long` | `getPosition()` Gets the character position in the reader.
    `boolean` | `isClosed()`
    `(package private) int` | `peek()` Returns the next character in the current reader without consuming it.
    `int` | `read()`
    `int` | `read(char[] buf, int offset, int length)`
    `java.lang.String` | `readLine()` Does not call `BufferedReader.readLine()` because that method drops the line terminator(s).
    `java.lang.String` | `readLine(boolean dropEolChars)`
    `java.lang.String` | `readLine(boolean dropEolChars, int guessLineLength)`

    - ### Methods inherited from class java.io.BufferedReader

      `lines, mark, markSupported, ready, reset, skip`

    - ### Methods inherited from class java.io.Reader

      `read, read`

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

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

- - ### Field Detail

    - #### closed

          private boolean closed

      Whether or not this reader has been closed.

    - #### CR

          public static final int CR

      See Also:
        Constant Field Values

    - #### currentLine

          private long currentLine

      The current line index. This is equal to the number of EOLs (CR/LF/CRLF) read thus far

    - #### defaultGuessLineLength

          private static final int defaultGuessLineLength

      See Also:
        Constant Field Values

    - #### EOF

          public static final int EOF

      See Also:
        Constant Field Values

    - #### lastReadChar

          private int lastReadChar

      The last char returned from read() (or an overload) Usage: If lastReadChar is CR and a LF is encountered next, the currentLine should NOT be incremented.

    - #### LF

          public static final int LF

      See Also:
        Constant Field Values

    - #### position

          private long position

      The position, which is number of characters read so far

    - #### UNKNOWN

          public static final int UNKNOWN

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ExtendedBufferedReader

          ExtendedBufferedReader(java.io.Reader reader)

      Created extended buffered reader using default buffer-size

  - ### Method Detail

    - #### close

          public void close()
                     throws java.io.IOException

      Closes the stream.
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Overrides:
        `close` in class `java.io.BufferedReader`
      Throws:
        `java.io.IOException` - If an I/O error occurs

    - #### getCurrentLineNumber

          long getCurrentLineNumber()

      Returns the current line number
      Returns:
        the current line number

    - #### getLastChar

          int getLastChar()

      Returns the last character that was read as an integer (0 to 65535). This will be the last character returned by any of the read methods. This will not include a character read using the `peek()` method. If no character has been read then this will return `UNKNOWN`. If the end of the stream was reached on the last read then this will return `EOF`.
      Returns:
        the last character that was read

    - #### getPosition

          long getPosition()

      Gets the character position in the reader.
      Returns:
        the current position in the reader (counting characters, not bytes since this is a Reader)

    - #### isClosed

          public boolean isClosed()

    - #### peek

          int peek()
            throws java.io.IOException

      Returns the next character in the current reader without consuming it. So the next call to `read()` will still return this value. Does not affect line number or last character.
      Returns:
        the next character
      Throws:
        `java.io.IOException` - if there is an error in reading

    - #### read

          public int read()
                   throws java.io.IOException

      Overrides:
        `read` in class `java.io.BufferedReader`
      Throws:
        `java.io.IOException`

    - #### read

          public int read(char[] buf,
                          int offset,
                          int length)
                   throws java.io.IOException

      Overrides:
        `read` in class `java.io.BufferedReader`
      Throws:
        `java.io.IOException`

    - #### readLine

          public java.lang.String readLine()
                                    throws java.io.IOException

      Does not call `BufferedReader.readLine()` because that method drops the line terminator(s).

      Increments `currentLine`

      Sets `lastReadChar` to `EOF` at EOF, otherwise to LF

      Overrides:
        `readLine` in class `java.io.BufferedReader`
      Returns:
        the line that was read, or null if reached EOF.
      Throws:
        `java.io.IOException`

    - #### readLine

          public java.lang.String readLine(boolean dropEolChars)
                                    throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### readLine

          public java.lang.String readLine(boolean dropEolChars,
                                           int guessLineLength)
                                    throws java.io.IOException

      Throws:
        `java.io.IOException`