List of usage examples for java.lang IndexOutOfBoundsException IndexOutOfBoundsException
public IndexOutOfBoundsException(int index)
From source file:io.horizondb.io.BitSet.java
/** * Writes the specified bit to this <code>BitSet</code>. * <p>//from w w w.j av a 2s . c om * The bits are written from right to left. * </p> * * @return this <code>BitSet</code>. */ public BitSet writeBit(boolean bit) { if (!isWriteable()) { throw new IndexOutOfBoundsException("Index: " + writerIndex() + ", Size: " + this.capacity); } int mask = this.writingMask; doSetBit(mask, bit); this.writingMask <<= 1; return this; }
From source file:io.horizondb.io.buffers.NettyBuffer.java
/** * {@inheritDoc}//from w w w .ja v a 2 s . co m */ @Override protected void checkSubRegion(int offset, int length) { if ((offset + length) > this.buffer.capacity()) { throw new IndexOutOfBoundsException( "Index: " + (offset + length) + " Capacity: " + this.buffer.capacity()); } }
From source file:com.opengamma.maths.highlevelapi.datatypes.primitive.OGIndexType.java
/** * @param indices The index of the entry within the matrix to be returned. * If a single index is given, it assumes ind2sub behaviour (index = i*rows+j) and returns that index * If a pair of indices are given, it assumes standard lookup behaviour and returns the index at the given matrix "coordinate". * @return the entry at index specified/*from ww w . j a v a2 s . c o m*/ * */ public int getEntry(int... indices) { if (indices.length > 2) { throw new IndexOutOfBoundsException( "Trying to access a 2D array representation with tuple>2 is forbidden!"); } else if (indices.length == 2) { return _data[_rowPtr[indices[0]] + indices[1]]; } else { return _data[indices[0]]; } }
From source file:com.google.uzaygezen.core.LongBitVector.java
private void checkIndex(int bitIndex) { if (bitIndex < 0 | bitIndex >= size) { throw new IndexOutOfBoundsException("Bit index out of range: " + bitIndex); }// w w w . jav a 2s .c o m }
From source file:IntVector.java
public int set(final int index, final int value) { if (index > m_size - 1) throw new IndexOutOfBoundsException("get[" + index + "] on vector of size " + m_size); final int current_value = m_values[index]; m_values[index] = value;/* w w w . jav a2s. c o m*/ return current_value; }
From source file:Main.java
/** * Underlying implementation of add(array, index, element) methods. * The last parameter is the class, which may not equal element.getClass * for primitives./*from ww w . j ava2s. c o m*/ * * @param array the array to add the element to, may be <code>null</code> * @param index the position of the new object * @param element the object to add * @param clss the type of the element being added * @return A new array containing the existing elements and the new element */ private static Object add(Object array, int index, Object element, Class clss) { if (array == null) { if (index != 0) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: 0"); } Object joinedArray = Array.newInstance(clss, 1); Array.set(joinedArray, 0, element); return joinedArray; } int length = Array.getLength(array); if (index > length || index < 0) { throw new IndexOutOfBoundsException("Index: " + index + ", Length: " + length); } Object result = Array.newInstance(clss, length + 1); System.arraycopy(array, 0, result, 0, index); Array.set(result, index, element); if (index < length) { System.arraycopy(array, index, result, index + 1, length - index); } return result; }
From source file:MapTableModel.java
/** * Returns the value at./*from w w w .j ava 2 s . c o m*/ */ public Object getValueAt(int row, int column) { Object[] entries = map.entrySet().toArray(); Map.Entry entry = (Map.Entry) entries[row]; if (column == 0) { return entry.getKey(); } else if (column == 1) { // column==1 return entry.getValue(); } else { throw new IndexOutOfBoundsException( "MapTableModel provides a 2-column table, column-index " + column + " is illegal."); } }
From source file:com.lexicalscope.fluentreflection.FluentMethodImpl.java
@Override public int indexOfArg(final Matcher<? super FluentClass<?>> matcher) { final List<FluentClass<?>> args = args(); for (int i = 0; i < args.size(); i++) { if (matcher.matches(args.get(i))) { return i; }/*from w w w . j a v a2 s . c o m*/ } throw new IndexOutOfBoundsException("No argment matching " + matcher); }
From source file:com.cpd.adapters.ViewPagerAdapter.java
/** * Gets the icon reference in that specific position *//*from w w w .j a va 2 s. c o m*/ public int getIconAt(int pos) { if (pos >= 0 && pos < mTabIcon.length) { return mTabIcon[pos]; } throw new IndexOutOfBoundsException("No icon for this position"); }
From source file:com.evolveum.midpoint.prism.xjc.PropertyArrayList.java
private PrismPropertyValue<Object> getPropertyValue(int index) { if (index < 0 || index >= size()) { throw new IndexOutOfBoundsException( "Can't get object on position '" + index + "', list size is '" + size() + "'."); }/*from w w w . j av a 2 s . c om*/ //at least we try to get object on index defined by parameter Iterator<PrismPropertyValue<Object>> iterator = property.getValues().iterator(); for (int i = 0; i < index; i++) { iterator.next(); } return iterator.next(); }