Top Description Fields Constructors Methods
org.glassfish.tyrus.core.frame

public Class TextFrame

extends TyrusFrame
Class Inheritance
Imports
java.nio.Buffer, .ByteBuffer, .CharBuffer, java.nio.charset.CharacterCodingException, .Charset, .CharsetDecoder, .CharsetEncoder, .CoderResult, org.glassfish.tyrus.core.StrictUtf8, .TyrusWebSocket, .Utf8DecodingException

Text frame representation.
Author
Pavel Bucek

Field Summary

Modifier and TypeField and Description
private final boolean
private final CharsetDecoder
private ByteBuffer
private final String
private final Charset

Constructor Summary

AccessConstructor and Description
public
TextFrame(Frame
original (text) frame.
frame
,
ByteBuffer
UTF-8 decoding remainder from previously processed frame.
remainder
)

Constructor.

public
TextFrame(Frame
original (text) frame.
frame
,
ByteBuffer
UTF-8 decoding remainder from previously processed frame.
remainder
,
boolean
true when this frame is continuation frame, false otherwise.
continuation
)

Constructor.

public
TextFrame(String
text message (will be encoded using strict UTF-8 encoding).
message
,
boolean
true when this frame is continuation frame, false otherwise.
continuation
,
boolean
true when this frame is last in current partial message batch. Standard (non-continuous) frames have this bit set to true.
fin
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
private static byte[]
copyOf(byte[] original, int newLength)

private static byte[]
encode(Charset charset, String string)

private ByteBuffer
getByteBuffer(final byte[] data, ByteBuffer remainder)

public ByteBuffer

Returns:

UTF-8 decoding remainder. Used internally to decoding next incoming frame.
getRemainder
()

Remainder after UTF-8 decoding.

public String

Returns:

text payload.
getTextPayload
()

Get text payload.

public void
respond(TyrusWebSocket
socket on which the appropriate action will be performed.
socket
)

Implements abstract org.glassfish.tyrus.core.frame.TyrusFrame.respond.

Execution part of frame processing.

private static byte[]
safeTrim(byte[] ba, int len)

private static int
scale(int len, float expansionFactor)

public String
toString()

Overrides org.glassfish.tyrus.core.frame.Frame.toString.

Returns a string representation of the object.

private String
utf8Decode(boolean finalFragment, byte[] data, ByteBuffer remainder)

Inherited from org.glassfish.tyrus.core.frame.TyrusFrame:
getFrameTypewrap

Field Detail

continuationback to summary
private final boolean continuation
currentDecoderback to summary
private final CharsetDecoder currentDecoder
remainderback to summary
private ByteBuffer remainder
textPayloadback to summary
private final String textPayload
utf8back to summary
private final Charset utf8

Constructor Detail

TextFrameback to summary
public TextFrame(Frame frame, ByteBuffer remainder)

Constructor.

Parameters
frame:Frame

original (text) frame.

remainder:ByteBuffer

UTF-8 decoding remainder from previously processed frame.

TextFrameback to summary
public TextFrame(Frame frame, ByteBuffer remainder, boolean continuation)

Constructor.

Parameters
frame:Frame

original (text) frame.

remainder:ByteBuffer

UTF-8 decoding remainder from previously processed frame.

continuation:boolean

true when this frame is continuation frame, false otherwise.

TextFrameback to summary
public TextFrame(String message, boolean continuation, boolean fin)

Constructor.

Parameters
message:String

text message (will be encoded using strict UTF-8 encoding).

continuation:boolean

true when this frame is continuation frame, false otherwise.

fin:boolean

true when this frame is last in current partial message batch. Standard (non-continuous) frames have this bit set to true.

Method Detail

copyOfback to summary
private static byte[] copyOf(byte[] original, int newLength)
encodeback to summary
private static byte[] encode(Charset charset, String string)
getByteBufferback to summary
private ByteBuffer getByteBuffer(final byte[] data, ByteBuffer remainder)
getRemainderback to summary
public ByteBuffer getRemainder()

Remainder after UTF-8 decoding.

This might be removed in the future, if encoding part will be separated from text frame impl.

Returns:ByteBuffer

UTF-8 decoding remainder. Used internally to decoding next incoming frame.

getTextPayloadback to summary
public String getTextPayload()

Get text payload.

Returns:String

text payload.

respondback to summary
public void respond(TyrusWebSocket socket)

Implements abstract org.glassfish.tyrus.core.frame.TyrusFrame.respond.

Doc from org.glassfish.tyrus.core.frame.TyrusFrame.respond.

Execution part of frame processing.

Parameters
socket:TyrusWebSocket

socket on which the appropriate action will be performed.

Annotations
@Override
safeTrimback to summary
private static byte[] safeTrim(byte[] ba, int len)
scaleback to summary
private static int scale(int len, float expansionFactor)
toStringback to summary
public String toString()

Overrides org.glassfish.tyrus.core.frame.Frame.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
utf8Decodeback to summary
private String utf8Decode(boolean finalFragment, byte[] data, ByteBuffer remainder)