net.sf.jsefa.rbf.lowlevel
Class RbfLowLevelDeserializerImpl<C extends RbfLowLevelConfiguration>

java.lang.Object
  extended by net.sf.jsefa.rbf.lowlevel.RbfLowLevelDeserializerImpl<C>
Type Parameters:
C - the type of the RbfLowLevelConfiguration
All Implemented Interfaces:
LowLevelDeserializer, RbfLowLevelDeserializer
Direct Known Subclasses:
CsvLowLevelDeserializerImpl, FlrLowLevelDeserializerImpl

public abstract class RbfLowLevelDeserializerImpl<C extends RbfLowLevelConfiguration>
extends Object
implements RbfLowLevelDeserializer

Abstract implementation of RbfLowLevelDeserializer.

Author:
Norman Lahme-Huetig

Constructor Summary
RbfLowLevelDeserializerImpl(C config)
          Constructs a new RbfLowLevelDeserializerImpl.
 
Method Summary
 void close(boolean closeReader)
          Closes the deserialization stream.
protected  C getConfiguration()
          Returns the configuration object.
protected  LineSegment.Terminator getCurrentSegmentTerminator()
           
protected  String getCurrentSegmentTerminatorString()
           
 InputPosition getInputPosition()
          Returns information about the current position within the input stream.
 List<Line> getStoredLines()
          Returns a list of lines stored during deserialization.
protected  boolean hasNextChar()
          Returns true, if there is another character on the current line segment to read.
protected  char nextChar()
          Returns the next character of the current line segment and moves one character forward.
protected  String nextString(int length)
          Returns the next String with the given length of the current line segment and moves forward accordingly.
 void open(Reader reader)
          Opens a new deserialization stream based on the given reader.
protected  char peekChar()
          Returns the current character of the current line segment.
 boolean readNextRecord()
          Reads the next record from the stream.
protected  boolean readNextSegment()
          Reads the next segment from the stream.
protected  int remainingLineLength()
           
 void unreadRecord()
          Unreads the already read record so that it can be read again with RbfLowLevelDeserializer.readNextRecord().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RbfLowLevelDeserializerImpl

public RbfLowLevelDeserializerImpl(C config)
Constructs a new RbfLowLevelDeserializerImpl.

Parameters:
config - the configuration object
Method Detail

open

public final void open(Reader reader)
Opens a new deserialization stream based on the given reader.

Specified by:
open in interface LowLevelDeserializer
Parameters:
reader - the reader to base the stream on.

readNextRecord

public final boolean readNextRecord()
Reads the next record from the stream. Returns true, if it could be read and false otherwise.

Specified by:
readNextRecord in interface RbfLowLevelDeserializer
Returns:
true, if another record could be read from the stream, otherwise false.

unreadRecord

public final void unreadRecord()
Unreads the already read record so that it can be read again with RbfLowLevelDeserializer.readNextRecord().

Specified by:
unreadRecord in interface RbfLowLevelDeserializer

close

public final void close(boolean closeReader)
Closes the deserialization stream. The underlying reader will be closed only if closeReader is true.

Specified by:
close in interface LowLevelDeserializer
Parameters:
closeReader - if true, the underlying reader will be closed, too.

getInputPosition

public final InputPosition getInputPosition()
Returns information about the current position within the input stream.

Specified by:
getInputPosition in interface LowLevelDeserializer
Returns:
the input position or null if no position information is available

getStoredLines

public List<Line> getStoredLines()
Returns a list of lines stored during deserialization.

Specified by:
getStoredLines in interface RbfLowLevelDeserializer
Returns:
a list of lines
See Also:
LineFilter

getConfiguration

protected final C getConfiguration()
Returns the configuration object.

Returns:
the configuration object

hasNextChar

protected final boolean hasNextChar()
Returns true, if there is another character on the current line segment to read.

Returns:
true, if there is another character on the current line segment to read; false otherwise.

peekChar

protected final char peekChar()
Returns the current character of the current line segment.

Returns:
a character

nextChar

protected final char nextChar()
Returns the next character of the current line segment and moves one character forward.

Returns:
a character

nextString

protected final String nextString(int length)
Returns the next String with the given length of the current line segment and moves forward accordingly.

Parameters:
length - the length of the String to return
Returns:
a String

remainingLineLength

protected final int remainingLineLength()
Returns:
the number of remaining characters in the current line segment.

readNextSegment

protected boolean readNextSegment()
Reads the next segment from the stream.

Returns:
true, if a segment could be read; false otherwise

getCurrentSegmentTerminatorString

protected String getCurrentSegmentTerminatorString()
Returns:
the string terminating the current segment.

getCurrentSegmentTerminator

protected LineSegment.Terminator getCurrentSegmentTerminator()
Returns:
the terminator of the current segment.


Copyright © 2014. All rights reserved.