org.apache.axiom.attachments.utils
Class BAAOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.apache.axiom.attachments.utils.BAAOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class BAAOutputStream
extends java.io.OutputStream

BAAOutputStream is like a ByteArrayOutputStream. A ByteArrayOutputStream stores the backing data in a byte[]. BAAOutputStream stores the backing data in a Array of 4K byte[]. Using several non-contiguous chunks reduces memory copy and resizing.


Field Summary
(package private)  int BUFFER_SIZE
           
(package private)  byte[] currBuffer
           
(package private)  java.util.ArrayList data
           
(package private)  int index
           
(package private)  byte[] writeByte
           
 
Constructor Summary
BAAOutputStream()
           
 
Method Summary
private  void addBuffer()
           
 java.util.ArrayList buffers()
           
 int length()
           
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.OutputStream
close, flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

java.util.ArrayList data

BUFFER_SIZE

int BUFFER_SIZE

index

int index

currBuffer

byte[] currBuffer

writeByte

byte[] writeByte
Constructor Detail

BAAOutputStream

public BAAOutputStream()
Method Detail

addBuffer

private void addBuffer()

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

buffers

public java.util.ArrayList buffers()

length

public int length()