List of usage examples for java.lang ArrayIndexOutOfBoundsException ArrayIndexOutOfBoundsException
public ArrayIndexOutOfBoundsException()
From source file:fi.johannes.kata.ocr.cells.Cell.java
public char swapChar(int pos, char c) throws ArrayIndexOutOfBoundsException { char original; altered = true;/* w w w. j av a2 s. c o m*/ copyOfContent = new StringBuilder(cellContent.toString()); try { original = cellContent.charAt(pos); cellContent.setCharAt(pos, c); return original; } catch (Exception e) { ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException = new ArrayIndexOutOfBoundsException(); AppLogging.logMessageWithExpection_Error(this.getClass(), ApplicationStrings.LoggingMessages.Error.CELL_SWAP_AT_INVALID_INDEX, arrayIndexOutOfBoundsException); throw arrayIndexOutOfBoundsException; } }
From source file:openlr.binary.ByteArray.java
/** * Gets the byte at position pos.// w w w. j a va2s.com * * @param pos * the position * * @return the byte at position pos */ public final byte get(final int pos) { if (pos < 0 || pos > bytes.length - 1) { throw new ArrayIndexOutOfBoundsException(); } return bytes[pos]; }
From source file:org.apache.hadoop.io.compress.lzma.LzmaDecompressor.java
public synchronized void setInput(byte[] b, int off, int len) { if (b == null) { throw new NullPointerException(); }//from ww w.java2 s . c o m if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } this.userBuf = b; this.userBufOff = off; this.userBufLen = len; setInputFromSavedData(); // Reinitialize lzma's output direct buffer uncompressedDirectBuf.limit(directBufferSize); uncompressedDirectBuf.position(directBufferSize); }
From source file:dataform.sql.query.DefaultTable.java
/** * Use this class to build a Combobox based on a foreign key. * //www .ja v a 2s. c o m * @param columnIndex the column to keep when cloning. NOTE : The key flag is removed from this column * @return a copy of the current class, with all but the given column and it's keys. */ public Table cloneKeysAndColumn(int columnIndex) throws Exception { if (columnIndex > getColumnCount()) throw new ArrayIndexOutOfBoundsException(); Table table = Globals.getGlobals().getDBManager().getTableInstance(); table.setTableName(getTableName()); for (int x = 0; x < getColumnCount(); x++) { if (x == columnIndex) { // The cloning will remove the key flag from the to be kept column table.addColumn(new Column(getColumn(x).getColumnName(), getColumn(x).getColumnDescription() == null ? "" : getColumn(x).getColumnDescription(), false, getColumn(x).getSQLColumnType())); } else if (getColumn(x).isKeyColumn()) { table.addColumn(getColumn(x)); } } table.replaceWhereClause(getWhereClause()); return table; }
From source file:org.apache.hadoop.io.crypto.aes.AESEncryptor.java
/** * Sets input data for compression. This should be called whenever * #needsInput() returns <code>true</code> indicating that more input data is * required./* ww w .j av a 2 s .com*/ * * @param b Input data * @param off Start offset * @param len Length */ @Override public synchronized void setInput(byte[] b, int off, int len) { if (b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } if (len == 0) { return; } allInputProcessed = false; if (len > uncompressedDirectBuf.remaining()) { // save data; now !needsInput this.userBuf = b; this.userBufOff = off; this.userBufLen = len; } else { ((ByteBuffer) uncompressedDirectBuf).put(b, off, len); uncompressedDirectBufLen = uncompressedDirectBuf.position(); } bytesRead += len; }
From source file:takatuka.classreader.dataObjs.ControllerBase.java
public void add(int index, Object obj) throws Exception { if (objs.size() >= size && size != -1) { //-1 is infinity throw new ArrayIndexOutOfBoundsException(); }//w ww .j a v a2 s . c o m if (allowedType(obj)) { throw new Exception("Invalid Class exception "); } validate(); //overwrite validate function to add other validations. objs.add(index, obj); }
From source file:com.john.main.Utils.java
static float[] copyOfRange(float[] original, int start, int end) { if (start > end) { throw new IllegalArgumentException(); }//from ww w . j a va 2 s. c o m int originalLength = original.length; if (start < 0 || start > originalLength) { throw new ArrayIndexOutOfBoundsException(); } int resultLength = end - start; int copyLength = Math.min(resultLength, originalLength - start); float[] result = new float[resultLength]; System.arraycopy(original, start, result, 0, copyLength); return result; }
From source file:org.apache.hadoop.io.compress.lz4.Lz4Decompressor.java
/** * Sets input data for decompression.//from w ww. j av a 2s . co m * This should be called if and only if {@link #needsInput()} returns * <code>true</code> indicating that more input data is required. * (Both native and non-native versions of various Decompressors require * that the data passed in via <code>b[]</code> remain unmodified until * the caller is explicitly notified--via {@link #needsInput()}--that the * buffer may be safely modified. With this requirement, an extra * buffer-copy can be avoided.) * * @param b Input data * @param off Start offset * @param len Length */ @Override public synchronized void setInput(byte[] b, int off, int len) { if (b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } this.userBuf = b; this.userBufOff = off; this.userBufLen = len; setInputFromSavedData(); // Reinitialize lz4's output direct-buffer uncompressedDirectBuf.limit(directBufferSize); uncompressedDirectBuf.position(directBufferSize); }
From source file:org.apache.hadoop.io.compress.snappy.SnappyDecompressor.java
/** * Sets input data for decompression.//from w w w . j a v a 2s . c o m * This should be called if and only if {@link #needsInput()} returns * <code>true</code> indicating that more input data is required. * (Both native and non-native versions of various Decompressors require * that the data passed in via <code>b[]</code> remain unmodified until * the caller is explicitly notified--via {@link #needsInput()}--that the * buffer may be safely modified. With this requirement, an extra * buffer-copy can be avoided.) * * @param b Input data * @param off Start offset * @param len Length */ @Override public synchronized void setInput(byte[] b, int off, int len) { if (b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } this.userBuf = b; this.userBufOff = off; this.userBufLen = len; setInputFromSavedData(); // Reinitialize snappy's output direct-buffer uncompressedDirectBuf.limit(directBufferSize); uncompressedDirectBuf.position(directBufferSize); }
From source file:org.apache.hadoop.io.crypto.aes.AESDecryptor.java
/** * Sets input data for decompression. This should be called if and only if * {@link #needsInput()} returns <code>true</code> indicating that more input * data is required. (Both native and non-native versions of various * Decompressors require that the data passed in via <code>b[]</code> remain * unmodified until the caller is explicitly notified--via * {@link #needsInput()}--that the buffer may be safely modified. With this * requirement, an extra buffer-copy can be avoided.) * /*from w w w .j a v a 2 s .co m*/ * @param b Input data * @param off Start offset * @param len Length */ @Override public synchronized void setInput(byte[] b, int off, int len) { if (b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } this.userBuf = b; this.userBufOff = off; this.userBufLen = len; setInputFromSavedData(); // Reinitialize snappy's output direct-buffer uncompressedDirectBuf.limit(directBufferSize - AESConstants.AES_BLOCK_SIZE); uncompressedDirectBuf.position(directBufferSize - AESConstants.AES_BLOCK_SIZE); }