Interface InputStreamInterceptor

All Known Implementing Classes:
GzipStreamInterceptor

public interface InputStreamInterceptor
An interceptor to be consulted by the IonReaderBuilder when creating an IonReader over a user-provided stream. This allows users to transform a stream's raw bytes into valid text or binary Ion.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    The name of the format the interceptor recognizes.
    boolean
    isMatch(byte[] candidate, int offset, int length)
    Determines whether the given candidate byte sequence matches this format.
    newInputStream(InputStream interceptedStream)
    Creates a new InputStream that transforms the bytes in the given InputStream into valid text or binary Ion.
    int
    The number of bytes required to be read from the beginning of the stream in order to determine whether it matches the format relevant to this interceptor.
  • Method Details

    • formatName

      String formatName()
      The name of the format the interceptor recognizes.
      Returns:
      a constant String.
    • numberOfBytesNeededToDetermineMatch

      int numberOfBytesNeededToDetermineMatch()
      The number of bytes required to be read from the beginning of the stream in order to determine whether it matches the format relevant to this interceptor. If a stream contains fewer than the number of bytes returned by this method, then this interceptor will not be considered a match and isMatch(byte[], int, int) will not be called.
      Returns:
      the length in bytes.
    • isMatch

      boolean isMatch(byte[] candidate, int offset, int length)
      Determines whether the given candidate byte sequence matches this format.
      Parameters:
      candidate - the candidate byte sequence.
      offset - the offset into the candidate bytes to begin matching.
      length - the number of bytes (beginning at 'offset') in `candidate`. Must be greater than or equal to numberOfBytesNeededToDetermineMatch().
      Returns:
      true if the candidate byte sequence matches; otherwise, false.
    • newInputStream

      InputStream newInputStream(InputStream interceptedStream) throws IOException
      Creates a new InputStream that transforms the bytes in the given InputStream into valid text or binary Ion.
      Parameters:
      interceptedStream - the stream containing bytes in this format.
      Returns:
      a new InputStream.
      Throws:
      IOException - if thrown when constructing the new InputStream.