List of usage examples for java.lang IndexOutOfBoundsException IndexOutOfBoundsException
public IndexOutOfBoundsException(int index)
From source file:com.kunckle.jetpower.core.base.repository.impl.BaseRepositorySupport.java
/** * ?// w w w . j av a2 s. co m * * @param searchAdapter ?? * @return ?null * @throws IndexOutOfBoundsException */ @Override @SuppressWarnings("unchecked") public Page<E> findAll(SearchAdapter searchAdapter, PageAdapter pageAdapter) { pageAdapter.setCountOfElements(count(searchAdapter)); if (pageAdapter.exists() && pageAdapter.getPageNumber() != 0) { throw new IndexOutOfBoundsException("?"); } else if (pageAdapter.getCountOfElements() == 0) { return null; } if (searchAdapter.getPrepQL() != null) { Query query = getSession().createQuery("from " + entityClass.getSimpleName() + " " + searchAdapter.getPrepQL() + " " + pageAdapter.getPageSortAdapter().getPrepQL()); query.setParameter(0, entityClass.getName()); query.setFirstResult(pageAdapter.getPageOffset() * pageAdapter.getPageSize()); query.setMaxResults(pageAdapter.getPageSize()); return new Page<E>(pageAdapter, query.list()); } else { Criteria criteria = searchAdapter.getCriteria(getSession().createCriteria(entityClass)); criteria = pageAdapter.getPageSortAdapter().getCriteria(criteria); criteria.setFirstResult(pageAdapter.getPageOffset() * pageAdapter.getPageSize()); criteria.setMaxResults(pageAdapter.getPageSize()); return new Page<E>(pageAdapter, criteria.list()); } }
From source file:edu.chalmers.dat255.audiobookplayer.model.Bookshelf.java
public void setSelectedTrackElapsedTime(int elapsedTime) { if (selectedBookIndex == NO_BOOK_SELECTED) { throw new IndexOutOfBoundsException(TAG + " setSelectedTrackElapsedTime " + NO_BOOK_SELECTED); }/* w w w . ja v a2 s . com*/ // set elapsed time in the currently playing book books.get(selectedBookIndex).setSelectedTrackElapsedTime(elapsedTime); if (hasListeners()) { pcs.firePropertyChange(Constants.Event.ELAPSED_TIME_CHANGED, null, new Bookshelf(this)); } }
From source file:org.hexlogic.CooptoPluginFactory.java
@Override public List<?> findChildrenInRootRelation(String type, String relationName) { log.debug("running findChildrenInRootRelation() with type=" + type + " and relationName=" + relationName + "."); if (type.equals(CooptoModuleBuilder.ROOT)) { if (relationName.equals(CooptoModuleBuilder.NODERELATION)) { return findAll(DockerNode.TYPE, null).getElements(); } else {// www. ja v a 2s .c o m throw new IndexOutOfBoundsException("Unknown relation name: " + relationName); } } else { return Collections.emptyList(); } }
From source file:com.microsoft.tfs.core.util.TSWAHyperlinkBuilder.java
/** * Gets a Work Item Editor Url.//from ww w . j av a 2 s.co m * * @param workItemId * A workitem id. * @param accessMappingMoniker * A moniker for the desired access mapping. * @return A Work Item Editor url. */ public URI getWorkItemEditorURL(final int workItemId, final String accessMappingMoniker) { if (workItemId < 1) { throw new IndexOutOfBoundsException( MessageFormat.format("The value {0} is outside of the allowed range.", //$NON-NLS-1$ Integer.toString(workItemId))); } return buildURL(ServiceInterfaceNames.TSWA_OPEN_WORK_ITEM, accessMappingMoniker, "workItemId", //$NON-NLS-1$ Integer.toString(workItemId), null); }
From source file:com.ojcoleman.ahni.util.DoubleVector.java
private final void checkRange(int index) { if (index < 0 || index >= _size) { throw new IndexOutOfBoundsException("Should be at least 0 and less than " + _size + ", found " + index); }// ww w. ja va 2 s . co m }
From source file:com.framework.utils.error.PreConditions.java
/** * Ensures that {@code startTest} and {@code endTest} specify a valid <i>positions</i> in an array, list * or string of size {@code size}, and are in order. A position index may range from zero to * {@code size}, inclusive.// ww w. j av a 2s. com * * @param start a user-supplied index identifying a starting position in an array, list or string * @param end a user-supplied index identifying a ending position in an array, list or string * @param size the size of that array, list or string * * @throws IndexOutOfBoundsException if either index is negative or is greater than {@code size}, * or if {@code endTest} is less than {@code startTest} * @throws IllegalArgumentException if {@code size} is negative */ public static void checkPositionIndexes(int start, int end, int size) { // Carefully optimized for execution by hotspot (explanatory comment above) if (start < 0 || end < start || end > size) { throw new PreConditionException(new IndexOutOfBoundsException(badPositionIndexes(start, end, size))); } }
From source file:ArraySet.java
/** * Returns the entry for the index.//from w w w. ja va2 s .c om * * @param index * the index * @return the entry */ public final Entry<K, V> getEntry(int index) { if (index >= size) { throw new IndexOutOfBoundsException("Index:" + index + ", Size:" + size); } return listTable[index]; }
From source file:ArrayUtils.java
@SuppressWarnings("unchecked") public static <T> T[] remove(final T[] array, final int from, final int to) { assert (to >= from) : to + " - " + from; int length = getLength(array); if (from < 0 || to >= length) { throw new IndexOutOfBoundsException("from: " + from + ", to: " + to + ", Length: " + length); }/*from w ww.j a va 2 s. com*/ int remsize = to - from + 1; Object result = Array.newInstance(array.getClass().getComponentType(), length - remsize); System.arraycopy(array, 0, result, 0, from); if (to < length - 1) { System.arraycopy(array, to + 1, result, from, length - to - 1); } return (T[]) result; }
From source file:com.google.uzaygezen.core.BitSetBackedBitVector.java
@Override public void copySectionFrom(int offset, BitVector src) { int srcSize = src.size(); int toIndex = offset + srcSize; if (offset < 0 | toIndex > size) { throw new IndexOutOfBoundsException("invalid range: offset=" + offset + " src.size()=" + src.size()); }/* w ww . j a va 2s .c o m*/ bitset.clear(offset, toIndex); for (int j = srcSize == 0 ? -1 : src.nextSetBit(0); j != -1; j = j == srcSize - 1 ? -1 : src.nextSetBit(j + 1)) { bitset.set(offset + j); } }
From source file:com.silverwrist.dynamo.security.AclObject.java
public DynamoAce getAce(Principal caller, int index) throws DatabaseException, NotOwnerException { if (index < 0) throw new IndexOutOfBoundsException("ACE index less than 0"); // get the ACE ID from the database and then get it from the ACE cache return m_ace_cache.getAce(m_ops.getAceID(m_aclid, new PrincipalID(caller), index)); }