Class IoBufferDecoder

java.lang.Object
org.apache.mina.proxy.utils.IoBufferDecoder

public class IoBufferDecoder extends Object
IoBufferDecoder.java - Handles an IoBuffer decoder which supports two methods : - dynamic delimiter decoding - fixed length content reading
Since:
MINA 2.0.0-M3
  • Field Details

  • Constructor Details

    • IoBufferDecoder

      public IoBufferDecoder(byte[] delimiter)
      Creates a new instance that uses specified delimiter byte array as a message delimiter.
      Parameters:
      delimiter - an array of characters which delimits messages
    • IoBufferDecoder

      public IoBufferDecoder(int contentLength)
      Creates a new instance that will read messages of contentLength bytes.
      Parameters:
      contentLength - the exact length to read
  • Method Details

    • setContentLength

      public void setContentLength(int contentLength, boolean resetMatchCount)
      Sets the the length of the content line to be decoded. When set, it overrides the dynamic delimiter setting and content length method will be used for decoding on the next decodeOnce call. The default value is -1.
      Parameters:
      contentLength - the content length to match
      resetMatchCount - delimiter matching is reset if true
    • setDelimiter

      public void setDelimiter(byte[] delim, boolean resetMatchCount)
      Dynamically sets a new delimiter. Next time decodeFully(IoBuffer) will be called it will use the new delimiter. Delimiter matching is reset only if resetMatchCount is true but decoding will continue from current position. NB : Delimiter LineDelimiter.AUTO is not allowed.
      Parameters:
      delim - the new delimiter as a byte array
      resetMatchCount - delimiter matching is reset if true
    • decodeFully

      public IoBuffer decodeFully(IoBuffer in)
      Will return null unless it has enough data to decode. If contentLength is set then it tries to retrieve contentLength bytes from the buffer otherwise it will scan the buffer to find the data delimiter and return all the data and the trailing delimiter.
      Parameters:
      in - the data to decode
      Returns:
      The decoded buffer