List of usage examples for java.lang IndexOutOfBoundsException IndexOutOfBoundsException
public IndexOutOfBoundsException(int index)
From source file:com.google.uzaygezen.core.LongBitVector.java
private void checkBounds(int fromIndex, int toIndex) { if (fromIndex < 0 | toIndex > size | fromIndex > toIndex) { throw new IndexOutOfBoundsException( "Range [" + fromIndex + ", " + toIndex + ") is invalid for this bit vector"); }/*from w w w.ja va 2 s.c om*/ }
From source file:ru.jts_dev.common.packets.IncomingMessageWrapper.java
public final byte[] readBytes(final int length) { if (payload.readableBytes() < length) throw new IndexOutOfBoundsException("At least 4 bytes must be readable in payload"); final byte[] data = new byte[length]; payload.readBytes(data);//from w w w.j a v a 2s .com return data; }
From source file:com.surevine.alfresco.dashboard.DashboardDefinition.java
/** * Adds a dashlet to the specified column * //from w w w .ja v a2 s .co m * @param column * the column to add the dashlet to * @param dashlet * the dashlet url */ public void addDashlet(final int column, final String dashlet) { List<String> rows = dashlets.get(String.valueOf(column)); if (rows == null) { throw new IndexOutOfBoundsException("Column " + column + "does not exist"); } rows.add(dashlet); }
From source file:de.cosmocode.json.JsonArrayList.java
@Override public void add(int index, Object element) { if (index < 0 || index > size()) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size()); if (element == null) throw new NullPointerException("Element must not be null"); // save current position int i = index; // holds the next element Object next = element;//from w w w . j av a 2 s.c om // loop until the end while (true) { // is the current index after the last element? if (i == size()) { // just add the next element array.put(next); // stop looping after adding next element to the end break; } else { // we didn't reach the end, so just overwrite // the element at position i, save the overwritten one // and increase the index next = set(i++, next); } } }
From source file:ru.jts_dev.authserver.util.Encoder.java
public ByteBuf validateChecksum(ByteBuf buf) { if (buf.readableBytes() % 4 != 0 || buf.readableBytes() <= 4) { throw new IndexOutOfBoundsException("ByteBuf size must be multiply of 4 and more, that 4"); }//from w w w . ja va 2 s. c o m long checksum = 0; long check; int i; for (i = 0; i < buf.readableBytes() - 4; i += 4) { check = buf.getInt(i); checksum ^= check; } check = buf.getInt(i); if (check != checksum) { throw new InvalidParameterException("Wrong checksum"); } return buf.copy(0, buf.readableBytes() - 4); }
From source file:io.horizondb.io.buffers.CompositeBuffer.java
/** * {@inheritDoc}/*from ww w .j a va 2 s .c o m*/ */ @Override public CompositeBuffer readerIndex(int readerIndex) { if (readerIndex < 0 || readerIndex > this.capacity) { @SuppressWarnings("boxing") String msg = format("readerIndex: %d Expected: 0 <= readerIndex < capacity(%d)", readerIndex, this.capacity); throw new IndexOutOfBoundsException(msg); } this.current = this.buffers.get(0); this.bufferIndex = 0; this.bufferOffset = 0; this.readerIndex = readerIndex + this.offset; return this; }
From source file:bulat.diet.helper_couch.common.data.ExampleSectionExpandableDataProvider.java
@Override public GroupData getGroupItem(int groupPosition) { if (groupPosition < 0 || groupPosition >= getGroupCount()) { throw new IndexOutOfBoundsException("groupPosition = " + groupPosition); }/* w ww.j av a2s . c o m*/ return mData.get(groupPosition).first; }
From source file:ArrayIterator.java
/** Returns the next element from the data */ public Object next() { if (hasNext()) { return data[index++]; }//from ww w . j a v a 2s .c o m throw new IndexOutOfBoundsException("only " + data.length + " elements"); }
From source file:Polygon2D.java
/** * Constructs and initializes a <code>Polygon2D</code> from the specified * Rectangle2D.// w w w . ja v a 2 s . co m * @param rec the Rectangle2D * @exception NullPointerException rec is <code>null</code>. */ public Polygon2D(Rectangle2D rec) { if (rec == null) { throw new IndexOutOfBoundsException("null Rectangle"); } npoints = 4; xpoints = new float[4]; ypoints = new float[4]; xpoints[0] = (float) rec.getMinX(); ypoints[0] = (float) rec.getMinY(); xpoints[1] = (float) rec.getMaxX(); ypoints[1] = (float) rec.getMinY(); xpoints[2] = (float) rec.getMaxX(); ypoints[2] = (float) rec.getMaxY(); xpoints[3] = (float) rec.getMinX(); ypoints[3] = (float) rec.getMaxY(); calculatePath(); }
From source file:org.cloudfoundry.identity.uaa.rest.jdbc.JdbcPagingList.java
@Override public List<E> subList(int fromIndex, int toIndex) { if (fromIndex < 0 || toIndex > size || fromIndex > toIndex) { throw new IndexOutOfBoundsException("The indexes provided are outside the bounds of this list."); }/*from ww w. j av a 2 s . co m*/ return new SafeIteratorList<E>(super.subList(fromIndex, toIndex)); }