FileDocCategorySizeDatePackage
EncodedByteArray.javaAPI DocApache Axis 1.43147Sat Apr 22 18:57:28 BST 2006org.apache.axis.components.encoding

EncodedByteArray

public class EncodedByteArray extends Object
Simple byte array with variable array length, used within the XMLEncoder. It is used as a ByteArrayOutputStream replacement to limit the size of created temporary objects
author
Jens Schumann

Fields Summary
private byte[]
array
private int
pointer
private final double
PADDING
Constructors Summary
public EncodedByteArray(byte[] bytes, int startPos, int length)


           
        // string length will be at least the size of the byte array
        array = new byte[(int) (bytes.length * PADDING)];
        System.arraycopy(bytes, startPos, array, 0, length);
        pointer = length;
    
public EncodedByteArray(int size)

        array = new byte[size];
    
Methods Summary
public voidappend(int aByte)

        if (pointer + 1 >= array.length) {
            byte[] newArray = new byte[(int) (array.length * PADDING)];
            System.arraycopy(array, 0, newArray, 0, pointer);
            array = newArray;
        }
        array[pointer] = (byte) aByte;
        pointer++;
    
public voidappend(byte[] byteArray)

        if (pointer + byteArray.length >= array.length) {
            byte[] newArray = new byte[((int)(array.length * PADDING)) + byteArray.length];
            System.arraycopy(array, 0, newArray, 0, pointer);
            array = newArray;
        }

        System.arraycopy(byteArray, 0, array, pointer, byteArray.length);
        pointer += byteArray.length;
    
public voidappend(byte[] byteArray, int pos, int length)

        if (pointer + length >= array.length) {
            byte[] newArray = new byte[((int) (array.length * PADDING)) + byteArray.length];
            System.arraycopy(array, 0, newArray, 0, pointer);
            array = newArray;
        }
        System.arraycopy(byteArray, pos, array, pointer, length);
        pointer += length;
    
public java.lang.StringtoString()
convert to a string using the platform's default charset

return
string

        return new String(array, 0, pointer);
    
public java.lang.StringtoString(java.lang.String charsetName)
convert the encoded byte array to a string according to the given charset

param
charsetName
return
string
throws
UnsupportedEncodingException

        return new String(array, 0, pointer, charsetName);