InputDecorator
Date: 2016-12-03

com.fasterxml.jackson.core.io

## Class InputDecorator

- java.lang.Object
- - com.fasterxml.jackson.core.io.InputDecorator

- All Implemented Interfaces:
    java.io.Serializable

      public abstract class InputDecorator
      extends java.lang.Object
      implements java.io.Serializable

  Handler class that can be used to decorate input sources. Typical use is to use a filter abstraction (filtered stream, reader) around original input source, and apply additional processing during read operations.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `InputDecorator()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract java.io.InputStream` | `decorate(IOContext ctxt, byte[] src, int offset, int length)` Method called by `JsonFactory` instance when creating parser on given "raw" byte source.
    `java.io.DataInput` | `decorate(IOContext ctxt, java.io.DataInput input)` Method called by `JsonFactory` instance when creating parser given an `DataInput`, when this decorator has been registered.
    `abstract java.io.InputStream` | `decorate(IOContext ctxt, java.io.InputStream in)` Method called by `JsonFactory` instance when creating parser given an `InputStream`, when this decorator has been registered.
    `abstract java.io.Reader` | `decorate(IOContext ctxt, java.io.Reader r)` Method called by `JsonFactory` instance when creating parser given an `Reader`, when this decorator has been registered.

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

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

- - ### Constructor Detail

    - #### InputDecorator

          public InputDecorator()

  - ### Method Detail

    - #### decorate

          public abstract java.io.InputStream decorate(IOContext ctxt,
                                     java.io.InputStream in)
                                                throws java.io.IOException

      Method called by `JsonFactory` instance when creating parser given an `InputStream`, when this decorator has been registered.
      Parameters:
        `ctxt` - IO context in use (provides access to declared encoding). NOTE: at this point context may not have all information initialized; specifically auto-detected encoding is only available once parsing starts, which may occur only after this method is called.
        `in` - Original input source
      Returns:
        InputStream to use; either 'in' as is, or decorator version that typically delogates to 'in'
      Throws:
        `java.io.IOException`

    - #### decorate

          public abstract java.io.InputStream decorate(IOContext ctxt,
                                     byte[] src,
                                     int offset,
                                     int length)
                                                throws java.io.IOException

      Method called by `JsonFactory` instance when creating parser on given "raw" byte source. Method can either construct a `InputStream` for reading; or return null to indicate that no wrapping should occur.
      Parameters:
        `ctxt` - IO context in use (provides access to declared encoding) NOTE: at this point context may not have all information initialized; specifically auto-detected encoding is only available once parsing starts, which may occur only after this method is called.
        `src` - Input buffer that contains contents to parse
        `offset` - Offset of the first available byte in the input buffer
        `length` - Number of bytes available in the input buffer
      Returns:
        Either `InputStream` to use as input source; or null to indicate that contents are to be processed as-is by caller
      Throws:
        `java.io.IOException`

    - #### decorate

          public java.io.DataInput decorate(IOContext ctxt,
                                   java.io.DataInput input)
                                     throws java.io.IOException

      Method called by `JsonFactory` instance when creating parser given an `DataInput`, when this decorator has been registered.

      Default implementation simply throws `UnsupportedOperationException`

      Parameters:
        `ctxt` - IO context in use (provides access to declared encoding). NOTE: at this point context may not have all information initialized; specifically auto-detected encoding is only available once parsing starts, which may occur only after this method is called.
        `input` - Original input source
      Returns:
        InputStream to use; either 'input' as is, or decorator version that typically delogates to 'input'
      Throws:
        `java.io.IOException`
      Since:
        2.8

    - #### decorate

          public abstract java.io.Reader decorate(IOContext ctxt,
                                java.io.Reader r)
                                           throws java.io.IOException

      Method called by `JsonFactory` instance when creating parser given an `Reader`, when this decorator has been registered.
      Parameters:
        `ctxt` - IO context in use (provides access to declared encoding) NOTE: at this point context may not have all information initialized; specifically auto-detected encoding is only available once parsing starts, which may occur only after this method is called.
        `r` - Original reader
      Returns:
        Reader to use; either passed in argument, or something that calls it (for example, a `FilterReader`)
      Throws:
        `java.io.IOException`