public class Attachment extends Object
Constructor and Description |
---|
Attachment()
Instantiates 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.
|
Modifier and Type | Method and Description |
---|---|
String |
getAttachmentId()
Returns the unique replacement token for the attachment.
|
byte[] |
getContent()
Returns the content of the attachment as a byte array.
|
String |
getContentString()
Returns the content of the attachment as a string, using UTF-8 encoding.
|
String |
getContentString(String charset)
Returns the content of the attachment as a string, using the specified charset encoding.
|
String |
getId()
Returns the unique ID for the attachment.
|
String |
getType()
Returns the MIME type of the attachment.
|
void |
setContent(byte[] content)
Sets the content of the attachment.
|
void |
setContentString(String content)
Sets the content of the attachment, using UTF-8 encoding.
|
void |
setContentString(String content,
String charset)
Sets the content of the attachment, using the specified charset encoding.
|
void |
setId(String id)
Sets the unique ID for the attachment.
|
void |
setType(String type)
Sets the MIME type for the attachment.
|
public Attachment()
public Attachment(String id, byte[] content, String type)
id
- The unique ID of the attachment.content
- The content (byte array) to store for the attachment.type
- The MIME type of the attachment.public Attachment(String id, String content, String type) throws UnsupportedEncodingException
id
- The unique ID of the attachment.content
- The string representation of the attachment content.type
- The MIME type of the attachment.UnsupportedEncodingException
- If the named charset is not supported.public Attachment(String id, String content, String charset, String type) throws UnsupportedEncodingException
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.UnsupportedEncodingException
- If the named charset is not supported.public String getAttachmentId()
public String getId()
public void setId(String id)
id
- The unique ID to use for the attachment.public byte[] getContent()
public String getContentString() throws UnsupportedEncodingException
UnsupportedEncodingException
- If the named charset is not supported.public String getContentString(String charset) throws UnsupportedEncodingException
charset
- The charset encoding to convert the content bytes to a string with.UnsupportedEncodingException
- If the named charset is not supported.public void setContent(byte[] content)
content
- The content (byte array) to use for the attachment.public void setContentString(String content) throws UnsupportedEncodingException
content
- The string representation of the attachment content.UnsupportedEncodingException
- If the named charset is not supported.public void setContentString(String content, String charset) throws UnsupportedEncodingException
content
- The string representation of the attachment content.charset
- The charset encoding to convert the string to bytes with.UnsupportedEncodingException
- If the named charset is not supported.public String getType()
public void setType(String type)
type
- The MIME type to set for the attachment.