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

Source Link

Document

Constructs an ArrayIndexOutOfBoundsException with no detail message.

Usage

From source file:com.hadoop.compression.fourmc.Lz4Compressor.java

public synchronized int compress(byte[] b, int off, int len) throws IOException {
    if (b == null) {
        throw new NullPointerException();
    }//from ww w  . j a v  a  2s.  c o m
    if (off < 0 || len < 0 || off > b.length - len) {
        throw new ArrayIndexOutOfBoundsException();
    }

    int n = compressedDirectBuf.remaining();
    if (n > 0) {
        n = Math.min(n, len);
        ((ByteBuffer) compressedDirectBuf).get(b, off, n);
        bytesWritten += n;
        return n;
    }

    compressedDirectBuf.clear();
    compressedDirectBuf.limit(0);
    if (0 == uncompressedDirectBuf.position()) {
        setInputFromSavedData();
        if (0 == uncompressedDirectBuf.position()) {
            finished = true;
            return 0;
        }
    }

    n = compressBytesDirectSpecific();
    compressedDirectBuf.limit(n);
    uncompressedDirectBuf.clear();

    if (0 == userBufLen) {
        finished = true;
    }

    n = Math.min(n, len);
    bytesWritten += n;
    ((ByteBuffer) compressedDirectBuf).get(b, off, n);

    return n;
}

From source file:net.sourceforge.processdash.data.util.ResultSet.java

/** Store an object in the result set.
 * Data rows and columns are numbered starting with 1 and ending with
 * numRows() or numCols(), respectively. */
public void setData(int row, int col, Object value) {
    if (row == 0 || col == 0)
        throw new ArrayIndexOutOfBoundsException();
    data[row][col] = value;//from  w  w  w. java2  s  . c  om
}

From source file:net.sourceforge.processdash.data.util.ResultSet.java

/** Get an object from the result set.
 * Data rows and columns are numbered starting with 1 and ending with
 * numRows() or numCols(), respectively. */
public SimpleData getData(int row, int col) {
    if (row == 0 || col == 0)
        throw new ArrayIndexOutOfBoundsException();
    Object o = data[row][col];/*ww  w.j a  va2s .  c om*/
    if (o instanceof NumberData && ((NumberData) o).isDefined())
        return new DoubleData(((NumberData) o).getDouble() * multiplier[useRowFormats ? row : col], false);
    else
        return (o instanceof SimpleData) ? (SimpleData) o : null;
}

From source file:com.gpl_compression.lzo.LzoDecompressor.java

public synchronized int decompress(byte[] b, int off, int len) throws IOException {
    if (b == null) {
        throw new NullPointerException();
    }//from w ww . j ava  2 s  .c  o m
    if (off < 0 || len < 0 || off > b.length - len) {
        throw new ArrayIndexOutOfBoundsException();
    }

    int numBytes = 0;
    if (isCurrentBlockUncompressed()) {
        // The current block has been stored uncompressed, so just
        // copy directly from the input buffer.
        numBytes = Math.min(userBufLen, len);
        System.arraycopy(userBuf, userBufOff, b, off, numBytes);
        userBufOff += numBytes;
        userBufLen -= numBytes;
    } else {
        // Check if there is uncompressed data
        numBytes = uncompressedDirectBuf.remaining();
        if (numBytes > 0) {
            numBytes = Math.min(numBytes, len);
            ((ByteBuffer) uncompressedDirectBuf).get(b, off, numBytes);
            return numBytes;
        }

        // Check if there is data to decompress
        if (compressedDirectBufLen > 0) {
            // Re-initialize the lzo's output direct-buffer
            uncompressedDirectBuf.rewind();
            uncompressedDirectBuf.limit(directBufferSize);

            // Decompress data
            numBytes = decompressBytesDirect(strategy.getDecompressor());
            uncompressedDirectBuf.limit(numBytes);

            // Return atmost 'len' bytes
            numBytes = Math.min(numBytes, len);
            ((ByteBuffer) uncompressedDirectBuf).get(b, off, numBytes);
        }
    }

    // Set 'finished' if lzo has consumed all user-data
    if (userBufLen <= 0) {
        finished = true;
    }

    return numBytes;
}

From source file:org.apache.hadoop.io.compress.lzo.LzoCompressor.java

public synchronized int compress(byte[] b, int off, int len) throws IOException {
    if (b == null) {
        throw new NullPointerException();
    }/* ww w.ja  va2 s  .  c  o  m*/
    if (off < 0 || len < 0 || off > b.length - len) {
        throw new ArrayIndexOutOfBoundsException();
    }

    // Check if there is compressed data
    int n = compressedDirectBuf.remaining();
    if (n > 0) {
        n = Math.min(n, len);
        ((ByteBuffer) compressedDirectBuf).get(b, off, n);
        byteswritten += n;
        return n;
    }

    // Re-initialize the lzo's output direct-buffer
    compressedDirectBuf.clear();
    compressedDirectBuf.limit(0);
    if (0 == uncompressedDirectBuf.position()) {
        // No compressed data, so we should have !needsInput or !finished
        setInputFromSavedData();
        if (0 == uncompressedDirectBuf.position()) {
            // Called without data; write nothing
            finished = true;
            return 0;
        }
    }

    // Compress data
    n = compressBytesDirect(strategy.getCompressor());
    compressedDirectBuf.limit(n);
    uncompressedDirectBuf.clear(); // lzo consumes all buffer input

    // Set 'finished' if lzo has consumed all user-data
    if (0 == userBufLen) {
        finished = true;
    }

    // Get atmost 'len' bytes
    n = Math.min(n, len);
    byteswritten += n;
    ((ByteBuffer) compressedDirectBuf).get(b, off, n);

    return n;
}

From source file:org.photovault.folder.PhotoFolder.java

/**
 * Returns a photo from the folder with given order number. Valid values [0..getPhotoCount[
 * @param num order number of the photo/*from  ww w.j av a 2  s  .c  o m*/
 * @return The photo with the given number
 @deprecated This is horribly inefficient after introducing FolderPhotoAssociation
 */
public PhotoInfo getPhoto(int num) {
    Set<PhotoInfo> photos = getPhotos();
    if (num >= photos.size()) {
        throw new ArrayIndexOutOfBoundsException();
    }
    return photos.toArray(new PhotoInfo[photos.size()])[num];
}

From source file:org.apache.hadoop.io.compress.zlib.ZlibCompressor.java

@Override
public void setInput(byte[] b, int off, int len) {
    if (b == null) {
        throw new NullPointerException();
    }/*from  w  ww  . jav a  2 s  .co  m*/
    if (off < 0 || len < 0 || off > b.length - len) {
        throw new ArrayIndexOutOfBoundsException();
    }

    this.userBuf = b;
    this.userBufOff = off;
    this.userBufLen = len;
    uncompressedDirectBufOff = 0;
    setInputFromSavedData();

    // Reinitialize zlib's output direct buffer 
    compressedDirectBuf.limit(directBufferSize);
    compressedDirectBuf.position(directBufferSize);
}

From source file:com.gpl_compression.lzo.LzoCompressor.java

public synchronized int compress(byte[] b, int off, int len) throws IOException {
    if (b == null) {
        throw new NullPointerException();
    }//from   w w w.  j  a  va 2s.c om
    if (off < 0 || len < 0 || off > b.length - len) {
        throw new ArrayIndexOutOfBoundsException();
    }

    // Check if there is compressed data
    int n = compressedDirectBuf.remaining();
    if (n > 0) {
        n = Math.min(n, len);
        ((ByteBuffer) compressedDirectBuf).get(b, off, n);
        bytesWritten += n;
        return n;
    }

    // Re-initialize the lzo's output direct-buffer
    compressedDirectBuf.clear();
    compressedDirectBuf.limit(0);
    if (0 == uncompressedDirectBuf.position()) {
        // No compressed data, so we should have !needsInput or !finished
        setInputFromSavedData();
        if (0 == uncompressedDirectBuf.position()) {
            // Called without data; write nothing
            finished = true;
            return 0;
        }
    }

    // Compress data
    n = compressBytesDirect(strategy.getCompressor());
    compressedDirectBuf.limit(n);
    uncompressedDirectBuf.clear(); // lzo consumes all buffer input

    // Set 'finished' if lzo has consumed all user-data
    if (0 == userBufLen) {
        finished = true;
    }

    // Get atmost 'len' bytes
    n = Math.min(n, len);
    bytesWritten += n;
    ((ByteBuffer) compressedDirectBuf).get(b, off, n);

    return n;
}

From source file:org.lockss.servlet.HashCUS.java

private boolean checkParams() {
    auid = getParameter(KEY_AUID);/* w w  w . j  a  v  a2s .  c o  m*/
    url = getParameter(KEY_URL);
    lower = getParameter(KEY_LOWER);
    upper = getParameter(KEY_UPPER);
    isRecord = (getParameter(KEY_RECORD) != null);
    alg = req.getParameter(KEY_ALG);
    if (StringUtil.isNullString(alg)) {
        alg = LcapMessage.getDefaultHashAlgorithm();
    }
    String hTypeStr = getParameter(KEY_HASH_TYPE);
    if (StringUtil.isNullString(hTypeStr)) {
        hType = DEFAULT_HASH_TYPE;
    } else if (StringUtils.isNumeric(hTypeStr)) {
        try {
            int hTypeInt = Integer.parseInt(hTypeStr);
            hType = hashTypeCompat[hTypeInt];
            if (hType == null)
                throw new ArrayIndexOutOfBoundsException();
        } catch (ArrayIndexOutOfBoundsException e) {
            errMsg = "Unknown hash type: " + hTypeStr;
            return false;
        } catch (RuntimeException e) {
            errMsg = "Can't parse hash type: " + hTypeStr;
            return false;
        }
    } else {
        try {
            hType = HashType.valueOf(hTypeStr);
        } catch (IllegalArgumentException e) {
            errMsg = "Unknown hash type: " + hTypeStr;
            return false;
        }
    }
    String resTypeStr = getParameter(KEY_RESULT_TYPE);
    if (StringUtil.isNullString(resTypeStr)) {
        resType = DEFAULT_RESULT_TYPE;
    } else {
        try {
            resType = ResultType.valueOf(resTypeStr);
        } catch (IllegalArgumentException e) {
            errMsg = "Unknown result type: " + resTypeStr;
            return false;
        }
    }
    String resEncodingStr = getParameter(KEY_RESULT_ENCODING);
    if (StringUtil.isNullString(resEncodingStr)) {
        resEncoding = DEFAULT_RESULT_ENCODING;
    } else {
        try {
            resEncoding = ResultEncoding.valueOf(resEncodingStr);
        } catch (IllegalArgumentException e) {
            errMsg = "Unknown result encoding: " + resEncodingStr;
            return false;
        }
    }
    if (auid == null) {
        errMsg = "Select an AU";
        return false;
    }
    au = pluginMgr.getAuFromId(auid);
    if (au == null) {
        errMsg = "No such AU.  Select an AU";
        return false;
    }
    if (url == null) {
        url = AuCachedUrlSetSpec.URL;
        //       errMsg = "URL required";
        //       return false;
    }
    try {
        challenge = getB64Param(KEY_CHALLENGE);
    } catch (IllegalArgumentException e) {
        errMsg = "Challenge: Illegal Base64 string: " + e.getMessage();
        return false;
    }
    try {
        verifier = getB64Param(KEY_VERIFIER);
    } catch (IllegalArgumentException e) {
        errMsg = "Verifier: Illegal Base64 string: " + e.getMessage();
        return false;
    }
    PollSpec ps;
    try {
        switch (hType) {
        case V1File:
            if (upper != null || (lower != null && !lower.equals(PollSpec.SINGLE_NODE_LWRBOUND))) {
                errMsg = "Upper/Lower ignored";
            }
            ps = new PollSpec(auid, url, PollSpec.SINGLE_NODE_LWRBOUND, null, Poll.V1_CONTENT_POLL);
            break;
        case V3Tree:

            ps = new PollSpec(auid, url, lower, upper, Poll.V3_POLL);
            break;
        case V3File:
            ps = new PollSpec(auid, url, PollSpec.SINGLE_NODE_LWRBOUND, null, Poll.V3_POLL);
            break;
        default:
            ps = new PollSpec(auid, url, lower, upper, Poll.V1_CONTENT_POLL);
        }
    } catch (Exception e) {
        errMsg = "Error making PollSpec: " + e.toString();
        log.debug("Making Pollspec", e);
        return false;
    }
    log.debug("" + ps);
    cus = ps.getCachedUrlSet();
    if (cus == null) {
        errMsg = "No such CUS: " + ps;
        return false;
    }
    log.debug("" + cus);
    return true;
}

From source file:org.apache.hadoop.io.compress.zlib.ZlibCompressor.java

@Override
public void setDictionary(byte[] b, int off, int len) {
    if (stream == 0 || b == null) {
        throw new NullPointerException();
    }/*from  ww  w .java  2  s . co  m*/
    if (off < 0 || len < 0 || off > b.length - len) {
        throw new ArrayIndexOutOfBoundsException();
    }
    setDictionary(stream, b, off, len);
}