org.jboss.soa.esb.actions.soap.attachment
Class AttachmentPartImpl

java.lang.Object
  extended by javax.xml.soap.AttachmentPart
      extended by org.jboss.soa.esb.actions.soap.attachment.AttachmentPartImpl

public class AttachmentPartImpl
extends javax.xml.soap.AttachmentPart

Implementation of the AttachmentPart interface.

Author:
Jason T. Greene, Thomas.Diesler@jboss.org
See Also:
AttachmentPart

Constructor Summary
AttachmentPartImpl()
           
AttachmentPartImpl(javax.activation.DataHandler handler)
           
 
Method Summary
 void addMimeHeader(java.lang.String name, java.lang.String value)
           
 void clearContent()
           
 java.util.Iterator getAllMimeHeaders()
           
 java.io.InputStream getBase64Content()
          Returns an InputStream which can be used to obtain the content of AttachmentPart as Base64 encoded character data, this method would base64 encode the raw bytes of the attachment and return.
 java.lang.Object getContent()
           
 java.lang.String getContentId()
           
 java.lang.String getContentLocation()
           
 java.lang.String getContentType()
           
 javax.activation.DataHandler getDataHandler()
           
 java.lang.String getFirstMimeHeader(java.lang.String header)
          Returns the first occurence of a MIME header.
 java.util.Iterator getMatchingMimeHeaders(java.lang.String[] names)
           
 java.lang.String[] getMimeHeader(java.lang.String name)
           
 java.util.Iterator getNonMatchingMimeHeaders(java.lang.String[] names)
           
 java.io.InputStream getRawContent()
          Gets the content of this AttachmentPart object as an InputStream as if a call had been made to getContent and no DataContentHandler had been registered for the content-type of this AttachmentPart.
 byte[] getRawContentBytes()
          Gets the content of this AttachmentPart object as a byte[] array as if a call had been made to getContent and no DataContentHandler had been registered for the content-type of this AttachmentPart.
 int getSize()
           
 void removeAllMimeHeaders()
           
 void removeMimeHeader(java.lang.String name)
           
 void setBase64Content(java.io.InputStream content, java.lang.String contentType)
          Sets the content of this attachment part from the Base64 source InputStream and sets the value of the Content-Type header to the value contained in contentType, This method would first decode the base64 input and write the resulting raw bytes to the attachment.
 void setContent(java.lang.Object object, java.lang.String contentType)
          Sets the content of this attachment part to that of the given Object and sets the value of the Content-Type header to the given type.
 void setContentId(java.lang.String contentId)
           
 void setContentLocation(java.lang.String contentLocation)
           
 void setContentType(java.lang.String contentType)
           
 void setDataHandler(javax.activation.DataHandler dataHandler)
           
 void setMimeHeader(java.lang.String name, java.lang.String value)
           
 void setRawContent(java.io.InputStream content, java.lang.String contentType)
          Sets the content of this attachment part to that contained by the InputStream content and sets the value of the Content-Type header to the value contained in contentType.
 void setRawContentBytes(byte[] content, int offset, int len, java.lang.String contentType)
          Sets the content of this attachment part to that contained by the byte[] array content and sets the value of the Content-Type header to the value contained in contentType.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttachmentPartImpl

public AttachmentPartImpl()

AttachmentPartImpl

public AttachmentPartImpl(javax.activation.DataHandler handler)
Method Detail

addMimeHeader

public void addMimeHeader(java.lang.String name,
                          java.lang.String value)
Specified by:
addMimeHeader in class javax.xml.soap.AttachmentPart

clearContent

public void clearContent()
Specified by:
clearContent in class javax.xml.soap.AttachmentPart

getAllMimeHeaders

public java.util.Iterator getAllMimeHeaders()
Specified by:
getAllMimeHeaders in class javax.xml.soap.AttachmentPart

getContent

public java.lang.Object getContent()
                            throws javax.xml.soap.SOAPException
Specified by:
getContent in class javax.xml.soap.AttachmentPart
Throws:
javax.xml.soap.SOAPException

getDataHandler

public javax.activation.DataHandler getDataHandler()
                                            throws javax.xml.soap.SOAPException
Specified by:
getDataHandler in class javax.xml.soap.AttachmentPart
Throws:
javax.xml.soap.SOAPException

getMatchingMimeHeaders

public java.util.Iterator getMatchingMimeHeaders(java.lang.String[] names)
Specified by:
getMatchingMimeHeaders in class javax.xml.soap.AttachmentPart

getMimeHeader

public java.lang.String[] getMimeHeader(java.lang.String name)
Specified by:
getMimeHeader in class javax.xml.soap.AttachmentPart

getFirstMimeHeader

public java.lang.String getFirstMimeHeader(java.lang.String header)
Returns the first occurence of a MIME header.

Parameters:
header - the mime header
Returns:
the value of the first occurence of a MIME header

getNonMatchingMimeHeaders

public java.util.Iterator getNonMatchingMimeHeaders(java.lang.String[] names)
Specified by:
getNonMatchingMimeHeaders in class javax.xml.soap.AttachmentPart

getSize

public int getSize()
            throws javax.xml.soap.SOAPException
Specified by:
getSize in class javax.xml.soap.AttachmentPart
Throws:
javax.xml.soap.SOAPException

removeAllMimeHeaders

public void removeAllMimeHeaders()
Specified by:
removeAllMimeHeaders in class javax.xml.soap.AttachmentPart

removeMimeHeader

public void removeMimeHeader(java.lang.String name)
Specified by:
removeMimeHeader in class javax.xml.soap.AttachmentPart

setContent

public void setContent(java.lang.Object object,
                       java.lang.String contentType)
Sets the content of this attachment part to that of the given Object and sets the value of the Content-Type header to the given type. The type of the Object should correspond to the value given for the Content-Type. This depends on the particular set of DataContentHandler objects in use.

Specified by:
setContent in class javax.xml.soap.AttachmentPart
Parameters:
object - the Java object that makes up the content for this attachment part
contentType - the MIME string that specifies the type of the content
Throws:
java.lang.IllegalArgumentException - if the contentType does not match the type of the content object, or if there was no DataContentHandler object for this content object

setDataHandler

public void setDataHandler(javax.activation.DataHandler dataHandler)
Specified by:
setDataHandler in class javax.xml.soap.AttachmentPart

setMimeHeader

public void setMimeHeader(java.lang.String name,
                          java.lang.String value)
Specified by:
setMimeHeader in class javax.xml.soap.AttachmentPart

getContentId

public java.lang.String getContentId()
Overrides:
getContentId in class javax.xml.soap.AttachmentPart

getContentLocation

public java.lang.String getContentLocation()
Overrides:
getContentLocation in class javax.xml.soap.AttachmentPart

getContentType

public java.lang.String getContentType()
Overrides:
getContentType in class javax.xml.soap.AttachmentPart

setContentId

public void setContentId(java.lang.String contentId)
Overrides:
setContentId in class javax.xml.soap.AttachmentPart

setContentLocation

public void setContentLocation(java.lang.String contentLocation)
Overrides:
setContentLocation in class javax.xml.soap.AttachmentPart

setContentType

public void setContentType(java.lang.String contentType)
Overrides:
setContentType in class javax.xml.soap.AttachmentPart

getBase64Content

public java.io.InputStream getBase64Content()
                                     throws javax.xml.soap.SOAPException
Returns an InputStream which can be used to obtain the content of AttachmentPart as Base64 encoded character data, this method would base64 encode the raw bytes of the attachment and return.

Specified by:
getBase64Content in class javax.xml.soap.AttachmentPart
Returns:
an InputStream from which the Base64 encoded AttachmentPart can be read.
Throws:
javax.xml.soap.SOAPException - if there is no content set into this AttachmentPart object or if there was a data transformation error.
Since:
SAAJ 1.3

getRawContent

public java.io.InputStream getRawContent()
                                  throws javax.xml.soap.SOAPException
Gets the content of this AttachmentPart object as an InputStream as if a call had been made to getContent and no DataContentHandler had been registered for the content-type of this AttachmentPart. Note that reading from the returned InputStream would result in consuming the data in the stream. It is the responsibility of the caller to reset the InputStream appropriately before calling a Subsequent API. If a copy of the raw attachment content is required then the getRawContentBytes() API should be used instead.

Specified by:
getRawContent in class javax.xml.soap.AttachmentPart
Returns:
an InputStream from which the raw data contained by the AttachmentPart can be accessed.
Throws:
javax.xml.soap.SOAPException - if there is no content set into this AttachmentPart object or if there was a data transformation error.
Since:
SAAJ 1.3

getRawContentBytes

public byte[] getRawContentBytes()
                          throws javax.xml.soap.SOAPException
Gets the content of this AttachmentPart object as a byte[] array as if a call had been made to getContent and no DataContentHandler had been registered for the content-type of this AttachmentPart.

Specified by:
getRawContentBytes in class javax.xml.soap.AttachmentPart
Returns:
a byte[] array containing the raw data of the AttachmentPart.
Throws:
javax.xml.soap.SOAPException - if there is no content set into this AttachmentPart object or if there was a data transformation error.
Since:
SAAJ 1.3

setBase64Content

public void setBase64Content(java.io.InputStream content,
                             java.lang.String contentType)
                      throws javax.xml.soap.SOAPException
Sets the content of this attachment part from the Base64 source InputStream and sets the value of the Content-Type header to the value contained in contentType, This method would first decode the base64 input and write the resulting raw bytes to the attachment. A subsequent call to getSize() may not be an exact measure of the content size.

Specified by:
setBase64Content in class javax.xml.soap.AttachmentPart
Parameters:
content - the base64 encoded data to add to the attachment part
contentType - the value to set into the Content-Type header
Throws:
javax.xml.soap.SOAPException - if an there is an error in setting the content
java.lang.NullPointerException - if content is null
Since:
SAAJ 1.3

setRawContent

public void setRawContent(java.io.InputStream content,
                          java.lang.String contentType)
                   throws javax.xml.soap.SOAPException
Sets the content of this attachment part to that contained by the InputStream content and sets the value of the Content-Type header to the value contained in contentType. A subsequent call to getSize() may not be an exact measure of the content size.

Specified by:
setRawContent in class javax.xml.soap.AttachmentPart
Parameters:
content - the raw data to add to the attachment part
contentType - the value to set into the Content-Type header
Throws:
javax.xml.soap.SOAPException - if an there is an error in setting the content
java.lang.NullPointerException - if content is null
Since:
SAAJ 1.3

setRawContentBytes

public void setRawContentBytes(byte[] content,
                               int offset,
                               int len,
                               java.lang.String contentType)
                        throws javax.xml.soap.SOAPException
Sets the content of this attachment part to that contained by the byte[] array content and sets the value of the Content-Type header to the value contained in contentType.

Specified by:
setRawContentBytes in class javax.xml.soap.AttachmentPart
Parameters:
content - the raw data to add to the attachment part
contentType - the value to set into the Content-Type header
offset - the offset in the byte array of the content
len - the number of bytes that form the content
Throws:
javax.xml.soap.SOAPException - if an there is an error in setting the content or content is null
Since:
SAAJ 1.3