Class TextLineDecoder

    • Constructor Detail

      • TextLineDecoder

        public TextLineDecoder()
        Creates a new instance with the current default Charset and LineDelimiter.AUTO delimiter.
      • TextLineDecoder

        public TextLineDecoder​(String delimiter)
        Creates a new instance with the current default Charset and the specified delimiter.
        Parameters:
        delimiter - The line delimiter to use
      • TextLineDecoder

        public TextLineDecoder​(LineDelimiter delimiter)
        Creates a new instance with the current default Charset and the specified delimiter.
        Parameters:
        delimiter - The line delimiter to use
      • TextLineDecoder

        public TextLineDecoder​(Charset charset)
        Creates a new instance with the spcified charset and LineDelimiter.AUTO delimiter.
        Parameters:
        charset - The Charset to use
      • TextLineDecoder

        public TextLineDecoder​(Charset charset,
                               String delimiter)
        Creates a new instance with the spcified charset and the specified delimiter.
        Parameters:
        charset - The Charset to use
        delimiter - The line delimiter to use
      • TextLineDecoder

        public TextLineDecoder​(Charset charset,
                               LineDelimiter delimiter)
        Creates a new instance with the specified charset and the specified delimiter.
        Parameters:
        charset - The Charset to use
        delimiter - The line delimiter to use
    • Method Detail

      • getMaxLineLength

        public int getMaxLineLength()
        Returns:
        the allowed maximum size of the line to be decoded. If the size of the line to be decoded exceeds this value, the decoder will throw a BufferDataException. The default value is 1024 (1KB).
      • setMaxLineLength

        public void setMaxLineLength​(int maxLineLength)
        Sets the allowed maximum size of the line to be decoded. If the size of the line to be decoded exceeds this value, the decoder will throw a BufferDataException. The default value is 1024 (1KB).
        Parameters:
        maxLineLength - The maximum line length
      • setBufferLength

        public void setBufferLength​(int bufferLength)
        Sets the default buffer size. This buffer is used in the Context to store the decoded line.
        Parameters:
        bufferLength - The default bufer size
      • getBufferLength

        public int getBufferLength()
        Returns:
        the allowed buffer size used to store the decoded line in the Context instance.
      • dispose

        public void dispose​(IoSession session)
                     throws Exception
        Releases all resources related with this decoder.
        Specified by:
        dispose in interface ProtocolDecoder
        Parameters:
        session - The current Session
        Throws:
        Exception - if failed to dispose all resources
      • writeText

        protected void writeText​(IoSession session,
                                 String text,
                                 ProtocolDecoderOutput out)
        By default, this method propagates the decoded line of text to ProtocolDecoderOutput#write(Object). You may override this method to modify the default behavior.
        Parameters:
        session - the IoSession the received data.
        text - the decoded text
        out - the upstream ProtocolDecoderOutput.