|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfr.umlv.tatoo.runtime.buffer.impl.AbstractLexerBuffer
fr.umlv.tatoo.runtime.buffer.impl.ReadableByteChannelWrapper
public class ReadableByteChannelWrapper
A ReadableByteChannelWrapper wraps a ReadableByteChannel in order to allow
a lexer to process its content in order to have its tokens extracted.
Lexer| Constructor Summary | |
|---|---|
ReadableByteChannelWrapper(boolean direct,
int capacity,
int increment,
int chunkSize,
ReadableByteChannel readable,
LocationTracker tracker)
Construct a ReadableByteChannelWrapper used by the lexer to process the ReadableByteChannel. |
|
ReadableByteChannelWrapper(ReadableByteChannel readable,
LocationTracker tracker)
Constructs a ReadableByteChannelWrapper with default behavior. |
|
| Method Summary | |
|---|---|
protected ByteBuffer |
allocateBuffer(boolean direct,
int capacity)
|
protected void |
discardImpl()
|
ReadableByteChannel |
getReadableByteChannel()
|
boolean |
hasRemaining()
Returns true if more characters are availables in the buffer. |
int |
lastChar()
Returns last read char or -1 if not available. |
protected int |
nextImpl()
Returns next character in buffer without taking care of locations |
boolean |
previousWasNewLine()
Determines if the last unwinded character was an end of line. |
boolean |
read()
Reads at some bytes from the stream. |
protected void |
resetImpl()
Moves current position back to first non unwinded character without taking care of locations |
void |
restart(ReadableByteChannel readableByteChannel)
|
protected void |
restartImpl()
|
String |
toString()
Returns a String representation of the current token using the platform default encoding. |
String |
toString(String encoding)
Returns a String representation of the current token using the specified encoding. |
protected void |
unwindImpl(int l)
Performs unwind operation on buffer without taking care of locations |
ByteBuffer |
view()
Returns the token part of the buffer as a ByteBuffer. |
| Methods inherited from class fr.umlv.tatoo.runtime.buffer.impl.AbstractLexerBuffer |
|---|
discard, getLocationProvider, locationClear, next, reset, restart, unwind |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface fr.umlv.tatoo.runtime.buffer.TokenBuffer |
|---|
discard |
| Constructor Detail |
|---|
public ReadableByteChannelWrapper(ReadableByteChannel readable,
LocationTracker tracker)
ReadableByteChannelWrapper with default behavior.
readable - the readable to wrap
public ReadableByteChannelWrapper(boolean direct,
int capacity,
int increment,
int chunkSize,
ReadableByteChannel readable,
LocationTracker tracker)
ReadableByteChannelWrapper used by the lexer to process the ReadableByteChannel.
The parameters specify how the underlying buffer which stores data in allocated and reallocated
when more space is needed.
direct - if the ByteBuffer must be directcapacity - the initial capacityincrement - how much to increment the size of the buffer when more space is requiredchunkSize - how many bytes are read at once is the inputreadable - the inputtracker - the location tracker| Method Detail |
|---|
protected ByteBuffer allocateBuffer(boolean direct,
int capacity)
protected void resetImpl()
AbstractLexerBuffer
resetImpl in class AbstractLexerBufferLexerBuffer.reset()protected void unwindImpl(int l)
AbstractLexerBuffer
unwindImpl in class AbstractLexerBufferl - the number of characters to unwindLexerBuffer.unwind(int)public boolean previousWasNewLine()
LexerBuffer
true if the last unwinded character was an end of line;
false otherwisepublic boolean hasRemaining()
LexerBuffer
public boolean read()
throws IOException
LexerBufferSimpleLexer.run().
read in interface LexerBufferfalse at end of stream
IOException - if an i/o operation failed.protected int nextImpl()
AbstractLexerBuffer
nextImpl in class AbstractLexerBufferLexerBuffer.next()public void restart(ReadableByteChannel readableByteChannel)
public ReadableByteChannel getReadableByteChannel()
protected void discardImpl()
discardImpl in class AbstractLexerBufferpublic String toString()
CharsetDecoder
at each call.
toString in class ObjectCharset.defaultCharset()public String toString(String encoding)
CharsetDecoder
at each call.
encoding - the character encoding
Charsetprotected void restartImpl()
restartImpl in class AbstractLexerBufferpublic ByteBuffer view()
Buffer.limit()
index must not be moved, the Buffer.position() can be moved, but any data
before it can be discarded by the wrapper.
public int lastChar()
LexerBuffer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||