FileDocCategorySizeDatePackage
ShortArrayCodeOutput.javaAPI DocAndroid 5.1 API3579Thu Mar 12 22:18:30 GMT 2015com.android.dx.io.instructions

ShortArrayCodeOutput

public final class ShortArrayCodeOutput extends BaseCodeCursor implements CodeOutput
Implementation of {@code CodeOutput} that writes to a {@code short[]}.

Fields Summary
private final short[]
array
array to write to
Constructors Summary
public ShortArrayCodeOutput(int maxSize)
Constructs an instance.

param
maxSize the maximum number of code units that will be written

        if (maxSize < 0) {
            throw new IllegalArgumentException("maxSize < 0");
        }

        this.array = new short[maxSize];
    
Methods Summary
public short[]getArray()
Gets the array. The returned array contains exactly the data written (e.g. no leftover space at the end).

        int cursor = cursor();

        if (cursor == array.length) {
            return array;
        }

        short[] result = new short[cursor];
        System.arraycopy(array, 0, result, 0, cursor);
        return result;
    
public voidwrite(byte[] data)

inheritDoc

        int value = 0;
        boolean even = true;
        for (byte b : data) {
            if (even) {
                value = b & 0xff;
                even = false;
            } else {
                value |= b << 8;
                write((short) value);
                even = true;
            }
        }

        if (!even) {
            write((short) value);
        }
    
public voidwrite(short[] data)

inheritDoc

        for (short unit : data) {
            write(unit);
        }
    
public voidwrite(int[] data)

inheritDoc

        for (int i : data) {
            writeInt(i);
        }
    
public voidwrite(long[] data)

inheritDoc

        for (long l : data) {
            writeLong(l);
        }
    
public voidwrite(short codeUnit)

inheritDoc

        array[cursor()] = codeUnit;
        advance(1);
    
public voidwrite(short u0, short u1)

inheritDoc

        write(u0);
        write(u1);
    
public voidwrite(short u0, short u1, short u2)

inheritDoc

        write(u0);
        write(u1);
        write(u2);
    
public voidwrite(short u0, short u1, short u2, short u3)

inheritDoc

        write(u0);
        write(u1);
        write(u2);
        write(u3);
    
public voidwrite(short u0, short u1, short u2, short u3, short u4)

inheritDoc

        write(u0);
        write(u1);
        write(u2);
        write(u3);
        write(u4);
    
public voidwriteInt(int value)

inheritDoc

        write((short) value);
        write((short) (value >> 16));
    
public voidwriteLong(long value)

inheritDoc

        write((short) value);
        write((short) (value >> 16));
        write((short) (value >> 32));
        write((short) (value >> 48));