org.apache.synapse.format.syslog

## Class InputStreamConsumer

- java.lang.Object
- - org.apache.synapse.format.syslog.InputStreamConsumer

-     public class InputStreamConsumer
      extends java.lang.Object

  Input stream consumer. This is a helper class used by `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 Summary

    Constructors
    Constructor and Description
    `InputStreamConsumer(java.io.InputStream in)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### InputStreamConsumer

          public InputStreamConsumer(java.io.InputStream in)

      Constructor.
      Parameters:
        `in` - the input stream to consume data from

  - ### Method Detail

    - #### next

          public int next()
                   throws java.io.IOException

      Get the next byte from the stream without consuming it. If the byte is not consumed between invocations, two successive calls to this method will return the same result.
      Returns:
        the next byte as an integer value in the range 0..255 or -1 if the end of the stream has been reached
      Throws:
        `java.io.IOException` - if an I/O error occurred while reading from the stream

    - #### consume

          public void consume()

      Consume the last byte read from the stream and advance to the next byte.

    - #### getPosition

          public int getPosition()

      Get the current position in the stream.
      Returns:
        the position in the stream

    - #### setPosition

          public void setPosition(int position)

      Reset the stream position to a previous value.
      Parameters:
        `position` - the new position

    - #### expect

          public void expect(int expected)
                      throws java.io.IOException,
                             ProtocolException

      Check the value of the next byte in the stream.
      Parameters:
        `expected` - the expected value
      Throws:
        `java.io.IOException` - if an I/O error occurred while reading from the stream
        `ProtocolException` - if the next byte doesn't have the expected value

    - #### consume

          public void consume(int expected)
                       throws java.io.IOException,
                              ProtocolException

      Check the value of the next byte in the stream and consume it. This is a convenience method that combines a call to `expect(int)` with a call to `consume()`.
      Parameters:
        `expected` - the expected value
      Throws:
        `java.io.IOException` - if an I/O error occurred while reading from the stream
        `ProtocolException` - if the next byte doesn't have the expected value

    - #### getInteger

          public int getInteger(int maxDigits)
                         throws java.io.IOException,
                                ProtocolException

      Read a decimal representation of an integer from the stream.
      Parameters:
        `maxDigits` - the maximum number of expected digits
      Returns:
        the integer value
      Throws:
        `java.io.IOException` - if an I/O error occurred while reading from the stream
        `ProtocolException` - if no integer value was found or if it was too long

Copyright © 2005-2022 Apache Software Foundation. All Rights Reserved.