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:edu.umd.cs.psl.ui.data.graph.BinaryRelation.java

@Override
public Entity<ET, RT> get(int pos) {
    switch (pos) {
    case 0://from w w w  .  j  a v a  2s .c  om
        return first;
    case 1:
        return second;
    default:
        throw new ArrayIndexOutOfBoundsException();
    }
}

From source file:org.echocat.jomon.net.cluster.channel.Message.java

public Message(byte command, @Nonnull byte[] data, @Nonnegative int offset, @Nonnegative int length) {
    if (offset < 0 || length < offset) {
        throw new IllegalArgumentException();
    }/* w  ww . j av a 2 s  .co  m*/
    if (offset + length > data.length) {
        throw new ArrayIndexOutOfBoundsException();
    }
    _command = command;
    _data = data;
    _offset = offset;
    _length = length;
}

From source file:Main.java

public static void checkOffsetAndCount(int arrayLength, int offset, int count) {
    if ((offset | count) < 0 || offset > arrayLength || arrayLength - offset < count) {
        throw new ArrayIndexOutOfBoundsException();
    }//from  w  w w  .j av  a2s .  c  o m
}

From source file:Bag.java

/**
 * Retrieves and removes an element/*from w  ww  .ja va 2  s  . com*/
 * 
 * @param index
 * @return The indexed element
 */
public T take(int index) {
    if (index >= size) {
        throw new ArrayIndexOutOfBoundsException();
    }

    T took = data[index];
    data[index] = data[--size];
    data[size] = null;
    return took;
}

From source file:com.cloudera.crunch.Tuple4.java

public Object get(int index) {
    switch (index) {
    case 0:/*from  w  w w  . ja  v a2s.  c om*/
        return first;
    case 1:
        return second;
    case 2:
        return third;
    case 3:
        return fourth;
    default:
        throw new ArrayIndexOutOfBoundsException();
    }
}

From source file:org.accelio.jxio.jxioConnection.impl.MultiBufOutputStream.java

@Override
public synchronized void write(byte[] b, int off, int len) throws IOException {
    int totalWrite = 0;
    int bytesWrite;

    if (!connectionOpen) {
        throw new IOException("Stream closed.");
    }//from   w  w w .  ja v a2  s.c om
    if (b == null) {
        throw new NullPointerException();
    }
    // bounds check
    if (len < 0 || off < 0 || off + len > b.length) {
        throw new ArrayIndexOutOfBoundsException();
    }
    if (outBuf == null) {
        outBuf = supplier.getNextBuffer();
    }
    while (totalWrite < len) {
        // bring new buffer if full
        if (!outBuf.hasRemaining()) {
            outBuf = supplier.getNextBuffer();
        }
        bytesWrite = Math.min(len - totalWrite, outBuf.remaining());
        outBuf.put(b, off, bytesWrite);
        totalWrite += bytesWrite;
        off += bytesWrite;
    }
}

From source file:gda.data.scan.datawriter.scannablewriter.SingleScannableWriter.java

protected static int indexForComponentName(final Scannable s, final String component) {
    // FIXME : ArrayUtils.addAll(s.getInputNames(), s.getExtraNames()) should yield same result
    final String[] all = (String[]) ArrayUtils.addAll(
            (s.getInputNames() != null) ? s.getInputNames() : new String[] {},
            (s.getExtraNames() != null) ? s.getExtraNames() : new String[] {});

    if (all != null) {
        for (int i = 0; i < all.length; i++) {
            if (component.equals(all[i])) {
                return i;
            }/*from w ww.j a  v  a  2s .c  o  m*/
        }
    }

    throw new ArrayIndexOutOfBoundsException();
}

From source file:de.estudent.nfc.NFCHelper.java

public static byte[] subByteArray(byte[] array, int offset, int length) {
    if (array == null)
        throw new NullPointerException();
    if (length < 0 || offset < 0)
        throw new ArrayIndexOutOfBoundsException();
    byte[] result = new byte[length];
    System.arraycopy(array, offset, result, 0, length);
    return result;
}

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

@Override
public synchronized void setInput(byte[] b, int off, int len) {
    if (b == null) {
        throw new NullPointerException();
    }//from  ww  w  . java  2 s  .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 bzip2's output direct buffer.
    uncompressedDirectBuf.limit(directBufferSize);
    uncompressedDirectBuf.position(directBufferSize);
}

From source file:com.alibaba.napoli.gecko.core.nio.impl.SelectorManager.java

/**
 * //from w ww.  j a v a2  s. c  om
 * 
 * @param index
 * @return
 */
Reactor getReactorByIndex(final int index) {
    if (index < 0 || index > this.reactorSet.length - 1) {
        throw new ArrayIndexOutOfBoundsException();
    }
    return this.reactorSet[index];
}