public class InputStreamConsumer
extends java.lang.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(java.io.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(java.io.InputStream in)
in
- the input stream to consume data frompublic int next() throws java.io.IOException
java.io.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 java.io.IOException, ProtocolException
expected
- the expected valuejava.io.IOException
- 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 java.io.IOException, ProtocolException
expect(int)
with a
call to consume()
.expected
- the expected valuejava.io.IOException
- 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 java.io.IOException, ProtocolException
maxDigits
- the maximum number of expected digitsjava.io.IOException
- if an I/O error occurred while reading from
the streamProtocolException
- if no integer value was found or if it
was too longCopyright © 2005-2022 Apache Software Foundation. All Rights Reserved.