List of usage examples for java.lang IndexOutOfBoundsException IndexOutOfBoundsException
public IndexOutOfBoundsException(int index)
From source file:com.actionbarsherlock.internal.view.MenuBuilder.java
@Override public void removeItem(int itemId) { final int size = this.mItems.size(); for (int i = 0; i < size; i++) { if (this.mItems.get(i).getItemId() == itemId) { this.mItems.remove(i); return; }// w ww . j a v a2 s . c om } throw new IndexOutOfBoundsException("No item with id " + itemId); }
From source file:com.tiempometa.muestradatos.ReaderContext.java
public static boolean getGpo(int gpi) throws ReaderException { if (readerType == ReaderContext.USB_READER) { GpioPin[] pins = getGpo();// w w w .ja v a 2 s . c o m if (gpi < pins.length) { return pins[gpi].high; } else { throw new IndexOutOfBoundsException("Pin id beyond available inputs."); } } else { return false; } }
From source file:io.horizondb.io.buffers.AbstractBuffer.java
/** * {@inheritDoc}/* w ww . j av a 2 s . c o m*/ */ @Override public byte getByte(int index) { if (index < 0 || index >= capacity()) { @SuppressWarnings("boxing") String msg = String.format("Index: %d Capacity: %d", index, capacity()); throw new IndexOutOfBoundsException(msg); } return doGetByte(this.offset + index); }
From source file:Lists.java
private static <T> IndexOutOfBoundsException newIndexOutOfBounds(List<T> list, int index) { return new IndexOutOfBoundsException("Index: " + index + ", Size: " + list.size()); }
From source file:de.huberlin.cuneiform.dag.Invocation.java
public DataList getDataList(int outputChannel) throws NotDerivableException { int n;//w w w. j a v a 2 s.c om DataList list; if (outputChannel < 0) throw new IndexOutOfBoundsException("Output channel must not be smaller than 0."); list = dataListList.get(outputChannel); if (list == null) throw new NotDerivableException("Data list for output channel " + outputChannel + " not bound for invocation signature=" + getSignature() + "."); n = size(outputChannel); if (n != list.size()) throw new RuntimeException("Concrete size does not match inferred size."); return list; }
From source file:ivorius.ivtoolkit.models.utils.ArrayMap.java
public K getKeyAt(int index) { if (index >= size) throw new IndexOutOfBoundsException(String.valueOf(index)); return keys[index]; }
From source file:ivorius.ivtoolkit.models.utils.ArrayMap.java
public V getValueAt(int index) { if (index >= size) throw new IndexOutOfBoundsException(String.valueOf(index)); return values[index]; }
From source file:libepg.epg.util.datetime.DateTimeFieldConverter.java
/** * ?????java.sql.Timestamp??? <br> * MJD ??16 16 ??????246?4210BCD???<br> * ?????????????1??? <br>// w w w. j ava 2s .c om * 93/10/13 12:45:00?0xC079124500???? * * @param source * @return ???Timestamp * @throws IndexOutOfBoundsException ?????5??? * @throws java.text.ParseException ??????1???????????????? * */ public static synchronized java.sql.Timestamp BytesToSqlDateTime(byte[] source) throws ParseException { if (source.length != 5) { throw new IndexOutOfBoundsException( "?????5????????" + " ?=" + Hex.encodeHexString(source)); } if (Arrays.equals(source, UNDEFINED_DATETIME_BLOCK.getData())) { throw new ParseException("?????????? ? = " + Hex.encodeHexString(source), 0); } StringBuilder sb = new StringBuilder(); byte[] mjd = new byte[2]; System.arraycopy(source, 0, mjd, 0, mjd.length); sb.append(mjdToString(mjd)); byte[] hms = new byte[3]; System.arraycopy(source, 2, hms, 0, hms.length); sb.append(BcdTimeToString(hms)); String dateStr = sb.toString(); java.text.SimpleDateFormat dateParser = new java.text.SimpleDateFormat(DATE_PATTERN); dateParser.setLenient(false); long dt = dateParser.parse(dateStr).getTime(); if (LOG.isTraceEnabled()) { LOG.trace(dt); } return new java.sql.Timestamp(dt); }
From source file:io.horizondb.io.buffers.AbstractBuffer.java
/** * {@inheritDoc}// w w w. ja v a 2 s. c o m */ @Override public ReadableBuffer getBytes(int index, byte[] array, int off, int len) { if (index < 0 || len < 0 || (index + len) > capacity()) { @SuppressWarnings("boxing") String msg = String.format("Index: %d Length: %d Capacity: %d", index, len, capacity()); throw new IndexOutOfBoundsException(msg); } doGetBytes(this.offset + index, array, off, len); return this; }
From source file:com.slytechs.capture.file.indexer.SoftRegionIndexer.java
public long mapIndexToPositionRegional(final int regional) { if ((regional < 0) || (regional >= this.length)) { throw new IndexOutOfBoundsException( "Regional index [" + regional + "] is out of bounds [0 - " + (this.length - 1) + "]."); }// w ww .j a v a 2 s. c om final int it = (this.factor == 0 ? 0 : regional / this.factor); final int index = (this.factor == 0 ? regional : regional % this.factor); try { final long position = this.table[it].get(index); return position; } catch (final IOException e) { throw new IORuntimeException(e); } }