Example usage for java.lang ArrayIndexOutOfBoundsException ArrayIndexOutOfBoundsException

List of usage examples for java.lang ArrayIndexOutOfBoundsException ArrayIndexOutOfBoundsException

Introduction

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

Prototype

public ArrayIndexOutOfBoundsException(int index) 

Source Link

Document

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

Usage

From source file:ObjectStack.java

/**
 * Pop multiple values from the stack. The last value popped is the
 * one returned.//from   www .  j  a  va2s  . c  om
 *
 * @param count number of values to pop from stack (must be strictly
 * positive)
 * @return value from top of stack
 * @exception ArrayIndexOutOfBoundsException on attempt to pop past end of
 * stack
 */
public Object pop(int count) {
    if (count < 0) {
        throw new IllegalArgumentException("Count must be greater than 0");
    } else if (m_countPresent >= count) {
        m_countPresent -= count;
        Object value = m_baseArray[m_countPresent];
        discardValues(m_countPresent, m_countPresent + count);
        return value;
    } else {
        throw new ArrayIndexOutOfBoundsException("Attempt to pop past end of stack");
    }
}

From source file:StringStack.java

/**
 * Pop multiple values from the stack. The last value popped is the
 * one returned./*from w w  w.  ja  v a 2  s.co m*/
 *
 * @param count number of values to pop from stack (must be strictly
 * positive)
 * @return value from top of stack
 * @exception ArrayIndexOutOfBoundsException on attempt to pop past end of
 * stack
 */
public String pop(int count) {
    if (count < 0) {
        throw new IllegalArgumentException("Count must be greater than 0");
    } else if (m_countPresent >= count) {
        m_countPresent -= count;
        String value = m_baseArray[m_countPresent];
        discardValues(m_countPresent, m_countPresent + count);
        return value;
    } else {
        throw new ArrayIndexOutOfBoundsException("Attempt to pop past end of stack");
    }
}

From source file:StringArray.java

/**
 * Get a value from the array./*from w  ww .ja v  a2s. c  o m*/
 *
 * @param index index of value to be returned
 * @return value from stack
 * @exception ArrayIndexOutOfBoundsException on attempt to access outside
 * valid range
 */
public String get(int index) {
    if (m_countPresent > index) {
        return m_baseArray[index];
    } else {
        throw new ArrayIndexOutOfBoundsException("Attempt to access past end of array");
    }
}

From source file:mml.handler.scratch.ScratchVersionSet.java

/**
 * Get the databse name this resource is assigned to
 * @return the name of a calliope database
 * @throws ArrayIndexOutOfBoundsException 
 *//*  www .ja v a2 s .  co  m*/
public String getDbase() throws ArrayIndexOutOfBoundsException {
    if (this.list == null || this.list.length == 0)
        throw new ArrayIndexOutOfBoundsException("List is empty");
    return this.list[0].getDbase();
}

From source file:org.janusgraph.core.attribute.Geoshape.java

/**
 * Returns the point at the given position. The position must be smaller than {@link #size()}.
 *
 * @param position/*from   ww w  .  j a v a 2 s .c o m*/
 * @return
 */
public Point getPoint(int position) {
    if (position < 0 || position >= size())
        throw new ArrayIndexOutOfBoundsException("Invalid position: " + position);
    return new Point(coordinates[0][position], coordinates[1][position]);
}

From source file:com.alvermont.terraj.fracplanet.geom.TriangleBufferArray.java

/**
 * Get a vertex value from this triangle array
 *
 * @param index The index of the element to be retrieved
 * @param vertex The vertex number to be retrieved (0,1 or 2)
 * @return The value of the specified vertex at this index
 *//*from w w  w. j av a 2  s  .  c  o  m*/
public int get(int index, int vertex) {
    if (index >= size()) {
        throw new ArrayIndexOutOfBoundsException(
                "Request for invalid triangle index: " + index + " max is: " + size());
    }

    if (vertex > 2) {
        throw new ArrayIndexOutOfBoundsException("Illegal access to triangle vertex > 2: " + index);
    }

    return this.buffer.get((index * INTS_PER_ENTRY) + vertex);
}

From source file:ObjectStack.java

/**
 * Copy a value from the stack. This returns a value from within
 * the stack without modifying the stack.
 *
 * @param depth depth of value to be returned
 * @return value from stack// w ww  .  ja  v  a2s  .co m
 * @exception ArrayIndexOutOfBoundsException on attempt to peek past end of
 * stack
 */
public Object peek(int depth) {
    if (m_countPresent > depth) {
        return m_baseArray[m_countPresent - depth - 1];
    } else {
        throw new ArrayIndexOutOfBoundsException("Attempt to peek past end of stack");
    }
}

From source file:org.anarres.lzo.hadoop.codec.LzoDecompressor.java

@Override
public int decompress(byte[] b, int off, int len) throws IOException {
    if (b == null)
        throw new NullPointerException();
    if (off < 0 || len < 0 || off > b.length - len)
        throw new ArrayIndexOutOfBoundsException(
                "Illegal range in buffer: Buffer length=" + b.length + ", offset=" + off + ", length=" + len);

    // logState("Before decompress");

    len = Math.min(len, outputBufferLen.value);
    System.arraycopy(outputBuffer, outputBufferPos, b, off, len);
    outputBufferPos += len;/*  w  w  w  .j a  va  2 s . c o  m*/
    outputBufferLen.value -= len;

    return len;
}

From source file:StringStack.java

/**
 * Copy a value from the stack. This returns a value from within
 * the stack without modifying the stack.
 *
 * @param depth depth of value to be returned
 * @return value from stack//ww w  .j a va  2s.  c  o m
 * @exception ArrayIndexOutOfBoundsException on attempt to peek past end of
 * stack
 */
public String peek(int depth) {
    if (m_countPresent > depth) {
        return m_baseArray[m_countPresent - depth - 1];
    } else {
        throw new ArrayIndexOutOfBoundsException("Attempt to peek past end of stack");
    }
}

From source file:org.jboss.dashboard.dataset.AbstractDataSet.java

public List getValuesAt(int column) {
    List[] values = getPropertyValues();
    if (column < 0 || column >= values.length) {
        throw new ArrayIndexOutOfBoundsException(
                "Column out of bounds: " + column + "(must be between 0 and " + (values.length - 1) + ")");
    }// w  ww.  j  av  a  2  s . com
    return values[column];
}