List of usage examples for java.lang ArrayIndexOutOfBoundsException ArrayIndexOutOfBoundsException
public ArrayIndexOutOfBoundsException(int index)
From source file:org.cloudfoundry.identity.uaa.scim.JdbcPagingList.java
@Override public E get(int index) { if (index >= size) { throw new ArrayIndexOutOfBoundsException(index); }//from w w w. j av a 2 s . co m if (current == null || index - start >= pageSize || index < start) { current = parameterJdbcTemplate.query(getLimitSql(sql, index, pageSize), args, mapper); start = index; } return current.get(index - start); }
From source file:IntList.java
/** * Adds a value to this list at the given index * /*from www . ja v a 2 s .c om*/ * @param index * The index to add the value at * @param value * The value to add to the list */ public void add(int index, int value) { if (index < 0 || index > theSize) throw new ArrayIndexOutOfBoundsException(index); ensureCapacity(theSize + 1); for (int i = theSize; i > index; i--) theValue[i] = theValue[i - 1]; theValue[index] = value; theSize++; }
From source file:LongList.java
/** * Adds a value to this list at the given index * // w w w .ja v a 2s.com * @param index * The index to add the value at * @param value * The value to add to the list */ public void add(int index, long value) { if (index < 0 || index > theSize) throw new ArrayIndexOutOfBoundsException(index); ensureCapacity(theSize + 1); for (int i = theSize; i > index; i--) theValue[i] = theValue[i - 1]; theValue[index] = value; theSize++; }
From source file:IntList.java
public int get(int index) { if (index >= numElements) { throw new ArrayIndexOutOfBoundsException(index); }// w w w . ja v a 2 s . co m return data[index]; }
From source file:org.apache.poi.util.StringUtil.java
/** * Given a byte array of 16-bit unicode characters in Little Endian * format (most important byte last), return a Java String representation * of it.//from ww w .j a v a2 s.c om * * { 0x16, 0x00 } -0x16 * * @param string the byte array to be converted * @param offset the initial offset into the * byte array. it is assumed that string[ offset ] and string[ offset + * 1 ] contain the first 16-bit unicode character * @param len the length of the final string * @return the converted string, never <code>null</code>. * @exception ArrayIndexOutOfBoundsException if offset is out of bounds for * the byte array (i.e., is negative or is greater than or equal to * string.length) * @exception IllegalArgumentException if len is too large (i.e., * there is not enough data in string to create a String of that * length) */ public static String getFromUnicodeLE(final byte[] string, final int offset, final int len) throws ArrayIndexOutOfBoundsException, IllegalArgumentException { if ((offset < 0) || (offset >= string.length)) { throw new ArrayIndexOutOfBoundsException( "Illegal offset " + offset + " (String data is of length " + string.length + ")"); } if ((len < 0) || (((string.length - offset) / 2) < len)) { throw new IllegalArgumentException("Illegal length " + len); } return new String(string, offset, len * 2, UTF16LE); }
From source file:FloatList.java
public float get(int index) { if (index >= numElements) { throw new ArrayIndexOutOfBoundsException(index); }/* www.j ava2s.c om*/ return data[index]; }
From source file:org.quantumbadger.redreader.jsonwrap.JsonBufferedArray.java
/** * This method will block until either: the array item is received, the * array fails to parse, or the array is fully received and the index * parameter is too large.//from ww w . jav a 2 s .c o m * * @param id * The index into the array * @return The value at position id in the array * @throws InterruptedException * @throws java.io.IOException * @throws ArrayIndexOutOfBoundsException */ public JsonValue get(final int id) throws InterruptedException, IOException { if (id < 0) throw new ArrayIndexOutOfBoundsException(id); synchronized (this) { while (getStatus() == STATUS_LOADING && items <= id) { wait(); } if (getStatus() != STATUS_FAILED || items > id) { return contents.get(id); } if (getStatus() == STATUS_FAILED) { throwFailReasonException(); } throw new ArrayIndexOutOfBoundsException(id); } }
From source file:com.ryan.ryanreader.jsonwrap.JsonBufferedArray.java
/** * This method will block until either: the array item is received, the * array fails to parse, or the array is fully received and the index * parameter is too large./*from w w w.j a v a2s. co m*/ * * @param id * The index into the array * @return The value at position id in the array * @throws InterruptedException * @throws java.io.IOException * @throws ArrayIndexOutOfBoundsException */ public JsonValue get(final int id) throws InterruptedException, IOException { if (id < 0) throw new ArrayIndexOutOfBoundsException(id); synchronized (this) { while (getStatus() == Status.LOADING && items <= id) { wait(); } if (getStatus() != Status.FAILED || items > id) { return contents.get(id); } if (getStatus() == Status.FAILED) { throwFailReasonException(); } throw new ArrayIndexOutOfBoundsException(id); } }
From source file:ArrayIterator.java
/** * Checks whether the index is valid or not. * //from w w w . j av a 2 s . co m * @param bound the index to check * @param type the index type (for error messages) * @throws IndexOutOfBoundsException if the index is invalid */ protected void checkBound(final int bound, final String type) { if (bound > this.endIndex) { throw new ArrayIndexOutOfBoundsException( "Attempt to make an ArrayIterator that " + type + "s beyond the end of the array. "); } if (bound < 0) { throw new ArrayIndexOutOfBoundsException( "Attempt to make an ArrayIterator that " + type + "s before the start of the array. "); } }
From source file:IntList.java
public void put(int index, int val) { if (index >= numElements) { throw new ArrayIndexOutOfBoundsException(index); }//www . j av a 2s.co m data[index] = val; }