Module swim.codec
Package swim.codec

Class DynamicEncoder<I,O>

java.lang.Object
swim.codec.Encoder<I,O>
swim.codec.DynamicEncoder<I,O>

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

    Fields
    Modifier and Type
    Field
    Description
    protected Encoder<? super I,? extends O>
    Current encoder continuation.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the encoded result.
    protected abstract void
    didEncode(O value)
    Lifecycle callback invoked after this DynamicEncoder has finished encoding a value.
    protected abstract Encoder<? super I,? extends O>
    Returns a new Encoder continuation for this DynamicEncoder, or null if this DynamicEncoder is done.
    feed(I input)
    Returns an Encoder that represents the continuation of how to encode the given input object.
    fork(Object condition)
    Returns an Encoder continuation whose behavior may be altered by the given out-of-band condition.
    pull(OutputBuffer<?> output)
    Incrementally encodes as much output buffer data as possible, and returns another Encoder that represents the continuation of how to write additional buffer data.
    Returns the encode error.

    Methods inherited from class swim.codec.Encoder

    andThen, asDone, asError, done, done, error, isCont, isDone, isError

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • encoding

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

    • DynamicEncoder

      public DynamicEncoder()
  • Method Details

    • 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.