Module swim.codec
Package swim.codec

Class DynamicEncoder<I,​O>


  • public abstract class DynamicEncoder<I,​O>
    extends Encoder<I,​O>
    Dynamically generated Encoder continuation.
    • Field Detail

      • encoding

        protected Encoder<? super I,​? extends O> encoding
        Current encoder continuation.
    • Constructor Detail

      • DynamicEncoder

        public DynamicEncoder()
    • Method Detail

      • feed

        public Encoder<I,​O> feed​(I input)
        Description copied from class: Encoder
        Returns an Encoder that represents the continuation of how to encode the given input object.
        Overrides:
        feed in class Encoder<I,​O>
      • pull

        public Encoder<I,​O> pull​(OutputBuffer<?> output)
        Description copied from class: Encoder
        Incrementally encodes as much output buffer data as possible, and returns another Encoder that represents the continuation of how to write additional buffer data. If isLast is true, then pull must return a terminated Encoder, i.e. an Encoder in the done state, or in the error state. The given output buffer is only guaranteed to be valid for the duration of the method call; references to output must not be stored.
        Specified by:
        pull in class Encoder<I,​O>
      • fork

        public Encoder<I,​O> fork​(Object condition)
        Description copied from class: Encoder
        Returns an Encoder continuation whose behavior may be altered by the given out-of-band condition.
        Overrides:
        fork in class Encoder<I,​O>
      • bind

        public O bind()
        Description copied from class: Encoder
        Returns the encoded result. Only guaranteed to return a result when in the done state.
        Overrides:
        bind in class Encoder<I,​O>
      • trap

        public Throwable trap()
        Description copied from class: Encoder
        Returns the encode error. Only guaranteed to return an error when in the error state.
        Overrides:
        trap in class Encoder<I,​O>
      • doEncode

        protected abstract Encoder<? super I,​? extends O> doEncode()
        Returns a new Encoder continuation for this DynamicEncoder, or null if this DynamicEncoder is done.
      • didEncode

        protected abstract void didEncode​(O value)
        Lifecycle callback invoked after this DynamicEncoder has finished encoding a value.