Example usage for java.lang ArrayIndexOutOfBoundsException ArrayIndexOutOfBoundsException

List of usage examples for java.lang ArrayIndexOutOfBoundsException ArrayIndexOutOfBoundsException

Introduction

In this page you can find the example usage for java.lang ArrayIndexOutOfBoundsException ArrayIndexOutOfBoundsException.

Prototype

public ArrayIndexOutOfBoundsException() 

Source Link

Document

Constructs an ArrayIndexOutOfBoundsException with no detail message.

Usage

From source file:org.apache.hadoop.io.compress.lz4.Lz4Compressor.java

/**
 * Sets input data for compression./*  w  ww.j a v a2 s .c o m*/
 * This should be called whenever #needsInput() returns
 * <code>true</code> indicating that more input data is required.
 *
 * @param b   Input data
 * @param off Start offset
 * @param len Length
 */
@Override
public synchronized void setInput(byte[] b, int off, int len) {
    if (b == null) {
        throw new NullPointerException();
    }
    if (off < 0 || len < 0 || off > b.length - len) {
        throw new ArrayIndexOutOfBoundsException();
    }
    finished = false;

    if (len > uncompressedDirectBuf.remaining()) {
        // save data; now !needsInput
        this.userBuf = b;
        this.userBufOff = off;
        this.userBufLen = len;
    } else {
        ((ByteBuffer) uncompressedDirectBuf).put(b, off, len);
        uncompressedDirectBufLen = uncompressedDirectBuf.position();
    }

    bytesRead += len;
}

From source file:takatuka.classreader.dataObjs.ControllerBase.java

public void add(Object obj) throws Exception {
    if (objs.size() >= size && size != -1) { //-1 is infinity
        throw new ArrayIndexOutOfBoundsException();
    }//from  w  w  w .  j a  v a 2  s  .c  om
    if (allowedType(obj)) {
        throw new Exception("Invalid Class exception ");
    }
    validate(); //overwrite validate function to add other validations.

    objs.addElement(obj);
}

From source file:org.apache.hadoop.io.compress.lzma.LzmaCompressor.java

public synchronized void setInput(byte[] b, int off, int len) {
    if (b == null) {
        throw new NullPointerException();
    }/*  ww  w  .  j  av  a  2s. c  om*/
    if (off < 0 || len < 0 || off > b.length - len) {
        throw new ArrayIndexOutOfBoundsException();
    }

    this.userBuf = b;
    this.userBufOff = off;
    this.userBufLen = len;
    setInputFromSavedData();

    // Reinitialize lzma's output direct buffer 
    compressedDirectBuf.limit(directBufferSize);
    compressedDirectBuf.position(directBufferSize);
}

From source file:MD4.java

/**
 * MD4 block update operation./*from ww  w . ja va  2 s. co  m*/
 * <p>
 * Continues an MD4 message digest operation, by filling the buffer,
 * transform(ing) data in 512-bit message block(s), updating the variables
 * context and count, and leaving (buffering) the remaining bytes in buffer
 * for the next update or finish.
 *
 * @param    input    input block
 * @param    offset    start of meaningful bytes in input
 * @param    len        count of bytes in input block to consider
 */
public void engineUpdate(byte[] input, int offset, int len) {
    // make sure we don't exceed input's allocated size/length
    if (offset < 0 || len < 0 || (long) offset + len > input.length)
        throw new ArrayIndexOutOfBoundsException();

    // compute number of bytes still unhashed; ie. present in buffer
    int bufferNdx = (int) (count % BLOCK_LENGTH);
    count += len; // update number of bytes
    int partLen = BLOCK_LENGTH - bufferNdx;
    int i = 0;
    if (len >= partLen) {
        System.arraycopy(input, offset, buffer, bufferNdx, partLen);

        transform(buffer, 0);

        for (i = partLen; i + BLOCK_LENGTH - 1 < len; i += BLOCK_LENGTH)
            transform(input, offset + i);
        bufferNdx = 0;
    }
    // buffer remaining input
    if (i < len)
        System.arraycopy(input, offset + i, buffer, bufferNdx, len - i);
}

From source file:com.hadoop.compression.fourmc.Lz4Decompressor.java

public synchronized void setInput(byte[] b, int off, int len) {
    if (b == null) {
        throw new NullPointerException();
    }/*from   www  .  j  av  a  2s. c  om*/
    if (off < 0 || len < 0 || off > b.length - len) {
        throw new ArrayIndexOutOfBoundsException();
    }

    this.userBuf = b;
    this.userBufOff = off;
    this.userBufLen = len;

    setInputFromSavedData();

    // Reinitialize LZ4 output direct-buffer
    uncompressedDirectBuf.limit(directBufferSize);
    uncompressedDirectBuf.position(directBufferSize);
}

From source file:com.hadoop.compression.fourmc.ZstdDecompressor.java

public synchronized void setInput(byte[] b, int off, int len) {
    if (b == null) {
        throw new NullPointerException();
    }//from w  ww.  j  a v  a2s.co m
    if (off < 0 || len < 0 || off > b.length - len) {
        throw new ArrayIndexOutOfBoundsException();
    }

    this.userBuf = b;
    this.userBufOff = off;
    this.userBufLen = len;

    setInputFromSavedData();

    // Reinitialize ZSTD output direct-buffer
    uncompressedDirectBuf.limit(directBufferSize);
    uncompressedDirectBuf.position(directBufferSize);
}

From source file:com.hadoop.compression.fourmc.zstd.ZstdStreamDecompressor.java

public synchronized void setInput(byte[] b, int off, int len) {
    if (b == null) {
        throw new NullPointerException();
    }//from  w ww. j av  a  2s. com
    if (off < 0 || len < 0 || off > b.length - len) {
        throw new ArrayIndexOutOfBoundsException();
    }

    this.userBuf = b;
    this.userBufOff = off;
    this.userBufLen = len;

    setInputFromSavedData();

    // Reinitialize Zstd output direct-buffer
    oBuff.limit(oBuffSize);
    oBuff.position(oBuffSize);
}

From source file:cn.com.loopj.android.http.DataAsyncHttpResponseHandler.java

/**
 * Copies elements from {@code original} into a new array, from indexes start (inclusive) to end
 * (exclusive). The original order of elements is preserved. If {@code end} is greater than
 * {@code original.length}, the result is padded with the value {@code (byte) 0}.
 *
 * @param original the original array/*from   w  w w. j  a  v  a2s  .  co  m*/
 * @param start    the start index, inclusive
 * @param end      the end index, exclusive
 * @return the new array
 * @throws ArrayIndexOutOfBoundsException if {@code start < 0 || start > original.length}
 * @throws IllegalArgumentException       if {@code start > end}
 * @throws NullPointerException           if {@code original == null}
 * @see java.util.Arrays
 * @since 1.6
 */
public static byte[] copyOfRange(byte[] original, int start, int end)
        throws ArrayIndexOutOfBoundsException, IllegalArgumentException, NullPointerException {
    if (start > end) {
        throw new IllegalArgumentException();
    }
    int originalLength = original.length;
    if (start < 0 || start > originalLength) {
        throw new ArrayIndexOutOfBoundsException();
    }
    int resultLength = end - start;
    int copyLength = Math.min(resultLength, originalLength - start);
    byte[] result = new byte[resultLength];
    System.arraycopy(original, start, result, 0, copyLength);
    return result;
}

From source file:com.hadoop.compression.fourmc.zstd.ZstdStreamCompressor.java

public synchronized void setInput(byte[] b, int off, int len) {
    if (b == null) {
        throw new NullPointerException();
    }//  ww w .  j  a  v  a  2s  . c o  m
    if (off < 0 || len < 0 || off > b.length - len) {
        throw new ArrayIndexOutOfBoundsException();
    }
    finished = false;

    this.userBuf = b;
    this.userBufOff = off;
    this.userBufLen = len;
    setInputFromSavedData();
    oBuff.limit(oBuffSize);
    oBuff.position(oBuffSize);
    bytesRead += len;
}

From source file:org.apache.hadoop.io.compress.bzip2.Bzip2Decompressor.java

@Override
public synchronized int decompress(byte[] b, int off, int len) throws IOException {
    if (b == null) {
        throw new NullPointerException();
    }/*from  w w  w  .j  a v  a  2 s . co m*/
    if (off < 0 || len < 0 || off > b.length - len) {
        throw new ArrayIndexOutOfBoundsException();
    }

    // Check if there is uncompressed data.
    int n = uncompressedDirectBuf.remaining();
    if (n > 0) {
        n = Math.min(n, len);
        ((ByteBuffer) uncompressedDirectBuf).get(b, off, n);
        return n;
    }

    // Re-initialize bzip2's output direct buffer.
    uncompressedDirectBuf.rewind();
    uncompressedDirectBuf.limit(directBufferSize);

    // Decompress the data.
    n = finished ? 0 : inflateBytesDirect();
    uncompressedDirectBuf.limit(n);

    // Get at most 'len' bytes.
    n = Math.min(n, len);
    ((ByteBuffer) uncompressedDirectBuf).get(b, off, n);

    return n;
}