Class Decoder.Result<R extends MessageHeader>

java.lang.Object
org.jdrupes.httpcodec.Codec.Result
org.jdrupes.httpcodec.Decoder.Result<R>
Type Parameters:
R - the type of the optionally generated response message
Direct Known Subclasses:
HttpDecoder.Result, WsDecoder.Result
Enclosing interface:
Decoder<T extends MessageHeader,R extends MessageHeader>

public abstract static class Decoder.Result<R extends MessageHeader> extends Codec.Result
The result from decoding.

In addition to the common codec result, this includes the information wheteher a complete message header has been received and it can include a response that is to be sent back to the sender in order to fulfill the requirements of the protocol. As the decoder can (obviously) not sent back this response by itself, it is included in the result.

The class is declared abstract to promote the usage of the factory method.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    The Factory for (extended) results.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Result(boolean overflow, boolean underflow, boolean closeConnection, boolean headerCompleted, R response, boolean responseOnly)
    Creates a new result.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    int
     
    boolean
    Returns true if the message header has been decoded completely during the decoder invocation that returned this result and is now available.
    boolean
    If the result includes a response (see response()) and this method returns true then no further processing of the received data is required.
    Returns the response if a response exists.
     

    Methods inherited from class org.jdrupes.httpcodec.Codec.Result

    closeConnection, isOverflow, isUnderflow

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Result

      protected Result(boolean overflow, boolean underflow, boolean closeConnection, boolean headerCompleted, R response, boolean responseOnly)
      Creates a new result.
      Parameters:
      overflow - true if the data didn’t fit in the out buffer
      underflow - true if more data is expected
      closeConnection - true if the connection should be closed
      headerCompleted - true if the header has completely been decoded
      response - a response to send due to an error
      responseOnly - if the result includes a response this flag indicates that no further processing besides sending the response is required
  • Method Details

    • isHeaderCompleted

      public boolean isHeaderCompleted()
      Returns true if the message header has been decoded completely during the decoder invocation that returned this result and is now available.

      Note that not only the header may heve been decoded, but that the output buffer may also already contain decoded data.

      Returns:
      the result
    • response

      public Optional<R> response()
      Returns the response if a response exists.

      A response in the decoder result indicates that some information must be signaled back to the sender.

      Returns:
      the response
    • isResponseOnly

      public boolean isResponseOnly()
      If the result includes a response (see response()) and this method returns true then no further processing of the received data is required.

      After sending the response data, the decode method should be invoked again with the same parameters.

      Returns:
      the result
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Codec.Result
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Codec.Result
    • toString

      public String toString()
      Overrides:
      toString in class Codec.Result