java.lang.Object
com.aoapps.messaging.MultiMessage
- All Implemented Interfaces:
Message
,Closeable
,AutoCloseable
A message that is a combination of multiple messages.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMultiMessage
(Collection<? extends Message> messages) Creates a new multi-message. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes each of the underlying messages.static MultiMessage
Deprecated.static MultiMessage
decode
(ByteArray encodedMessages, IOSupplier<TempFileContext> tempFileContextSupplier) Decodes the messages using the providedtemporary file context
suppler as-needed.static MultiMessage
decode
(ByteArray encodedMessages, TempFileContext tempFileContext) Deprecated.Please useTempFileContext
supplier which may defer creation until first needed.static MultiMessage
Deprecated.Please useTempFileContext
supplier sinceFile.deleteOnExit()
is prone to memory leaks in long-running applications.static MultiMessage
decode
(String encodedMessages, IOSupplier<TempFileContext> tempFileContextSupplier) Decodes the messages using the providedtemporary file context
supplier as-needed.static MultiMessage
decode
(String encodedMessages, TempFileContext tempFileContext) Deprecated.Please useTempFileContext
supplier which may defer creation until first needed.Encodes the messages into a single ByteArray.Encodes the messages into a single string.boolean
Two messages of the same type with the same body must be considered equal.Collection
<? extends Message> Gets the messages or empty list for none.Gets the message type.int
hashCode()
The hash code must be consistent with equals.toString()
-
Field Details
-
EMPTY_MULTI_MESSAGE
-
-
Constructor Details
-
MultiMessage
Creates a new multi-message.- Parameters:
messages
- The messages ornull
for none, defensive copy if performed
-
-
Method Details
-
decode
public static MultiMessage decode(String encodedMessages, IOSupplier<TempFileContext> tempFileContextSupplier) throws IOException Decodes the messages using the providedtemporary file context
supplier as-needed.- Throws:
IOException
-
decode
@Deprecated public static MultiMessage decode(String encodedMessages, TempFileContext tempFileContext) throws IOException Deprecated.Please useTempFileContext
supplier which may defer creation until first needed.Decodes the messages using the providedtemporary file context
as-needed.- Throws:
IOException
- See Also:
-
decode
Deprecated.Please useTempFileContext
supplier sinceFile.deleteOnExit()
is prone to memory leaks in long-running applications.Decodes the messages, possibly using temporary files withFile.deleteOnExit()
as-needed.- Throws:
IOException
- See Also:
-
decode
public static MultiMessage decode(ByteArray encodedMessages, IOSupplier<TempFileContext> tempFileContextSupplier) throws IOException Decodes the messages using the providedtemporary file context
suppler as-needed.- Throws:
IOException
-
decode
@Deprecated public static MultiMessage decode(ByteArray encodedMessages, TempFileContext tempFileContext) throws IOException Deprecated.Please useTempFileContext
supplier which may defer creation until first needed.Decodes the messages using the providedtemporary file context
as-needed.- Throws:
IOException
- See Also:
-
decode
Deprecated.Please useTempFileContext
supplier sinceFile.deleteOnExit()
is prone to memory leaks in long-running applications.Decodes the messages, possibly using temporary files withFile.deleteOnExit()
as-needed.- Throws:
IOException
- See Also:
-
toString
-
equals
Description copied from interface:Message
Two messages of the same type with the same body must be considered equal. -
hashCode
public int hashCode()Description copied from interface:Message
The hash code must be consistent with equals. -
getMessageType
Description copied from interface:Message
Gets the message type.- Specified by:
getMessageType
in interfaceMessage
-
encodeAsString
Encodes the messages into a single string.- Specified by:
encodeAsString
in interfaceMessage
- Throws:
IOException
-
encodeAsByteArray
Encodes the messages into a single ByteArray. There is likely a more efficient implementation that reads-through, but this is a simple implementation.- Specified by:
encodeAsByteArray
in interfaceMessage
- Throws:
IOException
-
close
Closes each of the underlying messages.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceMessage
- Throws:
IOException
-
getMessages
Gets the messages or empty list for none.
-
TempFileContext
supplier sinceFile.deleteOnExit()
is prone to memory leaks in long-running applications.