Class Attachment
java.lang.Object
com.mirth.connect.server.userutil.Attachment
Used to store and retrieve details about message attachments such as the ID, MIME type, and
content.
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a new Attachment with no ID, content, or MIME type.Attachment(String id, byte[] content, String type) Instantiates a new Attachment.Attachment(String id, String content, String type) Instantiates a new Attachment with String data using UTF-8 charset encoding.Attachment(String id, String content, String charset, String type) Instantiates a new Attachment with String data and a given charset encoding. -
Method Summary
Modifier and TypeMethodDescriptionReturns the unique replacement token for the attachment.byte[]Returns the content of the attachment as a byte array.Returns the content of the attachment as a string, using UTF-8 encoding.getContentString(String charset) Returns the content of the attachment as a string, using the specified charset encoding.getId()Returns the unique ID for the attachment.getType()Returns the MIME type of the attachment.voidsetContent(byte[] content) Sets the content of the attachment.voidsetContentString(String content) Sets the content of the attachment, using UTF-8 encoding.voidsetContentString(String content, String charset) Sets the content of the attachment, using the specified charset encoding.voidSets the unique ID for the attachment.voidSets the MIME type for the attachment.
-
Constructor Details
-
Attachment
public Attachment()Instantiates a new Attachment with no ID, content, or MIME type. -
Attachment
Instantiates a new Attachment.- Parameters:
id- The unique ID of the attachment.content- The content (byte array) to store for the attachment.type- The MIME type of the attachment.
-
Attachment
Instantiates a new Attachment with String data using UTF-8 charset encoding.- Parameters:
id- The unique ID of the attachment.content- The string representation of the attachment content.type- The MIME type of the attachment.- Throws:
UnsupportedEncodingException- If the named charset is not supported.
-
Attachment
public Attachment(String id, String content, String charset, String type) throws UnsupportedEncodingException Instantiates a new Attachment with String data and a given charset encoding.- Parameters:
id- The unique ID of the attachment.content- The string representation of the attachment content.charset- The charset encoding to convert the string to bytes with.type- The MIME type of the attachment.- Throws:
UnsupportedEncodingException- If the named charset is not supported.
-
-
Method Details
-
getAttachmentId
Returns the unique replacement token for the attachment. This token should replace the attachment content in the message string, and will be used to re-attach the attachment content in the outbound message before it is sent to a downstream system.- Returns:
- The unique replacement token for the attachment.
-
getId
Returns the unique ID for the attachment.- Returns:
- The unique ID for the attachment.
-
setId
Sets the unique ID for the attachment.- Parameters:
id- The unique ID to use for the attachment.
-
getContent
public byte[] getContent()Returns the content of the attachment as a byte array.- Returns:
- The content of the attachment as a byte array.
-
getContentString
Returns the content of the attachment as a string, using UTF-8 encoding.- Returns:
- The content of the attachment as a string, using UTF-8 encoding.
- Throws:
UnsupportedEncodingException- If the named charset is not supported.
-
getContentString
Returns the content of the attachment as a string, using the specified charset encoding.- Parameters:
charset- The charset encoding to convert the content bytes to a string with.- Returns:
- The content of the attachment as a string, using the specified charset encoding.
- Throws:
UnsupportedEncodingException- If the named charset is not supported.
-
setContent
public void setContent(byte[] content) Sets the content of the attachment.- Parameters:
content- The content (byte array) to use for the attachment.
-
setContentString
Sets the content of the attachment, using UTF-8 encoding.- Parameters:
content- The string representation of the attachment content.- Throws:
UnsupportedEncodingException- If the named charset is not supported.
-
setContentString
Sets the content of the attachment, using the specified charset encoding.- Parameters:
content- The string representation of the attachment content.charset- The charset encoding to convert the string to bytes with.- Throws:
UnsupportedEncodingException- If the named charset is not supported.
-
getType
Returns the MIME type of the attachment.- Returns:
- The MIME type of the attachment.
-
setType
Sets the MIME type for the attachment.- Parameters:
type- The MIME type to set for the attachment.
-