List of usage examples for java.lang IndexOutOfBoundsException IndexOutOfBoundsException
public IndexOutOfBoundsException(int index)
From source file:com.netxforge.oss2.xml.event.Maskelement.java
/** * //from w ww. jav a2 s . c om * * @param index * @param vMevalue * @throws java.lang.IndexOutOfBoundsException if the index * given is outside the bounds of the collection */ public void setMevalue(final int index, final java.lang.String vMevalue) throws java.lang.IndexOutOfBoundsException { // check bounds for index if (index < 0 || index >= this._mevalueList.size()) { throw new IndexOutOfBoundsException("setMevalue: Index value '" + index + "' not in range [0.." + (this._mevalueList.size() - 1) + "]"); } this._mevalueList.set(index, vMevalue.intern()); }
From source file:com.netxforge.oss2.xml.event.Mask.java
/** * //from ww w .j a v a 2s . c o m * * @param index * @param vMaskelement * @throws java.lang.IndexOutOfBoundsException if the index * given is outside the bounds of the collection */ public void setMaskelement(final int index, final com.netxforge.oss2.xml.event.Maskelement vMaskelement) throws java.lang.IndexOutOfBoundsException { // check bounds for index if (index < 0 || index >= this._maskelementList.size()) { throw new IndexOutOfBoundsException("setMaskelement: Index value '" + index + "' not in range [0.." + (this._maskelementList.size() - 1) + "]"); } this._maskelementList.set(index, vMaskelement); }
From source file:net.librec.recommender.AbstractRecommender.java
/** * recommend/*from w w w. ja v a 2 s. c o m*/ * * predict the ranking scores in the test data * * @return predictive rating matrix * @throws LibrecException if error occurs during recommending */ protected RecommendedList recommendRank() throws LibrecException { recommendedList = new RecommendedItemList(numUsers - 1, numUsers); for (int userIdx = 0; userIdx < numUsers; ++userIdx) { Set<Integer> itemSet = trainMatrix.getColumnsSet(userIdx); for (int itemIdx = 0; itemIdx < numItems; ++itemIdx) { if (itemSet.contains(itemIdx)) { continue; } double predictRating = predict(userIdx, itemIdx); if (Double.isNaN(predictRating)) { continue; } recommendedList.addUserItemIdx(userIdx, itemIdx, predictRating); } recommendedList.topNRankItemsByUser(userIdx, topN); } if (recommendedList.size() == 0) { throw new IndexOutOfBoundsException( "No item is recommended, there is something error in the recommendation algorithm! Please check it!"); } return recommendedList; }
From source file:ch.entwine.weblounge.common.impl.content.page.PageImpl.java
/** * {@inheritDoc}//from ww w . j a v a2 s . c om * * @see ch.entwine.weblounge.common.content.page.Page#addPagelet(ch.entwine.weblounge.common.content.page.Pagelet, * java.lang.String, int) */ public Pagelet addPagelet(Pagelet pagelet, String composer, int position) { List<Pagelet> c = composers.get(composer); if (c == null) { c = new ArrayList<Pagelet>(); composers.put(composer, c); } // Test position if (position < 0 || position > c.size()) throw new IndexOutOfBoundsException("There are only " + c.size() + " pagelets in the composer"); // Insert if (position < c.size()) { c.add(position, pagelet); for (int i = position + 1; i < c.size(); i++) { c.get(i).getURI().setPosition(i); } } // Append else { c.add(pagelet); } // Adjust pagelet location PageletURI location = pagelet.getURI(); if (location == null) { location = new PageletURIImpl(uri, composer, position); pagelet.setURI(location); } else { location.setURI(uri); location.setComposer(composer); location.setPosition(position); } return pagelet; }
From source file:ivorius.ivtoolkit.models.utils.ArrayMap.java
public void setKey(int index, K key) { if (index >= size) throw new IndexOutOfBoundsException(String.valueOf(index)); keys[index] = key;/*from www . j ava 2 s . co m*/ }
From source file:io.horizondb.io.buffers.CompositeBuffer.java
/** * Removes the specified amount bytes starting at the specified location. * * @param offset the position at which the bytes must be deleted * @param length the amount of bytes to delete * @throws IOException if an I/O problem occurs *///from w w w.j a va 2 s .c o m public CompositeBuffer removeBytes(int offset, int length) throws IOException { if (offset < 0) { throw new IndexOutOfBoundsException("Expected: offset >= 0"); } if (offset + length > this.capacity) { @SuppressWarnings("boxing") String msg = format("Expected: offset + length < capacity(%d)", this.capacity); throw new IndexOutOfBoundsException(msg); } int bufferOffset = 0; int remaining = length; int numberOfBuffers = this.buffers.size(); for (int i = 0; i < numberOfBuffers;) { if (remaining == 0) { break; } ReadableBuffer buffer = this.buffers.get(i); int readableBytes = buffer.readableBytes(); if (offset >= bufferOffset && offset < (bufferOffset + readableBytes)) { int index = offset - bufferOffset; int toRemove = Math.min(readableBytes - index, remaining); this.buffers.remove(i); if (index == 0) { if (toRemove != readableBytes) { ReadableBuffer newBuffer = buffer.slice(toRemove, readableBytes - toRemove).duplicate(); this.buffers.add(i, newBuffer); i++; } } else { ReadableBuffer newBuffer = buffer.slice(0, index).duplicate(); this.buffers.add(i, newBuffer); int off = index + toRemove; int l = readableBytes - off; if (l != 0) { newBuffer = buffer.slice(off, l).duplicate(); this.buffers.add(++i, newBuffer); } i++; } bufferOffset += (readableBytes - toRemove); remaining -= toRemove; } else { bufferOffset += readableBytes; i++; } numberOfBuffers = this.buffers.size(); } if (offset < this.readerIndex) { if (this.readerIndex < offset + length) { this.readerIndex = offset; } else { this.readerIndex -= length; } } this.capacity -= length; this.current = this.buffers.get(0); this.bufferIndex = 0; this.bufferOffset = 0; return this; }
From source file:com.tiendd.uet.predicting.AbstractRecommender.java
/** * recommend * predict the ranking scores in the test data * * @return predictive rating matrix//from w w w . ja v a2 s .c o m * @throws LibrecException * if error occurs during recommending */ protected RecommendedList recommendRank() throws LibrecException { recommendedList = new RecommendedItemList(numUsers - 1, numUsers); for (int userIdx = 0; userIdx < numUsers; ++userIdx) { Set<Integer> itemSet = trainMatrix.getColumnsSet(userIdx); for (int itemIdx = 0; itemIdx < numItems; ++itemIdx) { if (itemSet.contains(itemIdx)) { continue; } double predictRating = predict(userIdx, itemIdx); if (Double.isNaN(predictRating)) { continue; } recommendedList.addUserItemIdx(userIdx, itemIdx, predictRating); } // recommendedList.topNRankItemsByUser(userIdx, topN); } if (recommendedList.size() == 0) { throw new IndexOutOfBoundsException( "No item is recommended, there is something error in the recommendation algorithm! Please check it!"); } return recommendedList; }
From source file:ivorius.ivtoolkit.models.utils.ArrayMap.java
public void setValue(int index, V value) { if (index >= size) throw new IndexOutOfBoundsException(String.valueOf(index)); values[index] = value;/* w ww . java 2 s .c o m*/ }
From source file:com.jcwhatever.nucleus.internal.managed.commands.Arguments.java
@Override public Iterator<ICommandArgument> iterator() { return new Iterator<ICommandArgument>() { int index = 0; @Override/*from w w w . j a v a2 s . c o m*/ public boolean hasNext() { return index < staticSize() + floatingSize(); } @Override public Argument next() { if (!hasNext()) throw new IndexOutOfBoundsException("No more elements."); Argument arg = index < staticSize() ? _parseResults.getStaticArgs().get(index) : _parseResults.getFloatingArgs().get(index - (staticSize() > 0 ? 1 : 0)); index++; //noinspection ConstantConditions return arg; } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
From source file:ivorius.ivtoolkit.models.utils.ArrayMap.java
public void insert(int index, K key, V value) { if (index > size) throw new IndexOutOfBoundsException(String.valueOf(index)); if (size == keys.length) resize(Math.max(8, (int) (size * 1.75f))); if (ordered) { System.arraycopy(keys, index, keys, index + 1, size - index); System.arraycopy(values, index, values, index + 1, size - index); } else {//from w w w . java 2 s .c o m keys[size] = keys[index]; values[size] = values[index]; } size++; keys[index] = key; values[index] = value; }