org.apache.axis.attachments

Class AttachmentsImpl

public class AttachmentsImpl extends Object implements Attachments

Implements the Attachment interface, via an actual Hashmap of actual AttachmentParts.
Field Summary
protected StringcontentLocation
This is the content location as specified in SOAP with Attachments.
protected static Loglog
protected MultiPartInputStreammpartStream
The actual stream to manage the multi-related input stream.
protected intsendtype
The form of the attachments, whether MIME or DIME.
protected SOAPPartsoapPart
Field soapPart.
Constructor Summary
AttachmentsImpl(Object intialContents, String contentType, String contentLocation)
Construct one of these on a parent Message.
Method Summary
PartaddAttachmentPart(Part newPart)
Adds an existing attachment to this list.
PartcreateAttachmentPart(Object datahandler)
PartcreateAttachmentPart()
Create a new attachment Part in this Message.
protected DimeMultiPartcreateDimeMessage()
Creates the DIME message
voiddispose()
dispose of the attachments and their files; do not use the object after making this call.
PartgetAttachmentByReference(String reference)
This method should look at a refernce and determine if it is a CID: or url to look for attachment.
intgetAttachmentCount()
This is the number of attachments.
CollectiongetAttachments()
This method will return all attachments as a collection.
IteratorgetAttachments(MimeHeaders headers)
Retrieves all the AttachmentPart objects that have header entries that match the specified headers.
longgetContentLength()
Get the content length of the stream.
StringgetContentType()
Gets the content type for the whole stream.
IncomingAttachmentStreamsgetIncomingAttachmentStreams()
Once this method is called, attachments can only be accessed via the InputStreams.
PartgetRootPart()
From the complex stream return the root part.
intgetSendType()
static intgetSendType(String value)
Determine how an object typically sent as attachments are to be represented.
static StringgetSendTypeString(int value)
For a given sendType value, return a string representation.
booleanisAttachment(Object value)
Determine if an object is to be treated as an attchment.
voidremoveAllAttachments()
Removes all AttachmentPart objects that have been added to this SOAPMessage object.
PartremoveAttachmentPart(String reference)
This method uses getAttacmentByReference() to look for attachment.
voidsetAttachmentParts(Collection parts)
Add the collection of parts.
voidsetRootPart(Part newRoot)
voidsetSendType(int sendtype)
voidwriteContentToStream(OutputStream os)
Write the content to the stream.

Field Detail

contentLocation

protected String contentLocation
This is the content location as specified in SOAP with Attachments. This maybe null if the message had no Content-Location specifed.

log

protected static Log log

mpartStream

protected MultiPartInputStream mpartStream
The actual stream to manage the multi-related input stream.

sendtype

protected int sendtype
The form of the attachments, whether MIME or DIME.

soapPart

protected SOAPPart soapPart
Field soapPart.

Constructor Detail

AttachmentsImpl

public AttachmentsImpl(Object intialContents, String contentType, String contentLocation)
Construct one of these on a parent Message. Should only ever be called by Message constructor!

Parameters: intialContents should be anything but today only a stream is supported. contentType The mime content type of the stream for transports that provide it. contentLocation

Throws: org.apache.axis.AxisFault

Method Detail

addAttachmentPart

public Part addAttachmentPart(Part newPart)
Adds an existing attachment to this list. Note: Passed part will be bound to this message.

Parameters: newPart new part to add

Returns: Part old attachment with the same Content-ID, or null.

Throws: org.apache.axis.AxisFault

createAttachmentPart

public Part createAttachmentPart(Object datahandler)

createAttachmentPart

public Part createAttachmentPart()
Create a new attachment Part in this Message. Will actually, and always, return an AttachmentPart.

Returns: a new attachment Part

Throws: org.apache.axis.AxisFault

createDimeMessage

protected DimeMultiPart createDimeMessage()
Creates the DIME message

Returns: a DIME part

Throws: org.apache.axis.AxisFault if the part could not be built

dispose

public void dispose()
dispose of the attachments and their files; do not use the object after making this call.

getAttachmentByReference

public Part getAttachmentByReference(String reference)
This method should look at a refernce and determine if it is a CID: or url to look for attachment.
Note: if Content-Id or Content-Location headers have changed by outside code, lookup will not return proper values. In order to change these values attachment should be removed, then added again.

Parameters: reference The reference in the xml that referers to an attachment.

Returns: The part associated with the attachment.

Throws: org.apache.axis.AxisFault

getAttachmentCount

public int getAttachmentCount()
This is the number of attachments.

Returns: the number of attachments

getAttachments

public Collection getAttachments()
This method will return all attachments as a collection.

Returns: A collection of attachments.

Throws: org.apache.axis.AxisFault

getAttachments

public Iterator getAttachments(MimeHeaders headers)
Retrieves all the AttachmentPart objects that have header entries that match the specified headers. Note that a returned attachment could have headers in addition to those specified.

Parameters: headers a MimeHeaders object containing the MIME headers for which to search

Returns: an iterator over all attachments that have a header that matches one of the given headers

getContentLength

public long getContentLength()
Get the content length of the stream.

Returns: the content length of the stream

Throws: org.apache.axis.AxisFault

getContentType

public String getContentType()
Gets the content type for the whole stream.

Returns: the content type for the whole stream

Throws: org.apache.axis.AxisFault

getIncomingAttachmentStreams

public IncomingAttachmentStreams getIncomingAttachmentStreams()
Once this method is called, attachments can only be accessed via the InputStreams. Any other access to the attachments collection (e.g. via getAttachments()) is prohibited and will cause a IllegalStateException to be thrown.

Returns: All of the attachment streams.

getRootPart

public Part getRootPart()
From the complex stream return the root part. Today this is SOAP.

Returns: the root Part

getSendType

public int getSendType()

getSendType

public static int getSendType(String value)
Determine how an object typically sent as attachments are to be represented. Currently, MIME DIME and NONE are reccognised.

Parameters: value a String representing a sending type, treated in a case-insensetive manner

Returns: an int send type code

getSendTypeString

public static String getSendTypeString(int value)
For a given sendType value, return a string representation.

Parameters: value a type code integer

Returns: a String representation of value

isAttachment

public boolean isAttachment(Object value)
Determine if an object is to be treated as an attchment.

Parameters: value the value that is to be determined if its an attachment.

Returns: True if value should be treated as an attchment.

removeAllAttachments

public void removeAllAttachments()
Removes all AttachmentPart objects that have been added to this SOAPMessage object.

This method does not touch the SOAP part.

removeAttachmentPart

public Part removeAttachmentPart(String reference)
This method uses getAttacmentByReference() to look for attachment. If attachment has been found, it will be removed from the list, and returned to the user.

Parameters: reference The reference that referers to an attachment.

Returns: The part associated with the removed attachment, or null.

Throws: org.apache.axis.AxisFault

setAttachmentParts

public void setAttachmentParts(Collection parts)
Add the collection of parts.

Parameters: parts

Throws: org.apache.axis.AxisFault

setRootPart

public void setRootPart(Part newRoot)

setSendType

public void setSendType(int sendtype)

writeContentToStream

public void writeContentToStream(OutputStream os)
Write the content to the stream.

Parameters: os

Throws: org.apache.axis.AxisFault

Copyright B) 2005 Apache Web Services Project. All Rights Reserved.