java.lang.Object
org.miaixz.bus.http.plugin.httpv.CoverCall.Message
- Enclosing class:
CoverCall
Represents an incoming WebSocket message, which can be either text or binary. Provides convenient methods for
data conversion.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisText()byte[]toBytes()Converts the message content to a byte array.Returns anInputStreamfor the message content.org.miaixz.bus.core.io.ByteStringConverts the message content to aByteString.Returns aReaderfor the message content.toString()Returns the string representation of the message.
-
Constructor Details
-
Message
Constructs a message from a text string.- Parameters:
text- The text content.
-
Message
public Message(org.miaixz.bus.core.io.ByteString bytes) Constructs a message from a ByteString.- Parameters:
bytes- The binary content.
-
-
Method Details
-
isText
public boolean isText()- Returns:
trueif this is a text message,falseotherwise.
-
toBytes
public byte[] toBytes()Converts the message content to a byte array. Text messages are encoded using UTF-8.- Returns:
- The message content as a byte array, or
nullif the message is empty.
-
toString
Returns the string representation of the message. For binary messages, this decodes the bytes as a UTF-8 string. -
toByteString
public org.miaixz.bus.core.io.ByteString toByteString()Converts the message content to aByteString. Text messages are encoded using UTF-8.- Returns:
- The message content as a
ByteString.
-
toCharStream
Returns aReaderfor the message content.- Returns:
- A character stream reader.
-
toByteStream
Returns anInputStreamfor the message content.- Returns:
- A byte stream.
-