gov.nih.nlm.umls.io
Class PushBackReader

java.lang.Object
  extended by java.io.Reader
      extended by java.io.BufferedReader
          extended by gov.nih.nlm.umls.io.PushBackReader
All Implemented Interfaces:
LocalNullValueSupport, Closeable, Readable
Direct Known Subclasses:
SearchStringPushBackReader

public class PushBackReader
extends BufferedReader
implements LocalNullValueSupport

Extends BufferedReader to provide the ability to push a single line of input back onto the reader to read it again on the next readLine() call.

Author:
Brian Carlsen

Field Summary
protected  String line
           
protected  String null_value
           
protected  boolean null_value_flag
           
protected  String regex_null_value
           
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
PushBackReader(BufferedReader r)
          Instantiates a new PushBackReader wrapped around the specified reader.
 
Method Summary
 String getNullValue()
          Returns the null value.
 boolean isEmptyValue(String token)
          Indicates whether or not the specified token is null or contains a null value as defined by being either zero length or a value equal to the null value.
 void push(String line)
          Push a line of input back onto the reader.
 String readLine()
          Returns the next line from the reader.
protected  String resolveNull(String line)
          Replaces all "null value" characters in the line.
 void setNullValue(String null_value)
          Sets the null value to use.
 
Methods inherited from class java.io.BufferedReader
close, mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.io.Reader
read, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

line

protected String line

null_value

protected String null_value

regex_null_value

protected String regex_null_value

null_value_flag

protected boolean null_value_flag
Constructor Detail

PushBackReader

public PushBackReader(BufferedReader r)
Instantiates a new PushBackReader wrapped around the specified reader.

Parameters:
r - BufferedReader
Method Detail

setNullValue

public void setNullValue(String null_value)
Sets the null value to use. This is needed if release.dat specifies some non-standard null value char sequence.

Specified by:
setNullValue in interface LocalNullValueSupport
Parameters:
null_value - the new null string value

getNullValue

public String getNullValue()
Returns the null value. This is needed if release.dat specifies some non-standard null value char sequence.

Specified by:
getNullValue in interface LocalNullValueSupport
Returns:
the string value for "null"

isEmptyValue

public boolean isEmptyValue(String token)
Indicates whether or not the specified token is null or contains a null value as defined by being either zero length or a value equal to the null value.

Specified by:
isEmptyValue in interface LocalNullValueSupport

readLine

public String readLine()
                throws IOException
Returns the next line from the reader.

Overrides:
readLine in class BufferedReader
Returns:
the next line from the reader
Throws:
IOException

resolveNull

protected String resolveNull(String line)
Replaces all "null value" characters in the line.

Parameters:
line - input line
Returns:
output line

push

public void push(String line)
Push a line of input back onto the reader.

Parameters:
line - input line to be pushed back on reader


Copyright ©2005