|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object fr.umlv.tatoo.runtime.buffer.impl.UTF8Wrapper<T>
T
- the type of the token view of the wrapperpublic class UTF8Wrapper<T>
The class provides a buffer for using with a lexer build with UTF-8 encoding
(UTF8Encoding
).
It can wrap InputStream
and ReadableByteChannel
Method Summary | |
---|---|
void |
discard()
Discards all characters already recognized by the lexer. |
LocationTracker |
getLocationProvider()
Returns a location provider. |
boolean |
hasRemaining()
Returns true if more characters are availables in the buffer. |
int |
lastChar()
Returns last read char or -1 if not available. |
int |
next()
Reads the next character from the buffer. |
boolean |
previousWasNewLine()
Determines if the last unwinded character was an end of line. |
boolean |
read()
Reads at some bytes from the stream. |
void |
reset()
Moves current position back to first non unwinded character |
void |
restart()
Moves current position back to first non discarded character |
void |
unwind(int count)
Unwinds count characters from the buffer. |
T |
view()
Return a view of the tokens recognized in the buffer. |
static UTF8Wrapper<ByteBuffer> |
wrap(boolean direct,
int capacity,
int increment,
int chunkSize,
ReadableByteChannel readable,
LocationTracker tracker)
Construct a UTF8Wrapper used by the lexer to process the ReadableByteChannel . |
static UTF8Wrapper<InputStream> |
wrap(InputStream inputStream,
LocationTracker tracker)
Constructs an UTF8Wrapper wrapper used by the lexer to process the InputStream . |
static UTF8Wrapper<InputStream> |
wrap(int capacity,
int increment,
int chunkSize,
InputStream inputStream,
LocationTracker tracker)
Construct a UTF8Wrapper used by the lexer to process the InputStream . |
static UTF8Wrapper<ByteBuffer> |
wrap(ReadableByteChannel readable,
LocationTracker tracker)
Constructs an UTF8Wrapper wrapper used by the lexer to process the ReadableByteChannel . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static UTF8Wrapper<InputStream> wrap(int capacity, int increment, int chunkSize, InputStream inputStream, LocationTracker tracker)
UTF8Wrapper
used by the lexer to process the InputStream
.
The parameters specify how the underlying buffer which stores data in allocated and reallocated
when more space is needed.
capacity
- 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 inputinputStream
- the inputtracker
- the location trackerpublic static UTF8Wrapper<InputStream> wrap(InputStream inputStream, LocationTracker tracker)
UTF8Wrapper
wrapper used by the lexer to process the InputStream
.
inputStream
- the InputStream
to wraptracker
- the location trackerpublic static UTF8Wrapper<ByteBuffer> wrap(boolean direct, int capacity, int increment, int chunkSize, ReadableByteChannel readable, LocationTracker tracker)
UTF8Wrapper
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
public static UTF8Wrapper<ByteBuffer> wrap(ReadableByteChannel readable, LocationTracker tracker)
UTF8Wrapper
wrapper used by the lexer to process the ReadableByteChannel
.
readable
- the ReadableByteChannel
to wraptracker
- the location tracker
public int next()
LexerBuffer
next
in interface LexerBuffer
public boolean hasRemaining()
LexerBuffer
hasRemaining
in interface LexerBuffer
public void discard()
LexerBuffer
discard
in interface LexerBuffer
discard
in interface TokenBuffer<T>
public void restart()
LexerBuffer
restart
in interface LexerBuffer
public void unwind(int count)
LexerBuffer
count
characters from the buffer.
count
must not be 0.
unwind
in interface LexerBuffer
count
- the number of characters to unwindpublic void reset()
LexerBuffer
reset
in interface LexerBuffer
public boolean previousWasNewLine()
LexerBuffer
previousWasNewLine
in interface LexerBuffer
true
if the last unwinded character was an end of line;
false
otherwisepublic boolean read() throws IOException
LexerBuffer
SimpleLexer.run()
.
read
in interface LexerBuffer
false
at end of stream
IOException
- if an i/o operation failed.public T view()
view
in interface TokenBuffer<T>
ReadableByteChannelWrapper.view()
public int lastChar()
LexerBuffer
lastChar
in interface LexerBuffer
public LocationTracker getLocationProvider()
LexerBuffer
getLocationProvider
in interface LexerBuffer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |