sdsu.io
Class ChunkReader

java.lang.Object
  |
  +--sdsu.io.ChunkReader

public class ChunkReader
extends java.lang.Object
implements java.util.Enumeration

A chunk is any sequence of characters you wish. A chunk could be a single line, a table, or a complete document. The ChunkWriter separates chunks with a string separator, called a chunk seperator. The separator can be any string. The separator is not part of a chunk. The separator should be selected to insure that it does not occur in the input as a part of a chunk, as it will be interpreted as the end of the chunk not as part of the chunk. ChunkWriter will return each chunk one at a time.

Version:
0.8 7 January 1998
Author:
Roger Whitney (whitney@cs.sdsu.edu)

Constructor Summary
ChunkReader(java.io.Reader in, java.lang.String separator)
          Create a ChunkReader object with a Reader as an input and the given separator.
ChunkReader(java.lang.String input, java.lang.String separator)
          Create a ChunkReader object with a String as an input and the given separator.
 
Method Summary
 boolean eof()
          Returns true if there are more blocks of data in the input.
static ChunkReader fromFile(java.lang.String fileName, java.lang.String separator)
          Create a ChunkReader object with a file as an input and the given separator.
 boolean hasMoreElements()
          Returns true if there are more blocks of data in the input.
 java.lang.Object nextElement()
          Returns the next block of data.
 java.lang.Object readChunk()
          Returns the next block of data.
 void setSeparator(java.lang.String newSeparator)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChunkReader

public ChunkReader(java.io.Reader in,
                   java.lang.String separator)
Create a ChunkReader object with a Reader as an input and the given separator. This class does not buffer the reader for you.

ChunkReader

public ChunkReader(java.lang.String input,
                   java.lang.String separator)
Create a ChunkReader object with a String as an input and the given separator.
Method Detail

fromFile

public static ChunkReader fromFile(java.lang.String fileName,
                                   java.lang.String separator)
                            throws java.io.FileNotFoundException
Create a ChunkReader object with a file as an input and the given separator. File IO will be buffered for you.
Throws:
java.io.FileNotFoundException - thrown if fileName is not valid file name.

setSeparator

public void setSeparator(java.lang.String newSeparator)

eof

public boolean eof()
Returns true if there are more blocks of data in the input.

hasMoreElements

public boolean hasMoreElements()
Returns true if there are more blocks of data in the input.
Specified by:
hasMoreElements in interface java.util.Enumeration

readChunk

public java.lang.Object readChunk()
Returns the next block of data.
Throws:
java.util.NoSuchElementException - if there are no blocks of data left.

nextElement

public java.lang.Object nextElement()
Returns the next block of data.
Specified by:
nextElement in interface java.util.Enumeration
Throws:
java.util.NoSuchElementException - if there are no blocks of data left.