BeanIO 2.0.4

org.beanio.stream.util
Class CommentReader

java.lang.Object
  extended by org.beanio.stream.util.CommentReader

public class CommentReader
extends Object

Skips commented lines read from an input stream. The input stream must support marking (i.e. Reader.markSupported() must return true). A line is considered commented if it starts with one of the configured comment indicators.

Since:
1.2
Author:
Kevin Seim

Constructor Summary
CommentReader(Reader in, String[] comments)
          Constructs a new CommentReader.
CommentReader(Reader in, String[] comments, Character recordTerminator)
          Constructs a new CommentReader.
 
Method Summary
 boolean isEOF()
          Returns whether the end of the stream was reached reading a commented line.
 boolean isSkipLF()
          Returns whether the next character should be ignored if its a line feed.
 int skipComments(boolean initialSkipLF)
          Skips comments in the input stream and returns the number of commented lines read.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommentReader

public CommentReader(Reader in,
                     String[] comments)
              throws IllegalArgumentException
Constructs a new CommentReader.

Parameters:
in - the input stream to read
comments - an array of comment identifying strings
Throws:
IllegalArgumentException - if the configured comments are invalid or the reader does not support marking

CommentReader

public CommentReader(Reader in,
                     String[] comments,
                     Character recordTerminator)
              throws IllegalArgumentException
Constructs a new CommentReader.

Parameters:
in - the input stream to read from
comments - an array of comment identifying strings
recordTerminator - the record terminating character
Throws:
IllegalArgumentException - if the configured comments are invalid or the reader does not support marking
Method Detail

isSkipLF

public boolean isSkipLF()
Returns whether the next character should be ignored if its a line feed.

Returns:
true if the next line feed should be ignored

isEOF

public boolean isEOF()
Returns whether the end of the stream was reached reading a commented line.

Returns:
true if the end of the stream was reached reading a commented line.

skipComments

public int skipComments(boolean initialSkipLF)
                 throws IOException
Skips comments in the input stream and returns the number of commented lines read. If no commented lines were read, the stream is positioned just as it had been before this method is called.

Parameters:
initialSkipLF - true if the first line feed character read should be ignored
Returns:
the number of skipped comment lines
Throws:
IOException

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim