Class FileAttachment
- java.lang.Object
-
- microsoft.exchange.webservices.data.property.complex.ComplexProperty
-
- microsoft.exchange.webservices.data.property.complex.Attachment
-
- microsoft.exchange.webservices.data.property.complex.FileAttachment
-
- All Implemented Interfaces:
ISelfValidate,ComplexFunctionDelegate<EwsServiceXmlReader>
public final class FileAttachment extends Attachment
Represents a file attachment.
-
-
Constructor Summary
Constructors Constructor Description FileAttachment(Item owner)Initializes a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getContent()Gets the content of the attachment into memory.protected InputStreamgetContentStream()Gets the content stream.Gets the name of the file the attachment is linked to.StringgetFileName()Gets the name of the file the attachment is linked to.StringgetXmlElementName()Gets the name of the XML element.booleanisContactPhoto()Gets a value indicating whether this attachment is a contact photo.voidload(OutputStream stream)Loads the content of the file attachment into the specified stream.voidload(String fileName)Loads the content of the file attachment into the specified file.protected voidsetContent(byte[] content)Sets the content.protected voidsetContentStream(InputStream contentStream)Sets the content stream.protected voidsetFileName(String fileName)Sets the file name.voidsetIsContactPhoto(boolean isContactPhoto)Sets the checks if is contact photo.booleantryReadElementFromXml(EwsServiceXmlReader reader)Tries to read element from XML.booleantryReadElementFromXmlToPatch(EwsServiceXmlReader reader)For FileAttachment, the only thing need to patch is the AttachmentId.protected voidvalidate(int attachmentIndex)voidwriteElementsToXml(EwsServiceXmlWriter writer)Writes elements and content to XML.-
Methods inherited from class microsoft.exchange.webservices.data.property.complex.Attachment
canSetFieldValue, getContentId, getContentLocation, getContentType, getId, getIsInline, getLastModifiedTime, getName, getOwner, getSize, internalLoad, isNew, load, setContentId, setContentLocation, setContentType, setIsInline, setName, throwIfThisIsNotNew
-
Methods inherited from class microsoft.exchange.webservices.data.property.complex.ComplexProperty
addOnChangeEvent, changed, clearChangeEvents, clearChangeLog, func, getNamespace, internalValidate, loadFromXml, loadFromXml, readAttributesFromXml, readTextValueFromXml, removeChangeEvent, setNamespace, updateFromXml, updateFromXml, validate, writeAttributesToXml, writeToXml, writeToXml
-
-
-
-
Constructor Detail
-
FileAttachment
public FileAttachment(Item owner)
Initializes a new instance.- Parameters:
owner- the owner
-
-
Method Detail
-
getXmlElementName
public String getXmlElementName()
Gets the name of the XML element.- Specified by:
getXmlElementNamein classAttachment- Returns:
- XML element name
-
validate
protected void validate(int attachmentIndex) throws ServiceValidationException
- Throws:
ServiceValidationException
-
tryReadElementFromXml
public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws Exception
Tries to read element from XML.- Overrides:
tryReadElementFromXmlin classAttachment- Parameters:
reader- the reader- Returns:
- True if element was read.
- Throws:
Exception- the exception
-
tryReadElementFromXmlToPatch
public boolean tryReadElementFromXmlToPatch(EwsServiceXmlReader reader) throws Exception
For FileAttachment, the only thing need to patch is the AttachmentId.- Overrides:
tryReadElementFromXmlToPatchin classComplexProperty- Parameters:
reader- The reader.- Returns:
- true if element was read
- Throws:
Exception
-
writeElementsToXml
public void writeElementsToXml(EwsServiceXmlWriter writer) throws Exception
Writes elements and content to XML.- Overrides:
writeElementsToXmlin classAttachment- Parameters:
writer- the writer- Throws:
Exception- the exception
-
load
public void load(OutputStream stream) throws Exception
Loads the content of the file attachment into the specified stream. Calling this method results in a call to EWS.- Parameters:
stream- the stream- Throws:
Exception- the exception
-
load
public void load(String fileName) throws Exception
Loads the content of the file attachment into the specified file. Calling this method results in a call to EWS.- Parameters:
fileName- the file name- Throws:
Exception- the exception
-
getFileName
public String getFileName()
Gets the name of the file the attachment is linked to.- Returns:
- the file name
-
setFileName
protected void setFileName(String fileName)
Sets the file name.- Parameters:
fileName- the new file name
-
getContentStream
protected InputStream getContentStream()
Gets the content stream.Gets the name of the file the attachment is linked to.- Returns:
- The content stream
-
setContentStream
protected void setContentStream(InputStream contentStream)
Sets the content stream.- Parameters:
contentStream- the new content stream
-
getContent
public byte[] getContent()
Gets the content of the attachment into memory. Content is set only when Load() is called.- Returns:
- the content
-
setContent
protected void setContent(byte[] content)
Sets the content.- Parameters:
content- the new content
-
isContactPhoto
public boolean isContactPhoto() throws ServiceVersionException
Gets a value indicating whether this attachment is a contact photo.- Returns:
- true, if is contact photo
- Throws:
ServiceVersionException- the service version exception
-
setIsContactPhoto
public void setIsContactPhoto(boolean isContactPhoto) throws ServiceVersionException
Sets the checks if is contact photo.- Parameters:
isContactPhoto- the new checks if is contact photo- Throws:
ServiceVersionException- the service version exception
-
-