proguard
Class WordReader

java.lang.Object
  extended by proguard.WordReader
Direct Known Subclasses:
ArgumentWordReader, FileWordReader

public abstract class WordReader
extends java.lang.Object

An abstract reader of words, with the possibility to include other readers. Words are separated by spaces or broken off at delimiters. Words containing spaces or delimiters can be quoted with single or double quotes. Comments (everything starting with '#' on a single line) are ignored.


Constructor Summary
protected WordReader(java.io.File baseDir)
          Creates a new WordReader with the given base directory.
 
Method Summary
 void close()
          Closes the FileWordReader.
 java.io.File getBaseDir()
          Returns the base directory of this reader, if any.
 void includeWordReader(WordReader newIncludeWordReader)
          Specifies to start reading words from the given WordReader.
 java.lang.String lastComments()
          Returns the comments collected before returning the last word.
protected abstract  java.lang.String lineLocationDescription()
          Returns a readable description of the current WordReader position.
 java.lang.String locationDescription()
          Constructs a readable description of the current position in this WordReader and its included WordReader objects.
protected abstract  java.lang.String nextLine()
          Reads a line from this WordReader, or from one of its active included WordReader objects.
 java.lang.String nextWord()
          Reads a word from this WordReader, or from one of its active included WordReader objects.
 void setBaseDir(java.io.File baseDir)
          Sets the base directory of this reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WordReader

protected WordReader(java.io.File baseDir)
Creates a new WordReader with the given base directory.

Method Detail

setBaseDir

public void setBaseDir(java.io.File baseDir)
Sets the base directory of this reader.


getBaseDir

public java.io.File getBaseDir()
Returns the base directory of this reader, if any.


includeWordReader

public void includeWordReader(WordReader newIncludeWordReader)
Specifies to start reading words from the given WordReader. When it is exhausted, this WordReader will continue to provide its own words.

Parameters:
newIncludeWordReader - the WordReader that will start reading words.

nextWord

public java.lang.String nextWord()
                          throws java.io.IOException
Reads a word from this WordReader, or from one of its active included WordReader objects.

Returns:
the read word.
Throws:
java.io.IOException

lastComments

public java.lang.String lastComments()
                              throws java.io.IOException
Returns the comments collected before returning the last word. Starts collecting new comments.

Returns:
the collected comments, or null if there weren't any.
Throws:
java.io.IOException

locationDescription

public java.lang.String locationDescription()
Constructs a readable description of the current position in this WordReader and its included WordReader objects.

Returns:
the description.

nextLine

protected abstract java.lang.String nextLine()
                                      throws java.io.IOException
Reads a line from this WordReader, or from one of its active included WordReader objects.

Returns:
the read line.
Throws:
java.io.IOException

lineLocationDescription

protected abstract java.lang.String lineLocationDescription()
Returns a readable description of the current WordReader position.

Returns:
the description.

close

public void close()
           throws java.io.IOException
Closes the FileWordReader.

Throws:
java.io.IOException