public class InputStreamConsumer extends Object
SyslogMessageBuilder
to parse data
from an input stream. In particular it supports look ahead and allows to
buffer and reread data from the stream.Constructor and Description |
---|
InputStreamConsumer(InputStream in)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
consume()
Consume the last byte read from the stream and advance to the next byte.
|
void |
consume(int expected)
Check the value of the next byte in the stream and consume it.
|
void |
expect(int expected)
Check the value of the next byte in the stream.
|
int |
getInteger(int maxDigits)
Read a decimal representation of an integer from the stream.
|
int |
getPosition()
Get the current position in the stream.
|
int |
next()
Get the next byte from the stream without consuming it.
|
void |
setPosition(int position)
Reset the stream position to a previous value.
|
public InputStreamConsumer(InputStream in)
in
- the input stream to consume data frompublic int next() throws IOException
IOException
- if an I/O error occurred while reading from
the streampublic void consume()
public int getPosition()
public void setPosition(int position)
position
- the new positionpublic void expect(int expected) throws IOException, ProtocolException
expected
- the expected valueIOException
- if an I/O error occurred while reading from
the streamProtocolException
- if the next byte doesn't have the expected valuepublic void consume(int expected) throws IOException, ProtocolException
expect(int)
with a
call to consume()
.expected
- the expected valueIOException
- if an I/O error occurred while reading from
the streamProtocolException
- if the next byte doesn't have the expected valuepublic int getInteger(int maxDigits) throws IOException, ProtocolException
maxDigits
- the maximum number of expected digitsIOException
- if an I/O error occurred while reading from
the streamProtocolException
- if no integer value was found or if it
was too longCopyright © 2005-2017 Apache Software Foundation. All Rights Reserved.