Top Description Fields Constructors Methods
org.springframework.web.socket

public final Class TextMessage

extends AbstractWebSocketMessage<String>
Class Inheritance
Imports
java.nio.charset.StandardCharsets, org.springframework.lang.Nullable

A text WebSocket message.
Author
Rossen Stoyanchev
Since
4.0

Field Summary

Modifier and TypeField and Description
private final byte[]

Constructor Summary

AccessConstructor and Description
public
TextMessage(CharSequence
the non-null payload
payload
)

Create a new text WebSocket message from the given CharSequence payload.

public
TextMessage(byte[]
the non-null payload
payload
)

Create a new text WebSocket message from the given byte[].

public
TextMessage(CharSequence
the non-null payload
payload
,
boolean
whether this the last part of a series of partial messages
isLast
)

Create a new text WebSocket message with the given payload representing the full or partial message content.

Method Summary

Modifier and TypeMethod and Description
public byte[]
public int
getPayloadLength()

Implements org.springframework.web.socket.WebSocketMessage.getPayloadLength.

Return the number of bytes contained in the message.

protected String
Inherited from org.springframework.web.socket.AbstractWebSocketMessage:
equalsgetPayloadhashCodeisLasttoString

Field Detail

bytesback to summary
private final byte[] bytes
Annotations
@Nullable

Constructor Detail

TextMessageback to summary
public TextMessage(CharSequence payload)

Create a new text WebSocket message from the given CharSequence payload.

Parameters
payload:CharSequence

the non-null payload

TextMessageback to summary
public TextMessage(byte[] payload)

Create a new text WebSocket message from the given byte[]. It is assumed the byte array can be encoded into an UTF-8 String.

Parameters
payload:byte[]

the non-null payload

TextMessageback to summary
public TextMessage(CharSequence payload, boolean isLast)

Create a new text WebSocket message with the given payload representing the full or partial message content. When the isLast boolean flag is set to false the message is sent as partial content and more partial messages will be expected until the boolean flag is set to true.

Parameters
payload:CharSequence

the non-null payload

isLast:boolean

whether this the last part of a series of partial messages

Method Detail

asBytesback to summary
public byte[] asBytes()
getPayloadLengthback to summary
public int getPayloadLength()

Implements org.springframework.web.socket.WebSocketMessage.getPayloadLength.

Doc from org.springframework.web.socket.WebSocketMessage.getPayloadLength.

Return the number of bytes contained in the message.

Annotations
@Override
toStringPayloadback to summary
protected String toStringPayload()

Implements abstract org.springframework.web.socket.AbstractWebSocketMessage.toStringPayload.

Annotations
@Override