LAReader (API documentation of hlt.language packages)
Date: 2013-01-30

hlt.language.io

## Class LAReader

- java.lang.Object
- - java.io.Reader
  - - hlt.language.io.LAReader

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

      public class LAReader
      extends java.io.Reader

  This class provides the convenience for doing lookaheads of arbitrary length on a given Reader.
  Version:
    Last modified on Wed Jun 20 13:57:09 2012 by hak
  Author:
    Hassan Aït-Kaci
  See Also:
    `LAStreamTokenizer`
  Copyright:
    © by the author

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LAReader(java.io.Reader reader)` Constructs a LAReader with the specified Reader.
    `LAReader(java.io.Reader reader, int size)` Constructs a LAReader with the specified Reader and buffer size.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes this LAReader.
    `java.lang.String` | `lookahead()` Returns a lookahead string of length equal to the buffer's.
    `java.lang.String` | `lookahead(int n)` Returns the string of the `n` characters to be read next.
    `void` | `mark(int readAheadLimit)` This method does nothing because marking is not supported.
    `boolean` | `markSupported()` Returns `false` because it there is no simple way to accommodate marking with the lookahead buffer.
    `int` | `read()` Consumes and returns the next character in the LAReader.
    `int` | `read(char[] cbuf)` Read characters into an array.
    `int` | `read(char[] cbuf, int off, int len)` Read characters into a portion of an array.
    `boolean` | `ready()` Returns `true` iff there is a character available to be read.
    `void` | `reset()` This method does nothing because marking is not supported.
    `void` | `resizeBuffer(int size)` Resizes the lookahead buffer to the specified size.
    `long` | `skip(long n)` Skip `n` characters, up to EOF (or, more generally, any negative value returned by `read()`).
    `java.lang.String` | `toString()` Returns a string describing the current buffer state.

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

      `read`

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

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

- - ### Constructor Detail

    - #### LAReader

          public LAReader(java.io.Reader reader)

      Constructs a LAReader with the specified Reader.

    - #### LAReader

          public LAReader(java.io.Reader reader,
                  int size)

      Constructs a LAReader with the specified Reader and buffer size.

  - ### Method Detail

    - #### read

          public final int read()
                         throws java.io.IOException

      Consumes and returns the next character in the LAReader.
      Overrides:
        `read` in class `java.io.Reader`
      Throws:
        `java.io.IOException`

    - #### lookahead

          public final java.lang.String lookahead(int n)
                                           throws java.io.IOException

      Returns the string of the `n` characters to be read next. If less than `n` characters are available in the currentl buffer, it is first refilled. If `n` is greater than `BUFFER_SIZE`, the buffer is first resized to `n` and refilled. If the end of file is read, or the reader becomes non ready before `n` characters are consumed, only those characters that have been already read are used (and the lookahead is then shorter than `n`). If the reader is not ready or only the end of file remains, the empty string is returned.
      Throws:
        `java.io.IOException`

    - #### lookahead

          public final java.lang.String lookahead()
                                           throws java.io.IOException

      Returns a lookahead string of length equal to the buffer's.
      Throws:
        `java.io.IOException`

    - #### resizeBuffer

          public void resizeBuffer(int size)
                            throws java.io.IOException

      Resizes the lookahead buffer to the specified size.
      Throws:
        `java.io.IOException`

    - #### close

          public void close()
                     throws java.io.IOException

      Closes this LAReader.
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Specified by:
        `close` in class `java.io.Reader`
      Throws:
        `java.io.IOException`

    - #### toString

          public java.lang.String toString()

      Returns a string describing the current buffer state.
      Overrides:
        `toString` in class `java.lang.Object`

    - #### read

          public int read(char[] cbuf,
                 int off,
                 int len)
                   throws java.io.IOException

      Read characters into a portion of an array.
      Specified by:
        `read` in class `java.io.Reader`
      Parameters:
        `cbuf` - Destination buffer
        `off` - Offset at which to start storing characters
        `len` - Maximum number of characters to read
      Returns:
        Number of characters read, or IO.EOF.
      Throws:
        `java.io.IOException` - If an I/O error occurs

    - #### read

          public int read(char[] cbuf)
                   throws java.io.IOException

      Read characters into an array.
      Overrides:
        `read` in class `java.io.Reader`
      Parameters:
        `cbuf` - Destination buffer
      Returns:
        Number of characters read, or one of IO.EOF, IO.SOI, or IO.EOI.
      Throws:
        `java.io.IOException` - If an I/O error occurs

    - #### skip

          public long skip(long n)
                    throws java.io.IOException

      Skip `n` characters, up to EOF (or, more generally, any negative value returned by `read()`).
      Overrides:
        `skip` in class `java.io.Reader`
      Parameters:
        `n` - The number of characters to skip
      Returns:
        The number of characters actually skipped
      Throws:
        `java.lang.IllegalArgumentException` - If n is negative
        `java.io.IOException` - If an I/O error occurs

    - #### ready

          public boolean ready()
                        throws java.io.IOException

      Returns `true` iff there is a character available to be read.
      Overrides:
        `ready` in class `java.io.Reader`
      Throws:
        `java.io.IOException`

    - #### markSupported

          public boolean markSupported()

      Returns `false` because it there is no simple way to accommodate marking with the lookahead buffer.
      Overrides:
        `markSupported` in class `java.io.Reader`

    - #### mark

          public void mark(int readAheadLimit)
                    throws java.io.IOException

      This method does nothing because marking is not supported.
      Overrides:
        `mark` in class `java.io.Reader`
      Throws:
        `java.io.IOException`

    - #### reset

          public void reset()
                     throws java.io.IOException

      This method does nothing because marking is not supported.
      Overrides:
        `reset` in class `java.io.Reader`
      Throws:
        `java.io.IOException`