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 |
---|---|
String |
getContentId()
Gets the attachment's content ID.
|
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 |
setContentId(String contentId)
Assigns a content ID to the attachment's value.
|
void |
setData(byte[] data)
Assigns binary data to the attachment's value.
|
void |
setFormatType(String formatType)
Sets the content-type of the property's value.
|
void |
setUri(String uri)
Assigns a URI to the attachment's value.
|
protected void |
validate(List<ICalComponent> components,
ICalVersion version,
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 getContentId()
public void setContentId(String contentId)
contentId
- the content IDpublic 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, ICalVersion version, List<Warning> warnings)
ICalProperty
Checks the property for data consistency problems or deviations from the spec.
This method should be overridden by child classes that wish to provide validation logic. The default implementation of this method does nothing.
validate
in class ICalProperty
components
- the hierarchy of components that the property belongs
toversion
- the version to validate againstwarnings
- the list to add the warnings toCopyright © 2013-2015 Michael Angstadt. All Rights Reserved.