Package org.codehaus.groovy.control.io

# Class AbstractReaderSource

java.lang.Object
org.codehaus.groovy.control.io.AbstractReaderSource

All Implemented Interfaces:
  `HasCleanup`, `ReaderSource`

Direct Known Subclasses:
  `FileReaderSource`, `InputStreamReaderSource`, `StringReaderSource`, `URLReaderSource`

public abstract class AbstractReaderSource extends Object implements ReaderSource
For ReaderSources that can choose a parent class, a base that provides common functionality.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected CompilerConfiguration`
  `configuration`
  Compiler configuration used to decode the source.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AbstractReaderSource(CompilerConfiguration configuration)`
  Creates a reader source backed by the supplied compiler configuration.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `canReopenSource()`
  Returns true if the source can be restarted (i.e.
  `void`
  `cleanup()`
  Cleans up any cached resources used by getLine().
  `String`
  `getLine(int lineNumber, Janitor janitor)`
  Returns a line from the source, or null, if unavailable.

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

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

  ### Methods inherited from interface org.codehaus.groovy.control.io.ReaderSource

  `getReader, getURI`

- ## Field Details

  - ### configuration

    protected CompilerConfiguration configuration
    Compiler configuration used to decode the source.

- ## Constructor Details

  - ### AbstractReaderSource

    public AbstractReaderSource(CompilerConfiguration configuration)
    Creates a reader source backed by the supplied compiler configuration.
    Parameters:
      `configuration` - the compiler configuration to use

- ## Method Details

  - ### canReopenSource

    public boolean canReopenSource()
    Returns true if the source can be restarted (i.e. if getReader() will return non-null on subsequent calls).
    Specified by:
      `canReopenSource` in interface `ReaderSource`
    Returns:
      true if the resource can be reopened for reading

  - ### getLine

    public String getLine(int lineNumber, Janitor janitor)
    Returns a line from the source, or null, if unavailable. If you supply a Janitor, resources will be cached.
    Specified by:
      `getLine` in interface `ReaderSource`
    Parameters:
      `lineNumber` - the number of the line of interest
      `janitor` - helper to clean up afterwards
    Returns:
      the line of interest

  - ### cleanup

    public void cleanup()
    Cleans up any cached resources used by getLine().
    Specified by:
      `cleanup` in interface `HasCleanup`
    Specified by:
      `cleanup` in interface `ReaderSource`