org.apache.axiom.attachments.impl

## Class BufferUtils

- java.lang.Object
- - org.apache.axiom.attachments.impl.BufferUtils

-     public class BufferUtils
      extends Object

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

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `BUFFER_LEN`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BufferUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `doesDataHandlerExceedLimit(javax.activation.DataHandler dh, int limit)` The method checks to see if attachment is eligble for optimization.
    `static long` | `inputStream2BAAOutputStream(InputStream is, BAAOutputStream baaos, long limit)` inputStream2BAAOutputStream
    `static boolean` | `inputStream2FileOutputStream(InputStream is, FileOutputStream fos)` Opimized writing to FileOutputStream using a channel
    `static void` | `inputStream2OutputStream(InputStream is, OutputStream os)` Private utility to write the InputStream contents to the OutputStream.
    `static int` | `inputStream2OutputStream(InputStream is, OutputStream os, int limit)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BUFFER_LEN

          public static final int BUFFER_LEN

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### BufferUtils

          public BufferUtils()

  - ### Method Detail

    - #### inputStream2OutputStream

          public static void inputStream2OutputStream(InputStream is,
                                                      OutputStream os)
                                               throws IOException

      Private utility to write the InputStream contents to the OutputStream.
      Parameters:
        `is` -
        `os` -
      Throws:
        `IOException`

    - #### inputStream2OutputStream

          public static int inputStream2OutputStream(InputStream is,
                                                     OutputStream os,
                                                     int limit)
                                              throws IOException

      Parameters:
        `is` - InputStream
        `os` - OutputStream
        `limit` - maximum number of bytes to read
      Returns:
        total bytes read
      Throws:
        `IOException`

    - #### inputStream2FileOutputStream

          public static boolean inputStream2FileOutputStream(InputStream is,
                                                             FileOutputStream fos)
                                                      throws IOException

      Opimized writing to FileOutputStream using a channel
      Parameters:
        `is` -
        `fos` -
      Returns:
        false if lock was not aquired
      Throws:
        `IOException`

    - #### inputStream2BAAOutputStream

          public static long inputStream2BAAOutputStream(InputStream is,
                                                         BAAOutputStream baaos,
                                                         long limit)
                                                  throws IOException

      inputStream2BAAOutputStream
      Parameters:
        `is` -
        `baaos` -
        `limit` -
      Returns:
        the number of bytes copied
      Throws:
        `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.
      Parameters:
        `dh` -
        `limit` -
      Returns:
        1 if DataHandler data is bigger than limit, 0 if DataHandler data is smaller or -1 if an error occurs or unsupported.

Copyright © The Apache Software Foundation. All Rights Reserved.