Class Output<T extends Buffer>

All Implemented Interfaces:
Future<Void>, Associator, Eligible

public class Output<T extends Buffer> extends IOEvent<T>
This event signals that a new chunk of internally generated data is to be forwarded to some destination.

This type of event is commonly used for data flowing out of the application.

  • Constructor Details

    • Output

      public Output(Output<T> event)
      Create a new event from an existing event.

      This constructor is useful if the data is to be forwarded to another channel by a new event.

      The buffer is reused in the new event (the lock count is incremented).

      Parameters:
      event - the existing event
  • Method Details

    • fromSource

      public static <B extends Buffer> Output<B> fromSource(ManagedBuffer<B> buffer, boolean endOfRecord)
      Create a new event with the given buffer.

      The buffer must have been prepared for invoking get-methods.

      Parameters:
      buffer - the buffer with the data
      endOfRecord - if the event ends a data record
    • fromSink

      public static <B extends Buffer> Output<B> fromSink(ManagedBuffer<B> buffer, boolean endOfRecord)
      Create a new event with the given buffer.

      Creating the event flips the buffer, which is assumed to have been used for collecting data up to now.

      Parameters:
      buffer - the buffer with the data
      endOfRecord - if the event ends a data record
    • from

      public static Output<CharBuffer> from(String data, boolean endOfRecord)
      Convenience method that creates a Output event from a String.
      Parameters:
      data - the string to wrap
      endOfRecord - if the event ends a data record
      Returns:
      the event
    • from

      public static Output<ByteBuffer> from(byte[] data, boolean endOfRecord)
      Convenience method that creates a Output event from a byte[].
      Parameters:
      data - the array to wrap
      endOfRecord - if the event ends a data record
      Returns:
      the event