org.apache.axiom.attachments.impl
Class BufferUtils

java.lang.Object
  extended by org.apache.axiom.attachments.impl.BufferUtils

public class BufferUtils
extends java.lang.Object

Attachment processing uses a lot of buffers. The BufferUtils class attempts to reuse buffers to prevent excessive GarbageCollection


Constructor Summary
BufferUtils()
           
 
Method Summary
static int doesDataHandlerExceedLimit(javax.activation.DataHandler dh, int limit)
          The method checks to see if attachment is eligble for optimization.
static boolean inputStream2FileOutputStream(java.io.InputStream is, java.io.FileOutputStream fos)
          Opimized writing to FileOutputStream using a channel
static void inputStream2OutputStream(java.io.InputStream is, java.io.OutputStream os)
          Private utility to write the InputStream contents to the OutputStream.
static int inputStream2OutputStream(java.io.InputStream is, java.io.OutputStream os, int limit)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferUtils

public BufferUtils()
Method Detail

inputStream2OutputStream

public static void inputStream2OutputStream(java.io.InputStream is,
                                            java.io.OutputStream os)
                                     throws java.io.IOException
Private utility to write the InputStream contents to the OutputStream.

Parameters:
is -
os -
Throws:
java.io.IOException

inputStream2OutputStream

public static int inputStream2OutputStream(java.io.InputStream is,
                                           java.io.OutputStream os,
                                           int limit)
                                    throws java.io.IOException
Parameters:
is - InputStream
os - OutputStream
limit - maximum number of bytes to read
Returns:
total ytes read
Throws:
java.io.IOException

inputStream2FileOutputStream

public static boolean inputStream2FileOutputStream(java.io.InputStream is,
                                                   java.io.FileOutputStream fos)
                                            throws java.io.IOException
Opimized writing to FileOutputStream using a channel

Parameters:
is -
fos -
Returns:
false if lock was not aquired
Throws:
java.io.IOException

doesDataHandlerExceedLimit

public static int doesDataHandlerExceedLimit(javax.activation.DataHandler dh,
                                             int limit)
The method checks to see if attachment is eligble for optimization. An attachment is eligible for optimization if and only if the size of the attachment is greated then the optimzation threshold size limit. if the Content represented by DataHandler has size less than the optimize threshold size, the attachment will not be eligible for optimization, instead it will be inlined. returns 1 if DataHandler data is bigger than limit. returns 0 if DataHandler data is smaller. return -1 if an error occurs or unsupported.

Parameters:
in -
Returns:
Throws:
java.io.IOException


Copyright © 2004-2008 Apache Software Foundation. All Rights Reserved.