Top Description Fields Constructors Methods
io.undertow.websockets.core.protocol.version07

public Class UTF8Checker

extends Object
implements ChannelFunction
Class Inheritance
All Implemented Interfaces
io.undertow.websockets.core.function.ChannelFunction
Known Direct Subclasses
io.undertow.websockets.core.protocol.version07.WebSocket07CloseFrameSourceChannel.CloseFrameValidatorChannelFunction
Imports
io.undertow.server.protocol.framed.FrameHeaderData, io.undertow.websockets.core.WebSocketMessages, io.undertow.websockets.core.function.ChannelFunction, java.io.IOException, .UnsupportedEncodingException, java.nio.ByteBuffer

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

Field Summary

Modifier and TypeField and Description
private int
private static final byte[]
private static final byte[]
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterRead(ByteBuffer
the ByteBuffer to operate on
buf
,
int
the index in the ByteBuffer to start from
position
,
int
the number of bytes to operate on
length
)

Implements io.undertow.websockets.core.function.ChannelFunction.afterRead.

Is called on the ByteBuffer after a read operation completes

public void
beforeWrite(ByteBuffer
the ByteBuffer to operate on
buf
,
int
the index in the ByteBuffer to start from
position
,
int
the number of bytes to operate on
length
)

Implements io.undertow.websockets.core.function.ChannelFunction.beforeWrite.

Is called on the ByteBuffer before a write operation completes

private void
checkUTF8(int b)

private void
checkUTF8(ByteBuffer
the ByteBuffer to check
buf
,
int
the index in the ByteBuffer to start from
position
,
int
the number of bytes to operate on
length
)

Check if the given ByteBuffer contains non UTF-8 data.

public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

stateback to summary
private int state
STATESback to summary
private static final byte[] STATES
TYPESback to summary
private static final byte[] TYPES
UTF8_ACCEPTback to summary
private static final int UTF8_ACCEPT
UTF8_REJECTback to summary
private static final int UTF8_REJECT

Constructor Detail

UTF8Checkerback to summary
public UTF8Checker()

Method Detail

afterReadback to summary
public void afterRead(ByteBuffer buf, int position, int length) throws IOException

Implements io.undertow.websockets.core.function.ChannelFunction.afterRead.

Doc from io.undertow.websockets.core.function.ChannelFunction.afterRead.

Is called on the ByteBuffer after a read operation completes

Parameters
buf:ByteBuffer

the ByteBuffer to operate on

position:int

the index in the ByteBuffer to start from

length:int

the number of bytes to operate on

Annotations
@Override
Exceptions
IOException:
thrown if an error occurs
beforeWriteback to summary
public void beforeWrite(ByteBuffer buf, int position, int length) throws UnsupportedEncodingException

Implements io.undertow.websockets.core.function.ChannelFunction.beforeWrite.

Doc from io.undertow.websockets.core.function.ChannelFunction.beforeWrite.

Is called on the ByteBuffer before a write operation completes

Parameters
buf:ByteBuffer

the ByteBuffer to operate on

position:int

the index in the ByteBuffer to start from

length:int

the number of bytes to operate on

Annotations
@Override
checkUTF8back to summary
private void checkUTF8(int b) throws UnsupportedEncodingException
checkUTF8back to summary
private void checkUTF8(ByteBuffer buf, int position, int length) throws UnsupportedEncodingException

Check if the given ByteBuffer contains non UTF-8 data.

Parameters
buf:ByteBuffer

the ByteBuffer to check

position:int

the index in the ByteBuffer to start from

length:int

the number of bytes to operate on

Exceptions
UnsupportedEncodingException:
is thrown if non UTF-8 data is found
completeback to summary
public void complete() throws UnsupportedEncodingException

Implements io.undertow.websockets.core.function.ChannelFunction.complete.

Doc from io.undertow.websockets.core.function.ChannelFunction.complete.

Is called to complete the ChannelFunction. Access it after complete is called may result in unexpected behavior.

Annotations
@Override
newFrameback to summary
public void newFrame(FrameHeaderData headerData)

Implements io.undertow.websockets.core.function.ChannelFunction.newFrame.

Annotations
@Override