Module bus.http

Class CoverCall.Message

java.lang.Object
org.miaixz.bus.http.plugin.httpv.CoverCall.Message
Enclosing class:
CoverCall

public static class CoverCall.Message extends Object
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 Details

    • Message

      public Message(String text)
      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:
      true if this is a text message, false otherwise.
    • 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 null if the message is empty.
    • toString

      public String toString()
      Returns the string representation of the message. For binary messages, this decodes the bytes as a UTF-8 string.
      Overrides:
      toString in class Object
      Returns:
      The message content as a string, or null if the message is empty.
    • toByteString

      public org.miaixz.bus.core.io.ByteString toByteString()
      Converts the message content to a ByteString. Text messages are encoded using UTF-8.
      Returns:
      The message content as a ByteString.
    • toCharStream

      public Reader toCharStream()
      Returns a Reader for the message content.
      Returns:
      A character stream reader.
    • toByteStream

      public InputStream toByteStream()
      Returns an InputStream for the message content.
      Returns:
      A byte stream.