Class UTF8Checker

  • All Implemented Interfaces:
    ChannelFunction

    public class UTF8Checker
    extends java.lang.Object
    implements ChannelFunction
    An utility class which can be used to check if a sequence of bytes or ByteBuffers contain non UTF-8 data.

    Please use a new instance per stream.

    Author:
    Norman Maurer
    • Constructor Summary

      Constructors 
      Constructor Description
      UTF8Checker()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void afterRead​(java.nio.ByteBuffer buf, int position, int length)
      Is called on the ByteBuffer after a read operation completes
      void beforeWrite​(java.nio.ByteBuffer buf, int position, int length)
      Is called on the ByteBuffer before a write operation completes
      void complete()
      Is called to complete the ChannelFunction.
      void newFrame​(FrameHeaderData headerData)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UTF8Checker

        public UTF8Checker()
    • Method Detail

      • afterRead

        public void afterRead​(java.nio.ByteBuffer buf,
                              int position,
                              int length)
                       throws java.io.IOException
        Description copied from interface: ChannelFunction
        Is called on the ByteBuffer after a read operation completes
        Specified by:
        afterRead in interface ChannelFunction
        Parameters:
        buf - the ByteBuffer to operate on
        position - the index in the ByteBuffer to start from
        length - the number of bytes to operate on
        Throws:
        java.io.IOException - thrown if an error occurs
      • beforeWrite

        public void beforeWrite​(java.nio.ByteBuffer buf,
                                int position,
                                int length)
                         throws java.io.UnsupportedEncodingException
        Description copied from interface: ChannelFunction
        Is called on the ByteBuffer before a write operation completes
        Specified by:
        beforeWrite in interface ChannelFunction
        Parameters:
        buf - the ByteBuffer to operate on
        position - the index in the ByteBuffer to start from
        length - the number of bytes to operate on
        Throws:
        java.io.UnsupportedEncodingException
      • complete

        public void complete()
                      throws java.io.UnsupportedEncodingException
        Description copied from interface: ChannelFunction
        Is called to complete the ChannelFunction. Access it after complete is called may result in unexpected behavior.
        Specified by:
        complete in interface ChannelFunction
        Throws:
        java.io.UnsupportedEncodingException