io.undertow.websockets.core.protocol.version07

## Class UTF8Checker

- java.lang.Object
- - io.undertow.websockets.core.protocol.version07.UTF8Checker

All Implemented Interfaces:
  ChannelFunction

    public class UTF8Checker
    extends 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 and Description
`UTF8Checker()`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `afterRead(ByteBuffer buf, int position, int length)` Is called on the `ByteBuffer` after a read operation completes
`void` `beforeWrite(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

#### newFrame

    public void newFrame(FrameHeaderData headerData)

Specified by:
  `newFrame` in interface `ChannelFunction`

#### afterRead

    public void afterRead(ByteBuffer buf,
                          int position,
                          int length)
                   throws 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:
  `IOException` - thrown if an error occurs

#### beforeWrite

    public void beforeWrite(ByteBuffer buf,
                            int position,
                            int length)
                     throws 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:
  `UnsupportedEncodingException`

#### complete

    public void complete()
                  throws 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:
  `UnsupportedEncodingException`