Class AttachmentCollection
- java.lang.Object
-
- microsoft.exchange.webservices.data.property.complex.ComplexProperty
-
- microsoft.exchange.webservices.data.property.complex.ComplexPropertyCollection<Attachment>
-
- microsoft.exchange.webservices.data.property.complex.AttachmentCollection
-
- All Implemented Interfaces:
Iterable<Attachment>,ICustomXmlUpdateSerializer,ISelfValidate,ComplexFunctionDelegate<EwsServiceXmlReader>,IComplexPropertyChangedDelegate<Attachment>,IOwnedProperty
public final class AttachmentCollection extends ComplexPropertyCollection<Attachment> implements IOwnedProperty
Represents an item's attachment collection.
-
-
Constructor Summary
Constructors Constructor Description AttachmentCollection()Initializes a new instance of AttachmentCollection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AttachmentaddAttachment(Attachment attachment)Adds a file attachment to the collection.FileAttachmentaddFileAttachment(String fileName)Adds a file attachment to the collection.FileAttachmentaddFileAttachment(String name, byte[] content)Adds a file attachment to the collection.FileAttachmentaddFileAttachment(String name, InputStream contentStream)Adds a file attachment to the collection.FileAttachmentaddFileAttachment(String name, String fileName)Adds a file attachment to the collection.<TItem extends Item>
GenericItemAttachment<TItem>addItemAttachment(Class<TItem> cls)Adds an item attachment to the collection.voidclear()Removes all attachments from this collection.voidclearChangeLog()Disables the change log clearing mechanism.protected AttachmentcreateComplexProperty(String xmlElementName)Instantiate the appropriate attachment type depending on the current XML element name.protected StringgetCollectionItemXmlElementName(Attachment complexProperty)Determines the name of the XML element associated with the complexProperty parameter.ServiceObjectgetOwner()The owner of this attachment collection.booleanhasUnprocessedChanges()Determines whether there are any unsaved attachment collection changes.booleanremove(Attachment attachment)Removes the specified attachment.voidremoveAt(int index)Removes the attachment at the specified index.voidsave()Saves this collection by creating new attachment and deleting removed ones.voidsetOwner(ServiceObject value)The owner of this attachment collection.voidvalidate()Validates this instance.-
Methods inherited from class microsoft.exchange.webservices.data.property.complex.ComplexPropertyCollection
complexPropertyChanged, contains, getAddedItems, getCount, getItems, getModifiedItems, getPropertyAtIndex, getRemovedItems, indexOf, internalAdd, internalClear, internalRemove, internalRemoveAt, itemChanged, iterator, loadFromXml, loadFromXml, removeFromChangeLog, shouldWriteToXml, updateFromXml, writeDeleteUpdateToXml, writeElementsToXml, writeSetUpdateToXml, writeToXml
-
Methods inherited from class microsoft.exchange.webservices.data.property.complex.ComplexProperty
addOnChangeEvent, canSetFieldValue, changed, clearChangeEvents, func, getNamespace, internalValidate, readAttributesFromXml, readTextValueFromXml, removeChangeEvent, setNamespace, tryReadElementFromXml, tryReadElementFromXmlToPatch, updateFromXml, writeAttributesToXml, writeToXml
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
AttachmentCollection
public AttachmentCollection()
Initializes a new instance of AttachmentCollection.
-
-
Method Detail
-
getOwner
public ServiceObject getOwner()
The owner of this attachment collection.- Specified by:
getOwnerin interfaceIOwnedProperty- Returns:
- the owner
-
setOwner
public void setOwner(ServiceObject value)
The owner of this attachment collection.- Specified by:
setOwnerin interfaceIOwnedProperty- Parameters:
value- accepts ServiceObject
-
addFileAttachment
public FileAttachment addFileAttachment(String fileName)
Adds a file attachment to the collection.- Parameters:
fileName- the file name- Returns:
- A FileAttachment instance.
-
addFileAttachment
public FileAttachment addFileAttachment(String name, String fileName)
Adds a file attachment to the collection.- Parameters:
name- accepts String display name of the new attachment.fileName- accepts String name of the file representing the content of the attachment.- Returns:
- A FileAttachment instance.
-
addFileAttachment
public FileAttachment addFileAttachment(String name, InputStream contentStream)
Adds a file attachment to the collection.- Parameters:
name- accepts String display name of the new attachment.contentStream- accepts InputStream stream from which to read the content of the attachment.- Returns:
- A FileAttachment instance.
-
addFileAttachment
public FileAttachment addFileAttachment(String name, byte[] content)
Adds a file attachment to the collection.- Parameters:
name- the namecontent- accepts byte byte arrays representing the content of the attachment.- Returns:
- FileAttachment
-
addAttachment
public Attachment addAttachment(Attachment attachment)
Adds a file attachment to the collection.- Parameters:
name- the namecontent- accepts byte byte arrays representing the content of the attachment.- Returns:
- FileAttachment
-
addItemAttachment
public <TItem extends Item> GenericItemAttachment<TItem> addItemAttachment(Class<TItem> cls) throws Exception
Adds an item attachment to the collection.- Type Parameters:
TItem- the generic type- Parameters:
cls- the cls- Returns:
- An ItemAttachment instance.
- Throws:
Exception- the exception
-
clear
public void clear()
Removes all attachments from this collection.
-
removeAt
public void removeAt(int index)
Removes the attachment at the specified index.- Parameters:
index- Index of the attachment to remove.
-
remove
public boolean remove(Attachment attachment) throws Exception
Removes the specified attachment.- Parameters:
attachment- The attachment to remove.- Returns:
- True if the attachment was successfully removed from the collection, false otherwise.
- Throws:
Exception- the exception
-
createComplexProperty
protected Attachment createComplexProperty(String xmlElementName)
Instantiate the appropriate attachment type depending on the current XML element name.- Specified by:
createComplexPropertyin classComplexPropertyCollection<Attachment>- Parameters:
xmlElementName- The XML element name from which to determine the type of attachment to create.- Returns:
- An Attachment instance.
-
getCollectionItemXmlElementName
protected String getCollectionItemXmlElementName(Attachment complexProperty)
Determines the name of the XML element associated with the complexProperty parameter.- Specified by:
getCollectionItemXmlElementNamein classComplexPropertyCollection<Attachment>- Parameters:
complexProperty- The attachment object for which to determine the XML element name with.- Returns:
- The XML element name associated with the complexProperty parameter.
-
save
public void save() throws Exception
Saves this collection by creating new attachment and deleting removed ones.- Throws:
Exception- the exception
-
hasUnprocessedChanges
public boolean hasUnprocessedChanges() throws ServiceLocalException
Determines whether there are any unsaved attachment collection changes.- Returns:
- True if attachment adds or deletes haven't been processed yet.
- Throws:
ServiceLocalException
-
clearChangeLog
public void clearChangeLog()
Disables the change log clearing mechanism. Attachment collections are saved separately from the item they belong to.- Overrides:
clearChangeLogin classComplexPropertyCollection<Attachment>
-
validate
public void validate() throws Exception
Validates this instance.- Specified by:
validatein interfaceISelfValidate- Overrides:
validatein classComplexProperty- Throws:
Exception- the exception
-
-