Class EmptyEncoder

java.lang.Object
org.simpleframework.http.core.EmptyEncoder
All Implemented Interfaces:
BodyEncoder

class EmptyEncoder extends Object implements BodyEncoder
The EmptyEncoder object is a producer used if there is not response body to be delivered. Typically this is used when the HTTP request method is HEAD or if there is some status code sent to the client that does not require a response body.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final BodyObserver
    This is the observer that is used to process the pipeline.
    private final ByteWriter
    This is the writer that is passed to the monitor when ready.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the EmptyEncoder object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This method performs no operation.
    void
    encode(byte[] array)
    This method performs no operation.
    void
    encode(byte[] array, int off, int size)
    This method performs no operation.
    void
    This method is used to encode the provided buffer of bytes in a HTTP/1.1 compliant format and sent it to the client.
    void
    encode(ByteBuffer buffer, int off, int size)
    This method is used to encode the provided buffer of bytes in a HTTP/1.1 compliant format and sent it to the client.
    void
    This method performs no operation.

    Methods inherited from class java.lang.Object

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

    • observer

      private final BodyObserver observer
      This is the observer that is used to process the pipeline.
    • writer

      private final ByteWriter writer
      This is the writer that is passed to the monitor when ready.
  • Constructor Details

    • EmptyEncoder

      public EmptyEncoder(BodyObserver observer, ByteWriter writer)
      Constructor for the EmptyEncoder object. Once created this producer will signal the kernel the the next request is ready to read from the HTTP pipeline as there is no content to be delivered with this producer object.
      Parameters:
      observer - this is used to deliver signals to the kernel
      writer - this is used to send to the underlying transport
  • Method Details

    • encode

      public void encode(byte[] array) throws IOException
      This method performs no operation. Because this producer is not required to generate a response body this will ignore all data that is provided to sent to the underlying transport.
      Specified by:
      encode in interface BodyEncoder
      Parameters:
      array - this is the array of bytes to send to the client
      Throws:
      IOException
    • encode

      public void encode(byte[] array, int off, int size) throws IOException
      This method performs no operation. Because this producer is not required to generate a response body this will ignore all data that is provided to sent to the underlying transport.
      Specified by:
      encode in interface BodyEncoder
      Parameters:
      array - this is the array of bytes to send to the client
      off - this is the offset within the array to send from
      size - this is the number of bytes that are to be sent
      Throws:
      IOException
    • encode

      public void encode(ByteBuffer buffer) throws IOException
      This method is used to encode the provided buffer of bytes in a HTTP/1.1 compliant format and sent it to the client. Once the data has been encoded it is handed to the transport layer within the server, which may choose to buffer the data if the content is too small to send efficiently or if the socket is not write ready.
      Specified by:
      encode in interface BodyEncoder
      Parameters:
      buffer - this is the buffer of bytes to send to the client
      Throws:
      IOException
    • encode

      public void encode(ByteBuffer buffer, int off, int size) throws IOException
      This method is used to encode the provided buffer of bytes in a HTTP/1.1 compliant format and sent it to the client. Once the data has been encoded it is handed to the transport layer within the server, which may choose to buffer the data if the content is too small to send efficiently or if the socket is not write ready.
      Specified by:
      encode in interface BodyEncoder
      Parameters:
      buffer - this is the buffer of bytes to send to the client
      off - this is the offset within the buffer to send from
      size - this is the number of bytes that are to be sent
      Throws:
      IOException
    • flush

      public void flush() throws IOException
      This method performs no operation. Because this producer is not required to generate a response body this will ignore all data that is provided to sent to the underlying transport.
      Specified by:
      flush in interface BodyEncoder
      Throws:
      IOException
    • close

      public void close() throws IOException
      This method performs no operation. Because this producer is not required to generate a response body this will ignore all data that is provided to sent to the underlying transport.
      Specified by:
      close in interface BodyEncoder
      Throws:
      IOException