Module swim.codec
Package swim.codec

Class OutputBuffer<T>


  • public abstract class OutputBuffer<T>
    extends Output<T>
    Non-blocking token stream buffer.
    • Constructor Detail

      • OutputBuffer

        public OutputBuffer()
    • Method Detail

      • full

        public static <T> OutputBuffer<T> full()
        Returns an OutputBuffer in the full state, that binds a null result.
      • full

        public static <T> OutputBuffer<T> full​(OutputSettings settings)
        Returns an OutputBuffer in the full state, with the given settings.
      • full

        public static <T> OutputBuffer<T> full​(T value)
        Returns an OutputBuffer in the full state, that binds the given value.
      • full

        public static <T> OutputBuffer<T> full​(T value,
                                               OutputSettings settings)
        Returns an OutputBuffer in the full state, that binds the given value, with the given settings.
      • done

        public static <T> OutputBuffer<T> done()
        Returns an OutputBuffer in the done state, that binds a null result.
      • done

        public static <T> OutputBuffer<T> done​(OutputSettings settings)
        Returns an OutputBuffer in the done state, with the given settings.
      • done

        public static <T> OutputBuffer<T> done​(T value)
        Returns an OutputBuffer in the done state, that binds the given value.
      • done

        public static <T> OutputBuffer<T> done​(T value,
                                               OutputSettings settings)
        Returns an OutputBuffer in the done state, that binds the given value, with the given settings.
      • error

        public static <T> OutputBuffer<T> error​(Throwable error)
        Returns an OutputBuffer in the error state, with the given output error.
      • error

        public static <T> OutputBuffer<T> error​(Throwable error,
                                                OutputSettings settings)
        Returns an OutputBuffer in the error state, with the given output error and settings.
      • isPart

        public abstract OutputBuffer<T> isPart​(boolean isPart)
        Description copied from class: Output
        Returns a partial Output equivalent to this Output, if isPart is true; returns a final Output equivalent to this Output if isPart is false. The caller's reference to this Output should be replaced by the returned Output.
        Specified by:
        isPart in class Output<T>
      • index

        public abstract int index()
      • limit

        public abstract int limit()
      • capacity

        public abstract int capacity()
      • remaining

        public abstract int remaining()
      • array

        public abstract byte[] array()
      • arrayOffset

        public abstract int arrayOffset()
      • has

        public abstract boolean has​(int index)
      • get

        public abstract int get​(int index)
      • set

        public abstract void set​(int index,
                                 int token)
      • write

        public abstract OutputBuffer<T> write​(int token)
        Description copied from class: Output
        Writes a single token to the stream, if this Output is in the cont state. Returns an Output in the error state if this Output is not in the cont state. The caller's reference to this Output should be replaced by the returned Output.
        Specified by:
        write in class Output<T>
      • write

        public OutputBuffer<T> write​(String string)
        Description copied from class: Output
        Writes the code points of the given string. Assumes this is a Unicode Output with sufficient capacity. Returns an Output in the error state if this Output exits the cont state before the full string has been writtem. The caller's reference to this Output should be replaced by the returned Output.
        Overrides:
        write in class Output<T>
      • writeln

        public OutputBuffer<T> writeln​(String string)
        Description copied from class: Output
        Writes the code points of the given string, followed by the code points of the settings' line separator. Assumes this is a Unicode Output with sufficient capacity. Returns an Output in the error state if this Output exits the cont state before the full string and line separator has been written. The caller's reference to this Output should be replaced by the returned Output.
        Overrides:
        writeln in class Output<T>
      • writeln

        public OutputBuffer<T> writeln()
        Description copied from class: Output
        Writes the code points of the settings' line separator. Assumes this is a Unicode Output with sufficient capacity. Returns an Output in the error state if this Output exits the cont state before the full line separator has been written. The caller's reference to this Output should be replaced by the returned Output.
        Overrides:
        writeln in class Output<T>
      • display

        public OutputBuffer<T> display​(Object object)
        Description copied from class: Output
        Writes the code points of the human-readable Display string of the given object. Assumes this is a Unicode Output with sufficient capacity. Returns an Output in the error state if this Output exits the contt state before the full display string has been written. The caller's reference to this Output should be replaced by the returned Output.
        Overrides:
        display in class Output<T>
      • debug

        public OutputBuffer<T> debug​(Object object)
        Description copied from class: Output
        Writes the code points of the developer-readable Debug string of the given object. Assumes this is a Unicode Output with sufficient capacity. Returns an Output in the error state if this Output exits the contt state before the full debug string has been written. The caller's reference to this Output should be replaced by the returned Output.
        Overrides:
        debug in class Output<T>
      • move

        public abstract OutputBuffer<T> move​(int fromIndex,
                                             int toIndex,
                                             int length)
      • flush

        public OutputBuffer<T> flush()
        Description copied from class: Output
        Writes any internally buffered state to the underlying output stream.
        Overrides:
        flush in class Output<T>
      • fork

        public OutputBuffer<T> fork​(Object condition)
        Description copied from class: Output
        Returns an Output equivalent to this Output, but whose behavior may be altered by the given out-of-band condition. The caller's reference to this Output should be replaced by the returned Output.
        Overrides:
        fork in class Output<T>
      • clone

        public OutputBuffer<T> clone()
        Description copied from class: Output
        Returns an implementation-defined branch of the token stream.
        Overrides:
        clone in class Output<T>