Example usage for java.lang IndexOutOfBoundsException IndexOutOfBoundsException

List of usage examples for java.lang IndexOutOfBoundsException IndexOutOfBoundsException

Introduction

In this page you can find the example usage for java.lang IndexOutOfBoundsException IndexOutOfBoundsException.

Prototype

public IndexOutOfBoundsException(int index) 

Source Link

Document

Constructs a new IndexOutOfBoundsException class with an argument indicating the illegal index.

Usage

From source file:CopyOnWriteArrayList.java

/**
 * Returns a ListIterator of the elements in this List (in proper sequence),
 * starting at the specified position in the List. The specified index
 * indicates the first element that would be returned by an initial call to
 * nextElement. An initial call to previousElement would return the element
 * with the specified index minus one. The ListIterator returned by this
 * implementation will throw an UnsupportedOperationException in its remove,
 * set and add methods./*from   ww  w. j  ava 2 s. c o  m*/
 * 
 * @param index
 *            index of first element to be returned from the ListIterator
 *            (by a call to getNext).
 * @exception IndexOutOfBoundsException
 *                index is out of range (index < 0 || index > size()).
 */
public ListIterator listIterator(final int index) {
    Object[] elementData = array();
    int len = elementData.length;
    if (index < 0 || index > len)
        throw new IndexOutOfBoundsException("Index: " + index);

    return new COWIterator(array(), index);
}

From source file:com.netxforge.oss2.xml.event.Event.java

/**
 * /*from   w w w  .j a  v a2 s.c o  m*/
 * 
 * @param index
 * @param vAutoaction
 * @throws IndexOutOfBoundsException
 *             if the index given is outside the bounds of the collection
 */
public void setAutoaction(final int index, final Autoaction vAutoaction) throws IndexOutOfBoundsException {
    // check bounds for index
    if (index < 0 || index >= _autoactionList.size()) {
        throw new IndexOutOfBoundsException("setAutoaction: Index value '" + index + "' not in range [0.."
                + (_autoactionList.size() - 1) + "]");
    }

    _autoactionList.set(index, vAutoaction);
}

From source file:com.slytechs.capture.file.editor.AbstractRawIterator.java

public long setPosition(final long global) throws IOException {
    if (global < getBoundaryStart()) {
        throw new IndexOutOfBoundsException(
                "The position [" + global + "]is outside the boundary of this bounded Iterator ["
                        + getBoundaryStart() + "-" + getBoundaryEnd() + "]");
    }/* ww  w  . j  av a 2 s  . co  m*/

    final long old = global;
    this.global = global;

    this.setPosition();

    return old;
}

From source file:com.netxforge.oss2.xml.event.Event.java

/**
 * /* ww w.j  ava2  s.  c  om*/
 * 
 * @param index
 * @param vForward
 * @throws IndexOutOfBoundsException
 *             if the index given is outside the bounds of the collection
 */
public void setForward(final int index, final Forward vForward) throws IndexOutOfBoundsException {
    // check bounds for index
    if (index < 0 || index >= _forwardList.size()) {
        throw new IndexOutOfBoundsException(
                "setForward: Index value '" + index + "' not in range [0.." + (_forwardList.size() - 1) + "]");
    }

    _forwardList.set(index, vForward);
}

From source file:com.netxforge.oss2.xml.event.Event.java

/**
 * /* www  .j a  v a  2  s. c o m*/
 * 
 * @param index
 * @param vLoggroup
 * @throws IndexOutOfBoundsException
 *             if the index given is outside the bounds of the collection
 */
public void setLoggroup(final int index, final String vLoggroup) throws IndexOutOfBoundsException {
    // check bounds for index
    if (index < 0 || index >= _loggroupList.size()) {
        throw new IndexOutOfBoundsException("setLoggroup: Index value '" + index + "' not in range [0.."
                + (_loggroupList.size() - 1) + "]");
    }

    _loggroupList.set(index, vLoggroup);
}

From source file:com.github.helenusdriver.driver.impl.StatementManagerImpl.java

/**
 * {@inheritDoc}// w  w  w.  java2s  .co  m
 *
 * @author paouelle
 *
 * @see com.github.helenusdriver.driver.StatementManager#setIdx(java.lang.CharSequence, int, java.lang.Object)
 */
@Override
protected Assignment setIdx(CharSequence name, int idx, Object value) {
    if (idx < 0) {
        throw new IndexOutOfBoundsException("invalid negative index: " + idx);
    }
    return new AssignmentImpl.ListSetIdxAssignmentImpl(name, idx, value);
}

From source file:com.netxforge.oss2.xml.event.Event.java

/**
 * /*from  w ww.j  a v  a 2s  . c o m*/
 * 
 * @param index
 * @param vOperaction
 * @throws IndexOutOfBoundsException
 *             if the index given is outside the bounds of the collection
 */
public void setOperaction(final int index, final Operaction vOperaction) throws IndexOutOfBoundsException {
    // check bounds for index
    if (index < 0 || index >= _operactionList.size()) {
        throw new IndexOutOfBoundsException("setOperaction: Index value '" + index + "' not in range [0.."
                + (_operactionList.size() - 1) + "]");
    }

    _operactionList.set(index, vOperaction);
}

From source file:microsoft.exchange.webservices.data.core.EwsUtilities.java

/**
 * Gets the enumerated object at.//from   w w  w. ja va2s . c  o  m
 *
 * @param <T>     the generic type
 * @param objects the objects
 * @param index   the index
 * @return the enumerated object at
 */
public static <T> Object getEnumeratedObjectAt(Iterable<T> objects, int index) {
    int count = 0;
    for (Object obj : objects) {
        if (count == index) {
            return obj;
        }
        count++;
    }
    throw new IndexOutOfBoundsException("The IEnumerable doesn't contain that many objects.");
}

From source file:com.netxforge.oss2.xml.event.Event.java

/**
 * //from w  w  w  .jav  a 2  s .c  om
 * 
 * @param index
 * @param vScript
 * @throws IndexOutOfBoundsException
 *             if the index given is outside the bounds of the collection
 */
public void setScript(final int index, final Script vScript) throws IndexOutOfBoundsException {
    // check bounds for index
    if (index < 0 || index >= _scriptList.size()) {
        throw new IndexOutOfBoundsException(
                "setScript: Index value '" + index + "' not in range [0.." + (_scriptList.size() - 1) + "]");
    }

    _scriptList.set(index, vScript);
}

From source file:com.github.haixing_hu.csl.util.Argument.java

public static int requireIndexInCloseRange(final int index, final int left, final int right) {
    if ((index < left) || (index > right)) {
        throw new IndexOutOfBoundsException(
                "The index must in the close range [" + left + ", " + right + "], " + " but it is " + index);
    }/*from   ww  w  . java  2 s. com*/
    return index;
}