org.apache.axiom.attachments.impl
Class PartOnMemory

java.lang.Object
  extended by org.apache.axiom.attachments.impl.AbstractPart
      extended by org.apache.axiom.attachments.impl.PartOnMemory
All Implemented Interfaces:
Part

public class PartOnMemory
extends AbstractPart

PartOnMemory stores the attachment in memory (in a byte[]) This implementation is used for smaller attachments to enhance performance. The PartOnMemory object is created by the PartFactory

See Also:
org.apache.axiom.attachments.impl.PartFactory.

Nested Class Summary
(package private)  class PartOnMemory.MyByteArrayDataSource
          A DataSource that is backed by the byte[] and headers map.
 
Field Summary
(package private)  byte[] bytes
           
(package private)  int length
           
private static org.apache.commons.logging.Log log
           
 
Constructor Summary
PartOnMemory(java.util.Hashtable headers, byte[] bytes, int length)
          Construct a PartOnMemory
 
Method Summary
 javax.activation.DataHandler getDataHandler()
           
 java.lang.String getFileName()
          The part may be backed by a file.
 java.io.InputStream getInputStream()
           
 long getSize()
           
 
Methods inherited from class org.apache.axiom.attachments.impl.AbstractPart
addHeader, getAllHeaders, getContentID, getContentTransferEncoding, getContentType, getHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

bytes

byte[] bytes

length

int length
Constructor Detail

PartOnMemory

PartOnMemory(java.util.Hashtable headers,
             byte[] bytes,
             int length)
Construct a PartOnMemory

Parameters:
headers -
bytes -
length - (length of data in bytes)
Method Detail

getDataHandler

public javax.activation.DataHandler getDataHandler()
                                            throws javax.mail.MessagingException
Specified by:
getDataHandler in interface Part
Specified by:
getDataHandler in class AbstractPart
Returns:
DataHandler representing this part
Throws:
javax.mail.MessagingException

getFileName

public java.lang.String getFileName()
                             throws javax.mail.MessagingException
Description copied from interface: Part
The part may be backed by a file. If that is the case, this method returns the file name.

Specified by:
getFileName in interface Part
Specified by:
getFileName in class AbstractPart
Returns:
Throws:
javax.mail.MessagingException

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException,
                                          javax.mail.MessagingException
Specified by:
getInputStream in interface Part
Specified by:
getInputStream in class AbstractPart
Returns:
Get the part data as an input stream
Throws:
java.io.IOException
javax.mail.MessagingException

getSize

public long getSize()
             throws javax.mail.MessagingException
Specified by:
getSize in interface Part
Specified by:
getSize in class AbstractPart
Returns:
size
Throws:
javax.mail.MessagingException