List of usage examples for java.lang IndexOutOfBoundsException IndexOutOfBoundsException
public IndexOutOfBoundsException()
From source file:com.github.rvesse.airline.restrictions.options.RequireFromRestriction.java
@Override public String[] getContentBlock(int blockNumber) { if (blockNumber != 0) throw new IndexOutOfBoundsException(); if (mutuallyExclusive) { return new String[] { String.format( "This option is part of the group '%s' from which only one option may be specified", this.tag) }; } else {/*from ww w . j a v a 2s .co m*/ return new String[] { String.format( "This option is part of the group '%s' from which at least one option must be specified", this.tag) }; } }
From source file:com.google.android.feeds.ContentDecorator.java
/** {@inheritDoc} */ public View getView(int position, View convertView, ViewGroup parent) { if (isItem(position)) { return mAdapter.getView(position, convertView, parent); } else if (hasError()) { LayoutInflater inflater = getLayoutInflater(parent); return newErrorView(inflater, parent); } else if (hasMore()) { LayoutInflater inflater = getLayoutInflater(parent); return newLoadingView(inflater, parent); } else {/*from w ww . jav a 2 s . c o m*/ throw new IndexOutOfBoundsException(); } }
From source file:com.google.api.client.util.ArrayMap.java
/** * Sets the value at the given index, overriding any existing value mapping. * * @return previous value or {@code null} for none * @throws IndexOutOfBoundsException if index is negative or {@code >=} size */// ww w . j av a2s . c o m public final V set(int index, V value) { int size = this.size; if (index < 0 || index >= size) { throw new IndexOutOfBoundsException(); } int valueDataIndex = 1 + (index << 1); V result = valueAtDataIndex(valueDataIndex); this.data[valueDataIndex] = value; return result; }
From source file:com.nmote.io.ByteArrayOutputStream.java
/** * Write the bytes to byte array./*from ww w . j av a 2 s .c o m*/ * * @param b * the bytes to write * @param off * The start offset * @param len * The number of bytes to write */ @Override public void write(byte[] b, int off, int len) { if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } synchronized (this) { int newcount = count + len; int remaining = len; int inBufferPos = count - filledBufferSum; while (remaining > 0) { int part = Math.min(remaining, currentBuffer.length - inBufferPos); System.arraycopy(b, off + len - remaining, currentBuffer, inBufferPos, part); remaining -= part; if (remaining > 0) { needNewBuffer(newcount); inBufferPos = 0; } } count = newcount; } }
From source file:hr.fer.spocc.regex.AbstractRegularExpression.java
@Override public RegularExpression<T> getSubexpression(int n) { if (isTrivial() || n < 0 || n >= getOperator().getArity()) throw new IndexOutOfBoundsException(); return n == 0 ? subexpression1 : subexpression2; }
From source file:com.github.rvesse.airline.help.sections.common.VersionSection.java
@Override public String[] getContentBlock(int blockNumber) { if (blockNumber < 0 || blockNumber > this.numContentBlocks()) throw new IndexOutOfBoundsException(); if (this.tabular) { String[] column = new String[this.versions.size() + 1]; for (int row = 0; row < this.versions.size(); row++) { switch (blockNumber) { case 0: column[0] = "Component"; this.versions.get(row).addComponent(column, row + 1); break; case 1: column[0] = "Version"; this.versions.get(row).addVersion(column, row + 1); break; case 2: column[0] = "Build"; this.versions.get(row).addBuild(column, row + 1); break; case 3: column[0] = "Build Date"; this.versions.get(row).addBuildDate(column, row + 1); break; default: column[0] = this.titles[blockNumber - 4]; this.versions.get(row).addAdditionalColumn(column, row + 1, this.titles[blockNumber - 4]); break; }/*from ww w. j a va 2 s. com*/ } return column; } else { return this.versions.get(blockNumber).toList(); } }
From source file:de.walware.statet.r.core.rsource.ast.FCall.java
@Override public final RAstNode getChild(final int index) { switch (index) { case 0:/*from w w w. j av a2 s . c om*/ return fRefExpr.node; case 1: return fArgs; default: throw new IndexOutOfBoundsException(); } }
From source file:ClosableCharArrayWriter.java
/** * Writes the designated portion of the designated character array . * * @param c the source character sequence. * @param off the start offset in the source character sequence. * @param len the number of characters to write. * @throws java.io.IOException if an I/O error occurs. * In particular, an <tt>IOException</tt> may be thrown * if this writer has been {@link #close() closed}. *//* w ww . j ava 2 s . co m*/ public synchronized void write(char c[], int off, int len) throws IOException { checkClosed(); if ((off < 0) || (off > c.length) || (len < 0) || ((off + len) > c.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } int newcount = count + len; if (newcount > buf.length) { buf = copyOf(buf, Math.max(buf.length << 1, newcount)); } System.arraycopy(c, off, buf, count, len); count = newcount; }
From source file:cc.redberry.core.number.Complex.java
@Override public Tensor get(int i) { throw new IndexOutOfBoundsException(); }
From source file:MicroMap.java
/** * @see java.util.Map#values()/*from w w w .j a v a 2s . c o m*/ */ public Collection<V> values() { return new AbstractList<V>() { @Override public V get(final int index) { if (index > size() - 1) { throw new IndexOutOfBoundsException(); } return value; } @Override public int size() { return MicroMap.this.size(); } }; }