org.ws4d.java.attachment.interfaces.incoming
Interface IncomingFileAttachment

All Superinterfaces:
Attachment, IncomingAttachment
All Known Implementing Classes:
AttachmentStub

public interface IncomingFileAttachment
extends IncomingAttachment


Field Summary
 
Fields inherited from interface org.ws4d.java.attachment.Attachment
FILE_ATTACHMENT, MEMORY_ATTACHMENT, OUTPUTSTREAM_ATTACHMENT, STREAM_ATTACHMENT
 
Method Summary
 java.lang.String getFilePath()
          Returns the path to the file encapsulated by this attachment.
 boolean isLocal()
          Returns true, if this attachment was created locally.
 boolean move(java.lang.String newFilePath)
          This method moves the file containing the attachment's raw data to the given target file path (e.g.
 void save(java.lang.String targetFilePath)
          Copies the attachment's raw data to the target file path (e.g.
 
Methods inherited from interface org.ws4d.java.attachment.IncomingAttachment
getBytes, getInputStream, isAvailable, size
 
Methods inherited from interface org.ws4d.java.attachment.Attachment
dispose, getContentId, getContentType, getTransferEncoding, getType, serialize
 

Method Detail

getFilePath

java.lang.String getFilePath()
                             throws AttachmentException
Returns the path to the file encapsulated by this attachment. This method is only legal for attachments of type Attachment.FILE_ATTACHMENT. For any other types, it will throw an AttachmentException.

Returns:
the path to the file containing the attachments raw data
Throws:
AttachmentException

save

void save(java.lang.String targetFilePath)
          throws AttachmentException,
                 java.io.IOException
Copies the attachment's raw data to the target file path (e.g. "C:/folder/file.gif"). This method can only be used for attachments of type Attachment.FILE_ATTACHMENT. In any other cases it will throw an AttachmentException.

Parameters:
targetFilePath - the new path within the local file system to store the file to
Throws:
AttachmentException - if attachment processing is not supported within the current runtime or obtaining the attachment failed for any reason
java.io.IOException - in case writing to the local file system failed for any reason

move

boolean move(java.lang.String newFilePath)
             throws AttachmentException
This method moves the file containing the attachment's raw data to the given target file path (e.g. "C:/folder/file.gif"). It can only be used for attachments of type Attachment.FILE_ATTACHMENT. In any other cases it will throw an AttachmentException.

Parameters:
newFilePath - the new path within the local file system to move the file to
Returns:
true, if the file was moved/renamed successfully, false otherwise
Throws:
AttachmentException - if attachment processing is not supported within the current runtime or obtaining the attachment failed for any reason

isLocal

boolean isLocal()
Returns true, if this attachment was created locally. This is synonymous to the sender/originator of this attachment instance residing within the same Java virtual machine as its receiver.

This method is especially important for attachments of type Attachment.FILE_ATTACHMENT, as - if it returns true - this denotes that the file the attachment points to is the original one. That is, when attempting to move(String) a file attachment, this allows to distinguish whether the original file would be moved to a new location or whether simply the attachment file will be moved out of the local attachment store (used for caching incoming attachments) to a place outside of it.

Returns:
true only if this attachment was originally created locally (within the same JVM)