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:com.marklogic.mapreduce.LargeBinaryDocument.java

@Override
public byte[] getContentAsByteArray() {
    if (size > Integer.MAX_VALUE) {
        throw new ArrayIndexOutOfBoundsException("Array size = " + size);
    }//  w w  w.  j  ava2s.  c o  m
    return getContentAsByteArray(0, (int) size);
}

From source file:burstcoin.jminer.core.checker.util.OCLChecker.java

public void initChecker(int platformId, int deviceId) {
    check();//from   www . j  a  v a2  s.c om

    setExceptionsEnabled(true);

    int numPlatforms[] = new int[1];
    clGetPlatformIDs(0, null, numPlatforms);

    if (platformId >= numPlatforms[0]) {
        throw new ArrayIndexOutOfBoundsException("Invalid platform id");
    }

    cl_platform_id platforms[] = new cl_platform_id[numPlatforms[0]];
    clGetPlatformIDs(platforms.length, platforms, null);

    int[] numDevices = new int[1];
    clGetDeviceIDs(platforms[platformId], CL_DEVICE_TYPE_ALL, 0, null, numDevices);

    if (deviceId >= numDevices[0]) {
        throw new ArrayIndexOutOfBoundsException("Invalid device id");
    }

    cl_device_id devices[] = new cl_device_id[numDevices[0]];
    clGetDeviceIDs(platforms[platformId], CL_DEVICE_TYPE_ALL, devices.length, devices, null);

    cl_context_properties contextProperties = new cl_context_properties();
    contextProperties.addProperty(CL_CONTEXT_PLATFORM, platforms[platformId]);

    context = clCreateContext(contextProperties, 1, new cl_device_id[] { devices[deviceId] }, null, null, null);
    queue = clCreateCommandQueue(context, devices[deviceId], 0, null);

    String kernelSource;
    try {
        InputStream inputStream = OCLChecker.class.getResourceAsStream("calcdeadlines.cl");
        kernelSource = readInputStreamAsString(inputStream);
        inputStream.close();
    } catch (IOException e) {
        throw new RuntimeException("Failed to read calcdeadlines.cl file", e);
    }

    program = clCreateProgramWithSource(context, 1, new String[] { kernelSource }, null, null);
    clBuildProgram(program, 0, null, "-I kernel", null, null);

    kernel[0] = clCreateKernel(program, "calculate_deadlines", null);
    kernel[1] = clCreateKernel(program, "reduce_best", null);
    kernel[2] = clCreateKernel(program, "reduce_target", null);

    long[] maxWorkGroupSize = new long[1];
    for (int i = 0; i < 3; i++) {
        clGetKernelWorkGroupInfo(kernel[i], devices[deviceId], CL_KERNEL_WORK_GROUP_SIZE, 8,
                Pointer.to(maxWorkGroupSize), null);
        workgroupSize[i] = maxWorkGroupSize[0];
    }

    long[] maxComputeUnits = new long[1];
    clGetDeviceInfo(devices[deviceId], CL_DEVICE_MAX_COMPUTE_UNITS, 8, Pointer.to(maxComputeUnits), null);

    computeUnits = maxComputeUnits[0];
    gensigMem = clCreateBuffer(context, CL_MEM_READ_ONLY, 32, null, null);
    bestMem = clCreateBuffer(context, CL_MEM_WRITE_ONLY, 400, null, null); // org 400 // tested 5000

    LOG.info("");
    LOG.info("(*) openCL context successfully started! (platformId: " + platformId + ", deviceId: " + deviceId
            + ")");
    LOG.info("-------------------------------------------------------");
}

From source file:IntList.java

/**
 * Replaces a value in this list with another value
 * /*  w ww.j  a v  a2s  . c  o  m*/
 * @param index
 *            The index of the value to replace
 * @param value
 *            The value to replace the old value with
 * @return The old value at the given index
 */
public int set(int index, int value) {
    if (index < 0 || index >= theSize)
        throw new ArrayIndexOutOfBoundsException(index);
    int ret = theValue[index];
    theValue[index] = value;
    return ret;
}

From source file:com.jabyftw.lobstercraft.util.InventoryHolder.java

/**
 * This will customize the inventory, will accept colors. This DOES NOT update existing inventory!
 *
 * @param position  item position - must be [0, size[
 * @param itemStack ItemStack of the item
 * @param itemName  item's name/*  w  w w.ja v  a  2 s.  c  o m*/
 * @param itemLore  item's lore (description-like)
 * @return this instance
 * @see org.bukkit.ChatColor#translateAlternateColorCodes(char, String)
 */
public InventoryHolder setOption(int position, @Nullable final ItemStack itemStack,
        @Nullable final String itemName, @Nullable final String... itemLore) {
    // Check for valid position
    if (position < 0 || (maximumSize != null && position > maximumSize))
        throw new ArrayIndexOutOfBoundsException("Position is invalid!");
    ItemStack correctedItemStack = setItemNameAndLore(itemStack, itemName, itemLore);

    // Update our instance
    optionIcons.set(position, correctedItemStack);
    return this;
}

From source file:de.micromata.genome.gwiki.utils.IntArray.java

public int set(int index, int element) {
    if (index < 0 || index >= length) {
        throw new ArrayIndexOutOfBoundsException(index);
    }//from  w  w w.  j  a  v a 2s.  c  om
    int prev = getInt(index);
    data[index] = element;
    return prev;
}

From source file:LongList.java

/**
 * Replaces a value in this list with another value
 * /*ww w.ja va2 s.  c o  m*/
 * @param index
 *            The index of the value to replace
 * @param value
 *            The value to replace the old value with
 * @return The old value at the given index
 */
public long set(int index, long value) {
    if (index < 0 || index >= theSize)
        throw new ArrayIndexOutOfBoundsException(index);
    long ret = theValue[index];
    theValue[index] = value;
    return ret;
}

From source file:io.nuclei.box.adapter.PagedList.java

@Override
public T get(int location) {
    if (mPageSize == 0)
        throw new ArrayIndexOutOfBoundsException("Page size is zero");
    int pageIndex = location / mPageSize;
    Integer ix = pageIndex;//w  w w .j a va 2s .c  om
    List<T> page = mPages.get(ix);
    if (page == null) {
        if (!mLoading.contains(ix)) {
            loadPage(pageIndex);
        }
        return null;
    }
    int itemIndex = location % mPageSize;
    return page.get(itemIndex);
}

From source file:net.sf.maltcms.common.charts.api.selection.category.CategoryMouseSelectionHandler.java

/**
 *
 * @param cme/* www . ja va2 s  .c o  m*/
 */
@Override
public void chartMouseClicked(ChartMouseEvent cme) {
    if (cme.getEntity() instanceof CategoryItemEntity) {
        CategoryItemEntity itemEntity = ((CategoryItemEntity) cme.getEntity());
        int seriesIndex = dataset.getRowIndex(itemEntity.getRowKey());
        int itemIndex = dataset.getColumnIndex(itemEntity.getColumnKey());
        if (seriesIndex == -1 || itemIndex == -1) {
            throw new ArrayIndexOutOfBoundsException("Could not locate series and item index for entity!");
        }
        selection = new CategorySelection(dataset, seriesIndex, itemIndex, XYSelection.Type.CLICK,
                dataset.getSource(seriesIndex), dataset.getTarget(seriesIndex, itemIndex),
                shapeFactory.createSelectionShape(itemEntity));
        selection.setName(provider.getName(selection));
        selection.setDisplayName(provider.getDisplayName(selection));
        selection.setShortDescription(provider.getShortDescription(selection));
        fireSelectionChange();
    }
}

From source file:org.apache.synapse.transport.certificatevalidation.pathvalidation.PathChecker.java

/**
 * @return the immediate issuer certificate of the current certificate which is being checked. This is tracked
 *         by the position variable//from   w  w w.j ava2 s . c o  m
 */
private X509Certificate nextIssuer() {
    //get immediate issuer
    if (position > 0)
        return certChainArray[position--];
    else
        throw new ArrayIndexOutOfBoundsException("Certificate Chain Index Out of Bounds");
}

From source file:IntList.java

/**
 * Removes a value from this list/*  w  w  w. j  a  va  2s .c o m*/
 * 
 * @param index
 *            The index of the value to remove
 * @return The value that was removed
 */
public int remove(int index) {
    if (index < 0 || index >= theSize)
        throw new ArrayIndexOutOfBoundsException(index);
    int ret = theValue[index];
    for (int i = index; i < theSize - 1; i++)
        theValue[i] = theValue[i + 1];
    theSize--;
    return ret;
}