biweekly.property
Class Attachment

java.lang.Object
  extended by biweekly.property.ICalProperty
      extended by biweekly.property.Attachment

public class Attachment
extends ICalProperty

Represents a binary resource that is associated with an event, to-do, journal entry, or alarm.

Examples:

 //from a byte array
 byte[] data = ...
 Attachment attach = new Attachment("image/png", data);
 
 //reading from a file 
 Attachment attach = new Attachment("image/png", new File("image.png"));
 
 //referencing a URL
 Attachment attach = new Attachment("image/png", "http://example.com/image.png");
 

Author:
Michael Angstadt
Specification Reference:
RFC 5545 p.80-1

Field Summary
 
Fields inherited from class biweekly.property.ICalProperty
parameters
 
Constructor Summary
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.
 
Method Summary
 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<String> warnings)
          Checks the property for data consistency problems or deviations from the spec.
 
Methods inherited from class biweekly.property.ICalProperty
addParameter, getParameter, getParameters, getParameters, removeParameter, setParameter, setParameter, setParameters, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Attachment

public Attachment(String formatType,
                  File file)
           throws IOException
Creates a new attachment.

Parameters:
formatType - the content-type of the data (e.g. "image/png")
file - the file to attach
Throws:
IOException - if there's a problem reading from the file

Attachment

public Attachment(String formatType,
                  byte[] data)
Creates a new attachment.

Parameters:
formatType - the content-type of the data (e.g. "image/png")
data - the binary data

Attachment

public Attachment(String formatType,
                  String uri)
Creates a new attachment.

Parameters:
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")
Method Detail

getData

public byte[] getData()
Gets the attachment's binary data.

Returns:
the binary data or null if not set

setData

public void setData(byte[] data)
Sets the attachment's binary data. If the attachment has a URI associated with it, the URI will be set to null.

Parameters:
data - the binary data

getUri

public String getUri()
Gets the attachment's URI.

Returns:
the URI (e.g. "http://example.com/image.png") or null if not set

setUri

public void setUri(String uri)
Sets the attachment's URI. If the attachment has binary data associated with it, the binary data will be set to null.

Parameters:
uri - the URI (e.g. "http://example.com/image.png")

getFormatType

public String getFormatType()
Description copied from class: ICalProperty
Gets the content-type of the property's value.

Returns:
the content type (e.g. "image/png") or null if not set

setFormatType

public void setFormatType(String formatType)
Description copied from class: ICalProperty
Sets the content-type of the property's value.

Parameters:
formatType - the content type (e.g. "image/png") or null to remove

validate

protected void validate(List<ICalComponent> components,
                        List<String> warnings)
Description copied from class: ICalProperty
Checks the property for data consistency problems or deviations from the spec. Meant to be overridden by child classes that wish to provide validation logic.

Overrides:
validate in class ICalProperty
Parameters:
components - the hierarchy of components that the property belongs to
warnings - the list to add the warnings to


Copyright © 2013 Michael Angstadt. All Rights Reserved.