public class Attachment extends ICalProperty
Defines a binary resource that is associated with the component to which it belongs (such as an image or document).
Code sample:
VEvent event = new VEvent(); //from a byte array byte[] data = ... Attachment attach = new Attachment("image/png", data); event.addAttachment(attach); //from a file File file = new File("image.png"); attach = new Attachment("image/png", file); event.addAttachment(attach); //referencing a URL attach = new Attachment("image/png", "http://example.com/image.png"); event.addAttachment(attach);
parameters
Constructor and Description |
---|
Attachment(String formatType,
byte[] data)
Creates a new attachment.
|
Attachment(String formatType,
File file)
Creates a new attachment.
|
Attachment(String formatType,
String uri)
Creates a new attachment.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getData()
Gets the attachment's binary data.
|
String |
getFormatType()
Gets the content-type of the property's value.
|
String |
getUri()
Gets the attachment's URI.
|
void |
setData(byte[] data)
Sets the attachment's binary data.
|
void |
setFormatType(String formatType)
Sets the content-type of the property's value.
|
void |
setUri(String uri)
Sets the attachment's URI.
|
protected void |
validate(List<ICalComponent> components,
List<Warning> warnings)
Checks the property for data consistency problems or deviations from the
spec.
|
addParameter, getParameter, getParameters, getParameters, removeParameter, setParameter, setParameter, setParameters, validate
public Attachment(String formatType, File file) throws IOException
formatType
- the content-type of the data (e.g. "image/png")file
- the file to attachIOException
- if there's a problem reading from the filepublic Attachment(String formatType, byte[] data)
formatType
- the content-type of the data (e.g. "image/png")data
- the binary datapublic Attachment(String formatType, String uri)
formatType
- the content-type of the data (e.g. "image/png")uri
- a URL pointing to the resource (e.g.
"http://example.com/image.png")public byte[] getData()
public void setData(byte[] data)
data
- the binary datapublic String getUri()
public void setUri(String uri)
uri
- the URI (e.g. "http://example.com/image.png")public String getFormatType()
ICalProperty
public void setFormatType(String formatType)
ICalProperty
formatType
- the content type (e.g. "image/png") or null to removeprotected void validate(List<ICalComponent> components, List<Warning> warnings)
ICalProperty
validate
in class ICalProperty
components
- the hierarchy of components that the property belongs
towarnings
- the list to add the warnings toCopyright © 2013-2014 Michael Angstadt. All Rights Reserved.