Package client
Class Message
java.lang.Object
client.Message
Represents a single message within a chat session.
This class acts as a data carrier for message content, which can be either
plain text or a reference to an image file, along with associated metadata.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetText()Returns the text content or the image path of the message.getTime()Returns the timestamp indicating when the message was sent.getUser()Returns the author of the message.isImage()Checks if this message represents an image.toString()Returns a string representation of the message content.
-
Constructor Details
-
Message
Constructs a new Message instance.- Parameters:
text- The message body or the file path to an image.time- The timestamp of the message.user- The User who sent the message.isImage- True if the text parameter represents an image file; false for plain text.
-
-
Method Details
-
getText
Returns the text content or the image path of the message.- Returns:
- The message string.
-
getTime
Returns the timestamp indicating when the message was sent. * @return An Instant representing the time of dispatch. -
isImage
Checks if this message represents an image.- Returns:
- True if the message is an image, false otherwise.
-
getUser
Returns the author of the message.- Returns:
- The User object of the sender.
-
toString
Returns a string representation of the message content.
-