List of usage examples for java.lang IndexOutOfBoundsException IndexOutOfBoundsException
public IndexOutOfBoundsException()
From source file:com.github.rvesse.airline.restrictions.common.NotBlankRestriction.java
@Override public String[] getContentBlock(int blockNumber) { if (blockNumber != 0) throw new IndexOutOfBoundsException(); return new String[] { "This options value cannot be blank (empty or all whitespace)" }; }
From source file:ArrayByte.java
public void setPosition(int position) throws IndexOutOfBoundsException { if (position < 0 || position > data.length) { throw new IndexOutOfBoundsException(); }//from w ww. j a v a 2s.c o m this.position = position; }
From source file:ReaderDataInput.java
public final void readFully(byte[] bytes, int off, int len) throws IOException { if (len < 0) { throw new IndexOutOfBoundsException(); }/* w w w .ja v a 2 s. c om*/ int n = 0; while (n < len) { int b = read(); if (b < 0) { throw new EOFException(); } bytes[off + n++] = (byte) b; } }
From source file:com.letv.mobile.core.rpc.http.util.ParserCursor.java
public void updatePos(int pos) { if (pos < this.lowerBound) { throw new IndexOutOfBoundsException(); }/*from ww w .java 2s . c o m*/ if (pos > this.upperBound) { throw new IndexOutOfBoundsException(); } this.pos = pos; }
From source file:ArrayByte.java
private void checkAvailable(int length) throws IndexOutOfBoundsException { if (available() < length) { throw new IndexOutOfBoundsException(); }//w w w . j a v a2 s . c o m }
From source file:com.msopentech.o365.outlookServices.ODataMethodArgs.java
/** * @param indexFromTheEnd index of Id parameter in OData path (from the end of path) * @return Id//from w ww . j ava 2 s. c om * @throws IndexOutOfBoundsException */ public String parseIdFromODataPath(int indexFromTheEnd) throws IndexOutOfBoundsException { String[] oDataPathParts = this.oDataPath.split("/"); if (indexFromTheEnd > oDataPathParts.length) { throw new IndexOutOfBoundsException(); } return oDataPathParts[oDataPathParts.length - indexFromTheEnd]; }
From source file:imgb64.BaseNCodecOutputStream.java
/** * Writes <code>len</code> bytes from the specified <code>b</code> array starting at <code>offset</code> to this * output stream./*from ww w.j a v a2s. c o m*/ * * @param b * source byte array * @param offset * where to start reading the bytes * @param len * maximum number of bytes to write * * @throws IOException * if an I/O error occurs. * @throws NullPointerException * if the byte array parameter is null * @throws IndexOutOfBoundsException * if offset, len or buffer size are invalid */ @Override public void write(final byte b[], final int offset, final int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if (offset < 0 || len < 0) { throw new IndexOutOfBoundsException(); } else if (offset > b.length || offset + len > b.length) { throw new IndexOutOfBoundsException(); } else if (len > 0) { if (doEncode) { baseNCodec.encode(b, offset, len, context); } else { baseNCodec.decode(b, offset, len, context); } flush(false); } }
From source file:MemoryByteArrayOutputStream.java
/** * Write a portion of an array of characters. * /*from ww w . j a va 2 s. c om*/ * @param cbuf * Array of characters * @param off * Offset from which to start writing characters * @param len * Number of characters to write * @throws java.io.IOException * If an I/O error occurs */ public synchronized void write(final byte[] cbuf, final int off, final int len) throws IOException { if (len < 0) { throw new IllegalArgumentException(); } if (off < 0) { throw new IndexOutOfBoundsException(); } if (cbuf == null) { throw new NullPointerException(); } if ((len + off) > cbuf.length) { throw new IndexOutOfBoundsException(); } ensureSize(cursor + len); System.arraycopy(cbuf, off, this.buffer, cursor, len); cursor += len; }
From source file:MemoryStringWriter.java
/** * Write a portion of an array of characters. * /*from w w w.j av a 2 s .co m*/ * @param cbuf * Array of characters * @param off * Offset from which to start writing characters * @param len * Number of characters to write * @throws java.io.IOException * If an I/O error occurs */ public synchronized void write(final char[] cbuf, final int off, final int len) throws IOException { if (len < 0) { throw new IllegalArgumentException(); } if (off < 0) { throw new IndexOutOfBoundsException(); } if (cbuf == null) { throw new NullPointerException(); } if ((len + off) > cbuf.length) { throw new IndexOutOfBoundsException(); } ensureSize(cursor + len); System.arraycopy(cbuf, off, this.buffer, cursor, len); cursor += len; }
From source file:fr.limsi.ARViewer.CharArrayBuffer.java
public void append(final char[] b, int off, int len) { if (b == null) { return;/*from w w w . ja v a2s.c om*/ } if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) < 0) || ((off + len) > b.length)) { throw new IndexOutOfBoundsException(); } if (len == 0) { return; } int newlen = this.len + len; if (newlen > this.buffer.length) { expand(newlen); } System.arraycopy(b, off, this.buffer, this.len, len); this.len = newlen; }