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() 

Source Link

Document

Constructs an IndexOutOfBoundsException with no detail message.

Usage

From source file:com.github.rvesse.airline.restrictions.options.RequiredOnlyIfRestriction.java

@Override
public String[] getContentBlock(int blockNumber) {
    if (blockNumber != 0)
        throw new IndexOutOfBoundsException();
    return new String[] {
            String.format("This option is required if any of the following options are specified: %s",
                    StringUtils.join(this.names, ", ")) };
}

From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.core.variable.BinaryVariable.java

/**
 * Returns the value of the bit at the specified index.
 * /*from   w  ww  .j  a v  a  2s  . c  om*/
 * @param index the index of the bit to return
 * @return the value of the bit at the specified index
 * @throws IndexOutOfBoundsException if the index is out of bounds
 *         {@code (index < 0) || (index >= getNumberOfBits())}
 */
public boolean get(int index) {
    if ((index < 0) || (index >= numberOfBits)) {
        throw new IndexOutOfBoundsException();
    }

    return bitSet.get(index);
}

From source file:com.bellman.bible.service.format.OSISInputStream.java

@Override
public int read(byte[] b, int bOffset, int lenToRead) throws IOException {
    if (b == null) {
        throw new NullPointerException();
    } else if ((bOffset < 0) || (bOffset > b.length) || (lenToRead < 0) || ((bOffset + lenToRead) > b.length)
            || ((bOffset + lenToRead) < 0)) {
        throw new IndexOutOfBoundsException();
    } else if (lenToRead == 0) {
        return 0;
    }//w ww.  j a  va  2  s  .  c o m

    int available = available();
    // have we reached the end of the chapter
    if (available == 0) {
        return -1;
    }

    int lenActuallyCopied = Math.min(available, lenToRead);

    System.arraycopy(verseBuffer, next, b, bOffset, lenActuallyCopied);
    next += lenActuallyCopied;
    return lenActuallyCopied;
}

From source file:com.github.rvesse.airline.restrictions.common.PatternRestriction.java

@Override
public String[] getContentBlock(int blockNumber) {
    if (blockNumber != 0)
        throw new IndexOutOfBoundsException();

    return new String[] { String.format("This options value must match the regular expression '%s'.  %s",
            this.pattern.toString(), StringUtils.isNotBlank(this.description) ? this.description : "") };
}

From source file:FastByteArrayOutputStream.java

public void write(byte[] data, int offset, int length) throws IOException {
    if (data == null) {
        throw new NullPointerException();
    } else if ((offset < 0) || ((offset + length) > data.length) || (length < 0)) {
        throw new IndexOutOfBoundsException();
    } else if (closed) {
        throw new IOException("Stream closed");
    } else {//from   w w  w  .j av a  2 s . com
        if ((index + length) > blockSize) {
            int copyLength;

            do {
                if (index == blockSize) {
                    addBuffer();
                }

                copyLength = blockSize - index;

                if (length < copyLength) {
                    copyLength = length;
                }

                System.arraycopy(data, offset, buffer, index, copyLength);
                offset += copyLength;
                index += copyLength;
                length -= copyLength;
            } while (length > 0);
        } else {
            // Copy in the subarray
            System.arraycopy(data, offset, buffer, index, length);
            index += length;
        }
    }
}

From source file:com.evolveum.midpoint.prism.xjc.AnyArrayList.java

@Override
public Object get(int index) {
    if (isSchemaless()) {
        return containerValue.getRawElements().get(index);
    } else {/*from  ww w .  jav a  2  s .  c  o  m*/
        if (containerValue != null) {
            for (Item<?, ?> item : containerValue.getItems()) {
                if (index < item.getValues().size()) {
                    return asElement(item.getValue(index));
                } else {
                    index -= item.getValues().size();
                }
            }
            throw new IndexOutOfBoundsException();
        }
        return null; //TODO: is this OK??
    }
}

From source file:com.asakusafw.runtime.flow.FileMapListBuffer.java

@Override
public E get(int index) {
    if (index >= size) {
        throw new IndexOutOfBoundsException();
    }/*ww  w .j av a2  s . c o  m*/
    restorePage(index);
    return pageBuffer[getOffsetInPage(index)];
}

From source file:fr.inria.atlanmod.neoemf.graph.blueprints.datastore.estores.impl.DirectWriteBlueprintsResourceEStoreImpl.java

protected Object get(InternalEObject object, EAttribute eAttribute, int index) {
    Vertex vertex = graph.getVertex(object);
    if (!eAttribute.isMany()) {
        Object property = vertex.getProperty(eAttribute.getName());
        return parseProperty(eAttribute, property);
    } else {// w w  w  . jav a2  s  . c  o  m
        Integer size = getSize(vertex, eAttribute);
        if (index < 0 || index >= size) {
            throw new IndexOutOfBoundsException();
        } else {
            Object property = vertex.getProperty(eAttribute.getName() + SEPARATOR + index);
            return parseProperty(eAttribute, property);
        }
    }
}

From source file:org.talend.dataprep.command.GenericCommandTestService.java

@ApiOperation("Execute an operation")
@RequestMapping(value = "/command/test/unexpected", method = RequestMethod.GET, consumes = MediaType.ALL_VALUE, produces = MediaType.TEXT_PLAIN_VALUE)
public void fail_with_unexpected() {
    throw new IndexOutOfBoundsException();
}

From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.core.variable.BinaryVariable.java

/**
 * Sets the value of the bit at the specified index.
 * //  ww  w .jav a2  s  .c o m
 * @param index the index of the bit to set
 * @param value the new value of the bit being set
 * @throws IndexOutOfBoundsException if the index is out of bounds
 *         {@code (index < 0) || (index >= getNumberOfBits())}
 */
public void set(int index, boolean value) {
    if ((index < 0) || (index >= numberOfBits)) {
        throw new IndexOutOfBoundsException();
    }

    bitSet.set(index, value);
}