java.lang.IndexOutOfBoundsException
IndexOutOfBoundsException is described in the javadoc comments as:
Thrown to indicate that an index of some sort (such as to an array, to a string, or to a vector) is out of range.Applications can subclass this class to indicate similar exceptions.
author: Frank Yellin version: 1.11, 12/19/03 since: JDK1.0
Where is this exception thrown?
Following, is a list of exception messages cross-referenced to the source code responsible for throwing them. Click on the method link to view the code and see how the exception is thrown.
- The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
com.sun.imageio.plugins.gif.GIFImageReader.getHeight(int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
com.sun.imageio.plugins.gif.GIFImageReader.getImageTypes(int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
com.sun.imageio.plugins.gif.GIFImageReader.getWidth(int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
com.sun.imageio.plugins.jpeg.JPEGImageReader.skipImage() - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
com.sun.jmx.snmp.agent.SnmpMib.add(int, long) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
com.sun.jmx.snmp.agent.SnmpMib.add(int, long[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.BufferedInputStream.read(byte, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.BufferedReader.read(char, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.BufferedWriter.write(char, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.ByteArrayInputStream.read(byte, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.ByteArrayOutputStream.write(byte, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.CharArrayReader.read(char, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.CharArrayWriter.write(char, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.DataInputStream.readFully(byte, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.FilterOutputStream.write(byte, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.InputStream.read(byte, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.LineNumberInputStream.read(byte, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.ObjectInputStream.read(byte[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.ObjectInputStream.readFully(byte[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.ObjectOutputStream.write(byte[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.OutputStream.write(byte, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.PipedInputStream.read(byte, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.PipedOutputStream.write(byte, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.PipedReader.read(char, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.PipedWriter.write(char, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.PushbackInputStream.read(byte[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.PushbackReader.read(char, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.SequenceInputStream.read(byte, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.StringBufferInputStream.read(byte, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.StringReader.read(char, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.io.StringWriter.write(char, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.lang.AbstractStringBuilder.codePointCount(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.lang.AbstractStringBuilder.offsetByCodePoints(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.lang.Character.codePointAt(char[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.lang.Character.codePointBefore(char[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.lang.Character.codePointCount(CharSequence, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.lang.Character.codePointCount(char[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.lang.Character.offsetByCodePoints(CharSequence, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.lang.Character.offsetByCodePoints(char[], int, int, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.lang.Character.offsetByCodePointsImpl(char[], int, int, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.lang.String.codePointCount(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.lang.String.offsetByCodePoints(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.Buffer.checkBounds(int, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.Buffer.checkIndex(int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.Buffer.checkIndex(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.ByteBuffer.wrap(byte[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.ByteBufferAsCharBufferB.subSequence(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.ByteBufferAsCharBufferB.toString(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.ByteBufferAsCharBufferL.subSequence(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.ByteBufferAsCharBufferL.toString(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.ByteBufferAsCharBufferRB.subSequence(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.ByteBufferAsCharBufferRB.toString(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.ByteBufferAsCharBufferRL.subSequence(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.ByteBufferAsCharBufferRL.toString(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.CharBuffer.wrap(CharSequence, int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.CharBuffer.wrap(char[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.DirectCharBufferRS.subSequence(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.DirectCharBufferRS.toString(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.DirectCharBufferRU.subSequence(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.DirectCharBufferRU.toString(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.DirectCharBufferS.subSequence(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.DirectCharBufferS.toString(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.DirectCharBufferU.subSequence(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.DirectCharBufferU.toString(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.DoubleBuffer.wrap(double[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.FloatBuffer.wrap(float[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.HeapCharBuffer.subSequence(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.HeapCharBuffer.toString(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.HeapCharBufferR.subSequence(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.HeapCharBufferR.toString(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.IntBuffer.wrap(int[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.LongBuffer.wrap(long[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.ShortBuffer.wrap(short[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.StringCharBuffer.subSequence(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.nio.channels.Channels.newOutputStream(WritableByteChannel) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.util.AbstractList.add(int, E) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.util.concurrent.CopyOnWriteArrayList.removeRange(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.util.concurrent.CopyOnWriteArrayList.subList(int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.util.zip.DeflaterOutputStream.write(byte[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.util.zip.InflaterInputStream.read(byte[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.util.zip.ZipInputStream.read(byte[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
java.util.zip.ZipOutputStream.write(byte[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
javax.imageio.stream.FileCacheImageInputStream.read(byte[], int, int) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
javax.imageio.stream.FileCacheImageOutputStream.seek(long) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
javax.imageio.stream.MemoryCache.read(byte[], int, int, long) - The message 'java.lang.IndexOutOfBoundsException: ' is thrown within the method:
javax.imageio.stream.MemoryCache.write(byte[], int, int, long) - The message 'java.lang.IndexOutOfBoundsException: ...' is thrown within the method:
com.sun.jmx.remote.internal.ArrayQueue.get(int) - The message 'java.lang.IndexOutOfBoundsException: ... >= ...' is thrown within the method:
java.util.Vector.lastIndexOf(Object, int) - The message 'java.lang.IndexOutOfBoundsException: ... BMPImageReader0 ...' is thrown within the method:
com.sun.imageio.plugins.bmp.BMPImageReader.checkIndex(int) - The message 'java.lang.IndexOutOfBoundsException: ... WBMPImageReader0 ...' is thrown within the method:
com.sun.imageio.plugins.wbmp.WBMPImageReader.checkIndex(int) - The message 'java.lang.IndexOutOfBoundsException: Argument out of cache' is thrown within the method:
javax.imageio.stream.MemoryCache.writeToStream(OutputStream, long, long) - The message 'java.lang.IndexOutOfBoundsException: Attempt to read past end of image sequence!' is thrown within the method:
com.sun.imageio.plugins.gif.GIFImageReader.readMetadata() - The message 'java.lang.IndexOutOfBoundsException: Bad image index!' is thrown within the method:
com.sun.imageio.plugins.gif.GIFImageReader.getImageMetadata(int) - The message 'java.lang.IndexOutOfBoundsException: Decoded length exceeds buffer' is thrown within the method:
com.sun.jmx.snmp.BerDecoder.fetchAny() - The message 'java.lang.IndexOutOfBoundsException: Decoded length exceeds buffer' is thrown within the method:
com.sun.jmx.snmp.BerDecoder.fetchIntegerValue() - The message 'java.lang.IndexOutOfBoundsException: Decoded length exceeds buffer' is thrown within the method:
com.sun.jmx.snmp.BerDecoder.fetchIntegerValueAsLong() - The message 'java.lang.IndexOutOfBoundsException: Decoded length exceeds buffer' is thrown within the method:
com.sun.jmx.snmp.BerDecoder.fetchOidValue() - The message 'java.lang.IndexOutOfBoundsException: Decoded length exceeds buffer' is thrown within the method:
com.sun.jmx.snmp.BerDecoder.fetchStringValue() - The message 'java.lang.IndexOutOfBoundsException: Illegal start index' is thrown within the method:
java.util.regex.Matcher.find(int) - The message 'java.lang.IndexOutOfBoundsException: Index: ...' is thrown within the method:
java.util.AbstractList.listIterator(int) - The message 'java.lang.IndexOutOfBoundsException: Index: ...' is thrown within the method:
java.util.concurrent.CopyOnWriteArrayList.listIterator(int) - The message 'java.lang.IndexOutOfBoundsException: Index: ... , Size: ...' is thrown within the method:
java.util.AbstractList.addAll(int, Collection<? extends E>) - The message 'java.lang.IndexOutOfBoundsException: Index: ... , Size: ...' is thrown within the method:
java.util.AbstractList.listIterator(int) - The message 'java.lang.IndexOutOfBoundsException: Index: ... , Size: ...' is thrown within the method:
java.util.ArrayList.RangeCheck(int) - The message 'java.lang.IndexOutOfBoundsException: Index: ... , Size: ...' is thrown within the method:
java.util.ArrayList.add(int, E) - The message 'java.lang.IndexOutOfBoundsException: Index: ... , Size: ...' is thrown within the method:
java.util.ArrayList.addAll(int, Collection<? extends E>) - The message 'java.lang.IndexOutOfBoundsException: Index: ... , Size: ...' is thrown within the method:
java.util.LinkedList.addAll(int, Collection<? extends E>) - The message 'java.lang.IndexOutOfBoundsException: Index: ... , Size: ...' is thrown within the method:
java.util.LinkedList.entry(int) - The message 'java.lang.IndexOutOfBoundsException: Index: ... , Size: ...' is thrown within the method:
java.util.concurrent.CopyOnWriteArrayList.add(int, E) - The message 'java.lang.IndexOutOfBoundsException: Index: ... , Size: ...' is thrown within the method:
java.util.concurrent.CopyOnWriteArrayList.addAll(int, Collection<? extends E>) - The message 'java.lang.IndexOutOfBoundsException: Index: ... , Size: ...' is thrown within the method:
java.util.concurrent.CopyOnWriteArrayList.rangeCheck(int, int) - The message 'java.lang.IndexOutOfBoundsException: Index: ... , Tab count: ...' is thrown within the method:
javax.swing.JTabbedPane.checkIndex(int) - The message 'java.lang.IndexOutOfBoundsException: Index: ... ,Size: ...' is thrown within the method:
java.util.AbstractList.rangeCheck(int) - The message 'java.lang.IndexOutOfBoundsException: Negative pos or len' is thrown within the method:
javax.imageio.stream.MemoryCache.writeToStream(OutputStream, long, long) - The message 'java.lang.IndexOutOfBoundsException: No group ...' is thrown within the method:
java.util.regex.Matcher.end(int) - The message 'java.lang.IndexOutOfBoundsException: No group ...' is thrown within the method:
java.util.regex.Matcher.group(int) - The message 'java.lang.IndexOutOfBoundsException: No group ...' is thrown within the method:
java.util.regex.Matcher.start(int) - The message 'java.lang.IndexOutOfBoundsException: No such thumbnail' is thrown within the method:
com.sun.imageio.plugins.jpeg.JPEGImageReader.getThumbnailHeight(int, int) - The message 'java.lang.IndexOutOfBoundsException: No such thumbnail' is thrown within the method:
com.sun.imageio.plugins.jpeg.JPEGImageReader.getThumbnailWidth(int, int) - The message 'java.lang.IndexOutOfBoundsException: No such thumbnail' is thrown within the method:
com.sun.imageio.plugins.jpeg.JPEGImageReader.readThumbnail(int, int) - The message 'java.lang.IndexOutOfBoundsException: No thumbnails available!' is thrown within the method:
javax.imageio.IIOImage.getThumbnail(int) - The message 'java.lang.IndexOutOfBoundsException: Posn: ... , Size: ...' is thrown within the method:
javax.naming.ldap.LdapName.getPrefix(int) - The message 'java.lang.IndexOutOfBoundsException: Posn: ... , Size: ...' is thrown within the method:
javax.naming.ldap.LdapName.getSuffix(int) - The message 'java.lang.IndexOutOfBoundsException: Queue empty' is thrown within the method:
com.sun.jmx.remote.internal.ArrayQueue.remove(int) - The message 'java.lang.IndexOutOfBoundsException: Queue full' is thrown within the method:
com.sun.jmx.remote.internal.ArrayQueue.add(T) - The message 'java.lang.IndexOutOfBoundsException: Resizing would lose data' is thrown within the method:
com.sun.jmx.remote.internal.ArrayQueue.resize(int) - The message 'java.lang.IndexOutOfBoundsException: Source does not fit in dest' is thrown within the method:
java.util.Collections.copy(List<? super T>, List<? extends T>) - The message 'java.lang.IndexOutOfBoundsException: beginIndex: ...' is thrown within the method:
java.awt.Font.getStringBounds(CharacterIterator, int, int, FontRenderContext) - The message 'java.lang.IndexOutOfBoundsException: beginIndex: ...' is thrown within the method:
java.awt.Font.getStringBounds(char[], int, int, FontRenderContext) - The message 'java.lang.IndexOutOfBoundsException: bitIndex < 0: ...' is thrown within the method:
java.util.BitSet.clear(int) - The message 'java.lang.IndexOutOfBoundsException: bitIndex < 0: ...' is thrown within the method:
java.util.BitSet.flip(int) - The message 'java.lang.IndexOutOfBoundsException: bitIndex < 0: ...' is thrown within the method:
java.util.BitSet.get(int) - The message 'java.lang.IndexOutOfBoundsException: bitIndex < 0: ...' is thrown within the method:
java.util.BitSet.set(int) - The message 'java.lang.IndexOutOfBoundsException: dstOffset ...' is thrown within the method:
java.lang.AbstractStringBuilder.insert(int, CharSequence, int, int) - The message 'java.lang.IndexOutOfBoundsException: end' is thrown within the method:
java.util.regex.Matcher.region(int, int) - The message 'java.lang.IndexOutOfBoundsException: fromIndex < 0: ...' is thrown within the method:
java.util.BitSet.clear(int, int) - The message 'java.lang.IndexOutOfBoundsException: fromIndex < 0: ...' is thrown within the method:
java.util.BitSet.flip(int, int) - The message 'java.lang.IndexOutOfBoundsException: fromIndex < 0: ...' is thrown within the method:
java.util.BitSet.get(int, int) - The message 'java.lang.IndexOutOfBoundsException: fromIndex < 0: ...' is thrown within the method:
java.util.BitSet.nextClearBit(int) - The message 'java.lang.IndexOutOfBoundsException: fromIndex < 0: ...' is thrown within the method:
java.util.BitSet.nextSetBit(int) - The message 'java.lang.IndexOutOfBoundsException: fromIndex < 0: ...' is thrown within the method:
java.util.BitSet.set(int, int) - The message 'java.lang.IndexOutOfBoundsException: fromIndex: ... > toIndex: ...' is thrown within the method:
java.util.BitSet.clear(int, int) - The message 'java.lang.IndexOutOfBoundsException: fromIndex: ... > toIndex: ...' is thrown within the method:
java.util.BitSet.flip(int, int) - The message 'java.lang.IndexOutOfBoundsException: fromIndex: ... > toIndex: ...' is thrown within the method:
java.util.BitSet.get(int, int) - The message 'java.lang.IndexOutOfBoundsException: fromIndex: ... > toIndex: ...' is thrown within the method:
java.util.BitSet.set(int, int) - The message 'java.lang.IndexOutOfBoundsException: imageIndex != 0!' is thrown within the method:
com.sun.imageio.plugins.png.PNGImageReader.getImageMetadata(int) - The message 'java.lang.IndexOutOfBoundsException: imageIndex != 0!' is thrown within the method:
com.sun.imageio.plugins.png.PNGImageReader.getImageTypes(int) - The message 'java.lang.IndexOutOfBoundsException: imageIndex != 0!' is thrown within the method:
com.sun.imageio.plugins.png.PNGImageReader.read(int, ImageReadParam) - The message 'java.lang.IndexOutOfBoundsException: imageIndex < getMinIndex()!' is thrown within the method:
javax.imageio.ImageReader.readAll(int, ImageReadParam) - The message 'java.lang.IndexOutOfBoundsException: imageIndex < minIndex!' is thrown within the method:
com.sun.imageio.plugins.gif.GIFImageReader.checkIndex(int) - The message 'java.lang.IndexOutOfBoundsException: imageIndex out of bounds!' is thrown within the method:
com.sun.imageio.plugins.gif.GIFImageReader.read(int, ImageReadParam) - The message 'java.lang.IndexOutOfBoundsException: index ...' is thrown within the method:
java.util.concurrent.atomic.AtomicIntegerArray.rawIndex(int) - The message 'java.lang.IndexOutOfBoundsException: index ...' is thrown within the method:
java.util.concurrent.atomic.AtomicLongArray.rawIndex(int) - The message 'java.lang.IndexOutOfBoundsException: index ...' is thrown within the method:
java.util.concurrent.atomic.AtomicReferenceArray.rawIndex(int) - The message 'java.lang.IndexOutOfBoundsException: len < 0!' is thrown within the method:
javax.imageio.stream.ImageInputStreamImpl.readBytes(IIOByteBuffer, int) - The message 'java.lang.IndexOutOfBoundsException: length out of bounds: ...' is thrown within the method:
javax.sound.midi.MidiMessage.setMessage(byte[], int) - The message 'java.lang.IndexOutOfBoundsException: length out of bounds: ...' is thrown within the method:
javax.sound.midi.SysexMessage.setMessage(int, byte[], int) - The message 'java.lang.IndexOutOfBoundsException: limit: ...' is thrown within the method:
java.awt.Font.getStringBounds(CharacterIterator, int, int, FontRenderContext) - The message 'java.lang.IndexOutOfBoundsException: limit: ...' is thrown within the method:
java.awt.Font.getStringBounds(char[], int, int, FontRenderContext) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> b.length!' is thrown within the method:
javax.imageio.stream.ImageInputStreamImpl.readFully(byte[], int, int) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> b.length!' is thrown within the method:
javax.imageio.stream.MemoryCacheImageInputStream.read(byte[], int, int) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> b.length!' is thrown within the method:
javax.imageio.stream.MemoryCacheImageOutputStream.read(byte[], int, int) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> c.length!' is thrown within the method:
javax.imageio.stream.ImageInputStreamImpl.readFully(char[], int, int) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> c.length!' is thrown within the method:
javax.imageio.stream.ImageOutputStreamImpl.writeChars(char[], int, int) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> d.length!' is thrown within the method:
javax.imageio.stream.ImageInputStreamImpl.readFully(double[], int, int) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> d.length!' is thrown within the method:
javax.imageio.stream.ImageOutputStreamImpl.writeDoubles(double[], int, int) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> f.length!' is thrown within the method:
javax.imageio.stream.ImageInputStreamImpl.readFully(float[], int, int) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> f.length!' is thrown within the method:
javax.imageio.stream.ImageOutputStreamImpl.writeFloats(float[], int, int) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> i.length!' is thrown within the method:
javax.imageio.stream.ImageInputStreamImpl.readFully(int[], int, int) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> i.length!' is thrown within the method:
javax.imageio.stream.ImageOutputStreamImpl.writeInts(int[], int, int) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> l.length!' is thrown within the method:
javax.imageio.stream.ImageInputStreamImpl.readFully(long[], int, int) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> l.length!' is thrown within the method:
javax.imageio.stream.ImageOutputStreamImpl.writeLongs(long[], int, int) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> s.length!' is thrown within the method:
javax.imageio.stream.ImageInputStreamImpl.readFully(short[], int, int) - The message 'java.lang.IndexOutOfBoundsException: off < 0 || len < 0 || off + len> s.length!' is thrown within the method:
javax.imageio.stream.ImageOutputStreamImpl.writeShorts(short[], int, int) - The message 'java.lang.IndexOutOfBoundsException: pos < flushedPos!' is thrown within the method:
javax.imageio.stream.FileImageInputStream.seek(long) - The message 'java.lang.IndexOutOfBoundsException: pos < flushedPos!' is thrown within the method:
javax.imageio.stream.FileImageOutputStream.seek(long) - The message 'java.lang.IndexOutOfBoundsException: pos < flushedPos!' is thrown within the method:
javax.imageio.stream.ImageInputStreamImpl.flushBefore(long) - The message 'java.lang.IndexOutOfBoundsException: pos < flushedPos!' is thrown within the method:
javax.imageio.stream.ImageInputStreamImpl.seek(long) - The message 'java.lang.IndexOutOfBoundsException: pos > getStreamPosition()!' is thrown within the method:
javax.imageio.stream.ImageInputStreamImpl.flushBefore(long) - The message 'java.lang.IndexOutOfBoundsException: pos already disposed' is thrown within the method:
javax.imageio.stream.MemoryCache.disposeBefore(long) - The message 'java.lang.IndexOutOfBoundsException: pos already disposed' is thrown within the method:
javax.imageio.stream.MemoryCache.writeToStream(OutputStream, long, long) - The message 'java.lang.IndexOutOfBoundsException: range length: ...' is thrown within the method:
java.awt.Font.getStringBounds(CharacterIterator, int, int, FontRenderContext) - The message 'java.lang.IndexOutOfBoundsException: range length: ...' is thrown within the method:
java.awt.Font.getStringBounds(char[], int, int, FontRenderContext) - The message 'java.lang.IndexOutOfBoundsException: start' is thrown within the method:
java.util.regex.Matcher.region(int, int) - The message 'java.lang.IndexOutOfBoundsException: start ... , end ... , s.length() ...' is thrown within the method:
java.lang.AbstractStringBuilder.append(CharSequence, int, int) - The message 'java.lang.IndexOutOfBoundsException: start ... , end ... , s.length() ...' is thrown within the method:
java.lang.AbstractStringBuilder.insert(int, CharSequence, int, int) - The message 'java.lang.IndexOutOfBoundsException: start > end' is thrown within the method:
java.util.regex.Matcher.region(int, int) - The message 'java.lang.IndexOutOfBoundsException: toIndex < 0: ...' is thrown within the method:
java.util.BitSet.clear(int, int) - The message 'java.lang.IndexOutOfBoundsException: toIndex < 0: ...' is thrown within the method:
java.util.BitSet.flip(int, int) - The message 'java.lang.IndexOutOfBoundsException: toIndex < 0: ...' is thrown within the method:
java.util.BitSet.get(int, int) - The message 'java.lang.IndexOutOfBoundsException: toIndex < 0: ...' is thrown within the method:
java.util.BitSet.set(int, int)
How is this exception thrown?
The following sub-sections identify where this exception is thrown, and how (or why) the code is throwing the exception.
Any source code quoted in this section is subject to the Java Research License unless stated otherwise.
com.sun.imageio.plugins.gif.GIFImageReader.getHeight(int)
public int getHeight(int imageIndex) throws IIOException { checkIndex(imageIndex); int index = locateImage(imageIndex); if (index != imageIndex) { throw new IndexOutOfBoundsException(); } readMetadata(); return imageMetadata.imageHeight; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.gif.GIFImageReader.getImageTypes(int)
public Iterator getImageTypes(int imageIndex) throws IIOException { checkIndex(imageIndex); int index = locateImage(imageIndex); if (index != imageIndex) { throw new IndexOutOfBoundsException(); } readMetadata(); List l = new ArrayList(1); byte[] colorTable; if (imageMetadata.localColorTable != null) { colorTable = imageMetadata.localColorTable; } else { colorTable = streamMetadata.globalColorTable; } int length = colorTable.length / 3; int bits; if (length == 2) { bits = 1; } else if (length == 4) { bits = 2; } else if (length == 8 || length == 16) { bits = 4; } else { bits = 8; } int lutLength = 1 << bits; byte[] r = new byte[lutLength]; byte[] g = new byte[lutLength]; byte[] b = new byte[lutLength]; int rgbIndex = 0; for (int i = 0; i < length; i++) { r[i] = colorTable[rgbIndex++]; g[i] = colorTable[rgbIndex++]; b[i] = colorTable[rgbIndex++]; } byte[] a = null; if (imageMetadata.transparentColorFlag) { a = new byte[lutLength]; Arrays.fill(a, (byte) 255); int idx = Math.min(imageMetadata.transparentColorIndex, lutLength - 1); a[idx] = (byte) 0; } int[] bitsPerSample = new int[1]; bitsPerSample[0] = bits; l.add(ImageTypeSpecifier.createIndexed(r, g, b, a, bits, DataBuffer.TYPE_BYTE)); return l.iterator(); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.gif.GIFImageReader.getWidth(int)
public int getWidth(int imageIndex) throws IIOException { checkIndex(imageIndex); int index = locateImage(imageIndex); if (index != imageIndex) { throw new IndexOutOfBoundsException(); } readMetadata(); return imageMetadata.imageWidth; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.jpeg.JPEGImageReader.gotoImage(int)
/** * Sets the input stream to the start of the requested image. * @exception IllegalStateException if the input source has not been * set. * @exception IndexOutOfBoundsException if the supplied index is * out of bounds. */ private void gotoImage(int imageIndex) throws IOException { if (iis == null) { throw new IllegalStateException('Input not set'); } if (imageIndex < minIndex) { throw new IndexOutOfBoundsException(); } if (!tablesOnlyChecked) { checkTablesOnly(); } if (imageIndex < imagePositions.size()) { iis.seek(((Long) (imagePositions.get(imageIndex))).longValue()); } else { Long pos = (Long) imagePositions.get(imagePositions.size() - 1); iis.seek(pos.longValue()); skipImage(); for (int index = imagePositions.size(); index <= imageIndex; index++) { if (!hasNextImage()) { throw new IndexOutOfBoundsException(); } pos = new Long(iis.getStreamPosition()); imagePositions.add(pos); if (seekForwardOnly) { iis.flushBefore(pos.longValue()); } if (index < imageIndex) { skipImage(); } } } if (seekForwardOnly) { minIndex = imageIndex; } haveSeeked = true; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.jpeg.JPEGImageReader.skipImage()
/** * Skip over a complete image in the stream, leaving the stream * positioned such that the next byte to be read is the first * byte of the next image. For JPEG, this means that we read * until we encounter an EOI marker or until the end of the stream. * If the stream ends before an EOI marker is encountered, an * IndexOutOfBoundsException is thrown. */ private void skipImage() throws IOException { if (debug) { System.out.println('skipImage called'); } boolean foundFF = false; for (int byteval = iis.read(); byteval != -1; byteval = iis.read()) { if (foundFF == true) { if (byteval == JPEG.EOI) { return; } } foundFF = (byteval == 0xff) ? true : false; } throw new IndexOutOfBoundsException(); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.jmx.snmp.agent.SnmpMib.add(int, long)
/** * Same behaviour than add(int index, long o) in * {@link java.util.List}. * Any access to this method should be protected in a synchronized * block on the LongList object. **/ public final void add(final int index, final long o) { if (index > size) throw new IndexOutOfBoundsException(); if (index >= list.length) resize(); if (index == size) { list[size++] = o; return; } java.lang.System.arraycopy(list, index, list, index + 1, size - index); list[index] = o; size++; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.jmx.snmp.agent.SnmpMib.add(int, long[], int, int)
/** * Adds <var>count</var> elements to the list. * @param at index at which the elements must be inserted. The * first element will be inserted at this index. * @param src An array containing the elements we want to insert. * @param from Index of the first element from <var>src</var> that * must be inserted. * @param count number of elements to insert. * Any access to this method should be protected in a synchronized * block on the LongList object. **/ public final void add(final int at, final long[] src, final int from, final int count) { if (count <= 0) return; if (at > size) throw new IndexOutOfBoundsException(); ensure(size + count); if (at < size) { java.lang.System.arraycopy(list, at, list, at + count, size - at); } java.lang.System.arraycopy(src, from, list, at, count); size += count; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.BufferedInputStream.read(byte, int, int)
/** * Reads bytes from this byte-input stream into the specified byte array, * starting at the given offset. * This method implements the general contract of the corresponding * <code>{@link InputStream#read(byte[], int, int) read}</code> method of * the <code>{@link InputStream}</code> class. As an additional * convenience, it attempts to read as many bytes as possible by repeatedly * invoking the <code>read</code> method of the underlying stream. This * iterated <code>read</code> continues until one of the following * conditions becomes true: <ul> * <li> The specified number of bytes have been read, * <li> The <code>read</code> method of the underlying stream returns * <code>-1</code>, indicating end-of-file, or * <li> The <code>available</code> method of the underlying stream * returns zero, indicating that further input requests would block. * </ul> If the first <code>read</code> on the underlying stream returns * <code>-1</code> to indicate end-of-file then this method returns * <code>-1</code>. Otherwise this method returns the number of bytes * actually read. * Subclasses of this class are encouraged, but not required, to * attempt to read as many bytes as possible in the same fashion. * @param b destination buffer. * @param off offset at which to start storing bytes. * @param len maximum number of bytes to read. * @return the number of bytes read, or <code>-1</code> if the end of * the stream has been reached. * @exception IOException if an I/O error occurs. */ public synchronized int read(byte b[], int off, int len) throws IOException { getBufIfOpen(); if ((off | len | (off + len) | (b.length - (off + len))) < 0) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } int n = 0; for (; ; ) { int nread = read1(b, off + n, len - n); if (nread <= 0) return (n == 0) ? nread : n; n += nread; if (n >= len) return n; InputStream input = in; if (input != null && input.available() <= 0) return n; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.BufferedReader.read(char, int, int)
/** * Read characters into a portion of an array. * This method implements the general contract of the corresponding * <code>{@link Reader#read(char[], int, int) read}</code> method of the * <code>{@link Reader}</code> class. As an additional convenience, it * attempts to read as many characters as possible by repeatedly invoking * the <code>read</code> method of the underlying stream. This iterated * <code>read</code> continues until one of the following conditions becomes * true: <ul> * <li> The specified number of characters have been read, * <li> The <code>read</code> method of the underlying stream returns * <code>-1</code>, indicating end-of-file, or * <li> The <code>ready</code> method of the underlying stream * returns <code>false</code>, indicating that further input requests * would block. * </ul> If the first <code>read</code> on the underlying stream returns * <code>-1</code> to indicate end-of-file then this method returns * <code>-1</code>. Otherwise this method returns the number of characters * actually read. * Subclasses of this class are encouraged, but not required, to * attempt to read as many characters as possible in the same fashion. * Ordinarily this method takes characters from this stream's character * buffer, filling it from the underlying stream as necessary. If, * however, the buffer is empty, the mark is not valid, and the requested * length is at least as large as the buffer, then this method will read * characters directly from the underlying stream into the given array. * Thus redundant <code>BufferedReader</code>s will not copy data * unnecessarily. * @param cbuf Destination buffer * @param off Offset at which to start storing characters * @param len Maximum number of characters to read * @return The number of characters read, or -1 if the end of the * stream has been reached * @exception IOException If an I/O error occurs */ public int read(char cbuf[], int off, int len) throws IOException { synchronized (lock) { ensureOpen(); if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } int n = read1(cbuf, off, len); if (n <= 0) return n; while ((n < len) && in.ready()) { int n1 = read1(cbuf, off + n, len - n); if (n1 <= 0) break; n += n1; } return n; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.BufferedWriter.write(char, int, int)
/** * Write a portion of an array of characters. * Ordinarily this method stores characters from the given array into * this stream's buffer, flushing the buffer to the underlying stream as * needed. If the requested length is at least as large as the buffer, * however, then this method will flush the buffer and write the characters * directly to the underlying stream. Thus redundant * <code>BufferedWriter</code>s will not copy data unnecessarily. * @param cbuf A character array * @param off Offset from which to start reading characters * @param len Number of characters to write * @exception IOException If an I/O error occurs */ public void write(char cbuf[], int off, int len) throws IOException { synchronized (lock) { ensureOpen(); if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } if (len >= nChars) { flushBuffer(); out.write(cbuf, off, len); return; } int b = off, t = off + len; while (b < t) { int d = min(nChars - nextChar, t - b); System.arraycopy(cbuf, b, cb, nextChar, d); b += d; nextChar += d; if (nextChar >= nChars) flushBuffer(); } } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.ByteArrayInputStream.read(byte, int, int)
/** * Reads up to <code>len</code> bytes of data into an array of bytes * from this input stream. * If <code>pos</code> equals <code>count</code>, * then <code>-1</code> is returned to indicate * end of file. Otherwise, the number <code>k</code> * of bytes read is equal to the smaller of * <code>len</code> and <code>count-pos</code>. * If <code>k</code> is positive, then bytes * <code>buf[pos]</code> through <code>buf[pos+k-1]</code> * are copied into <code>b[off]</code> through * <code>b[off+k-1]</code> in the manner performed * by <code>System.arraycopy</code>. The * value <code>k</code> is added into <code>pos</code> * and <code>k</code> is returned. * This <code>read</code> method cannot block. * @param b the buffer into which the data is read. * @param off the start offset of the data. * @param len the maximum number of bytes read. * @return the total number of bytes read into the buffer, or * <code>-1</code> if there is no more data because the end of * the stream has been reached. */ public synchronized int read(byte b[], int off, int len) { if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } if (pos >= count) { return -1; } if (pos + len > count) { len = count - pos; } if (len <= 0) { return 0; } System.arraycopy(buf, pos, b, off, len); pos += len; return len; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.ByteArrayOutputStream.write(byte, int, int)
/** * Writes <code>len</code> bytes from the specified byte array * starting at offset <code>off</code> to this byte array output stream. * @param b the data. * @param off the start offset in the data. * @param len the number of bytes to write. */ public synchronized void write(byte b[], int off, int len) { if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } int newcount = count + len; if (newcount > buf.length) { byte newbuf[] = new byte[Math.max(buf.length << 1, newcount)]; System.arraycopy(buf, 0, newbuf, 0, count); buf = newbuf; } System.arraycopy(b, off, buf, count, len); count = newcount; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.CharArrayReader.read(char, int, int)
/** * Read characters into a portion of an array. * @param b Destination buffer * @param off Offset at which to start storing characters * @param len Maximum number of characters to read * @return The actual number of characters read, or -1 if * the end of the stream has been reached * @exception IOException If an I/O error occurs */ public int read(char b[], int off, int len) throws IOException { synchronized (lock) { ensureOpen(); if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } if (pos >= count) { return -1; } if (pos + len > count) { len = count - pos; } if (len <= 0) { return 0; } System.arraycopy(buf, pos, b, off, len); pos += len; return len; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.CharArrayWriter.write(char, int, int)
/** * Writes characters to the buffer. * @param c the data to be written * @param off the start offset in the data * @param len the number of chars that are written */ public void write(char c[], int off, int len) { if ((off < 0) || (off > c.length) || (len < 0) || ((off + len) > c.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } synchronized (lock) { int newcount = count + len; if (newcount > buf.length) { char newbuf[] = new char[Math.max(buf.length << 1, newcount)]; System.arraycopy(buf, 0, newbuf, 0, count); buf = newbuf; } System.arraycopy(c, off, buf, count, len); count = newcount; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.DataInputStream.readFully(byte, int, int)
/** * See the general contract of the <code>readFully</code> * method of <code>DataInput</code>. * Bytes * for this operation are read from the contained * input stream. * @param b the buffer into which the data is read. * @param off the start offset of the data. * @param len the number of bytes to read. * @exception EOFException if this input stream reaches the end before * reading all the bytes. * @exception IOException if an I/O error occurs. * @see java.io.FilterInputStream#in */ public final void readFully(byte b[], int off, int len) throws IOException { if (len < 0) throw new IndexOutOfBoundsException(); int n = 0; while (n < len) { int count = in.read(b, off + n, len - n); if (count < 0) throw new EOFException(); n += count; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.FilterOutputStream.write(byte, int, int)
/** * Writes <code>len</code> bytes from the specified * <code>byte</code> array starting at offset <code>off</code> to * this output stream. * The <code>write</code> method of <code>FilterOutputStream</code> * calls the <code>write</code> method of one argument on each * <code>byte</code> to output. * Note that this method does not call the <code>write</code> method * of its underlying input stream with the same arguments. Subclasses * of <code>FilterOutputStream</code> should provide a more efficient * implementation of this method. * @param b the data. * @param off the start offset in the data. * @param len the number of bytes to write. * @exception IOException if an I/O error occurs. * @see java.io.FilterOutputStream#write(int) */ public void write(byte b[], int off, int len) throws IOException { if ((off | len | (b.length - (len + off)) | (off + len)) < 0) throw new IndexOutOfBoundsException(); for (int i = 0; i < len; i++) { write(b[off + i]); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.InputStream.read(byte, int, int)
/** * Reads up to <code>len</code> bytes of data from the input stream into * an array of bytes. An attempt is made to read as many as * <code>len</code> bytes, but a smaller number may be read. * The number of bytes actually read is returned as an integer. * This method blocks until input data is available, end of file is * detected, or an exception is thrown. * If <code>b</code> is <code>null</code>, a * <code>NullPointerException</code> is thrown. * If <code>off</code> is negative, or <code>len</code> is negative, or * <code>off+len</code> is greater than the length of the array * <code>b</code>, then an <code>IndexOutOfBoundsException</code> is * thrown. * If <code>len</code> is zero, then no bytes are read and * <code>0</code> is returned; otherwise, there is an attempt to read at * least one byte. If no byte is available because the stream is at end of * file, the value <code>-1</code> is returned; otherwise, at least one * byte is read and stored into <code>b</code>. * The first byte read is stored into element <code>b[off]</code>, the * next one into <code>b[off+1]</code>, and so on. The number of bytes read * is, at most, equal to <code>len</code>. Let <i>k</i> be the number of * bytes actually read; these bytes will be stored in elements * <code>b[off]</code> through <code>b[off+</code><i>k</i><code>-1]</code>, * leaving elements <code>b[off+</code><i>k</i><code>]</code> through * <code>b[off+len-1]</code> unaffected. * In every case, elements <code>b[0]</code> through * <code>b[off]</code> and elements <code>b[off+len]</code> through * <code>b[b.length-1]</code> are unaffected. * If the first byte cannot be read for any reason other than end of * file, then an <code>IOException</code> is thrown. In particular, an * <code>IOException</code> is thrown if the input stream has been closed. * The <code>read(b,</code> <code>off,</code> <code>len)</code> method * for class <code>InputStream</code> simply calls the method * <code>read()</code> repeatedly. If the first such call results in an * <code>IOException</code>, that exception is returned from the call to * the <code>read(b,</code> <code>off,</code> <code>len)</code> method. If * any subsequent call to <code>read()</code> results in a * <code>IOException</code>, the exception is caught and treated as if it * were end of file; the bytes read up to that point are stored into * <code>b</code> and the number of bytes read before the exception * occurred is returned. Subclasses are encouraged to provide a more * efficient implementation of this method. * @param b the buffer into which the data is read. * @param off the start offset in array <code>b</code> * at which the data is written. * @param len the maximum number of bytes to read. * @return the total number of bytes read into the buffer, or * <code>-1</code> if there is no more data because the end of * the stream has been reached. * @exception IOException if an I/O error occurs. * @exception NullPointerException if <code>b</code> is <code>null</code>. * @see java.io.InputStream#read() */ public int read(byte b[], int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } int c = read(); if (c == -1) { return -1; } b[off] = (byte) c; int i = 1; try { for (; i < len; i++) { c = read(); if (c == -1) { break; } if (b != null) { b[off + i] = (byte) c; } } } catch (IOException ee) { } return i; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.LineNumberInputStream.read(byte, int, int)
/** * Reads up to <code>len</code> bytes of data from this input stream * into an array of bytes. This method blocks until some input is available. * The <code>read</code> method of * <code>LineNumberInputStream</code> repeatedly calls the * <code>read</code> method of zero arguments to fill in the byte array. * @param b the buffer into which the data is read. * @param off the start offset of the data. * @param len the maximum number of bytes read. * @return the total number of bytes read into the buffer, or * <code>-1</code> if there is no more data because the end of * this stream has been reached. * @exception IOException if an I/O error occurs. * @see java.io.LineNumberInputStream#read() */ public int read(byte b[], int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } int c = read(); if (c == -1) { return -1; } b[off] = (byte) c; int i = 1; try { for (; i < len; i++) { c = read(); if (c == -1) { break; } if (b != null) { b[off + i] = (byte) c; } } } catch (IOException ee) { } return i; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.ObjectInputStream.read(byte[], int, int)
/** * Reads into an array of bytes. This method will block until some input * is available. Consider using java.io.DataInputStream.readFully to read * exactly 'length' bytes. * @param buf the buffer into which the data is read * @param off the start offset of the data * @param len the maximum number of bytes read * @return the actual number of bytes read, -1 is returned when the end of * the stream is reached. * @throws IOException If an I/O error has occurred. * @see java.io.DataInputStream#readFully(byte[],int,int) */ public int read(byte[] buf, int off, int len) throws IOException { if (buf == null) { throw new NullPointerException(); } int endoff = off + len; if (off < 0 || len < 0 || endoff > buf.length || endoff < 0) { throw new IndexOutOfBoundsException(); } return bin.read(buf, off, len, false); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.ObjectInputStream.readFully(byte[], int, int)
/** * Reads bytes, blocking until all bytes are read. * @param buf the buffer into which the data is read * @param off the start offset of the data * @param len the maximum number of bytes to read * @throws EOFException If end of file is reached. * @throws IOException If other I/O error has occurred. */ public void readFully(byte[] buf, int off, int len) throws IOException { int endoff = off + len; if (off < 0 || len < 0 || endoff > buf.length || endoff < 0) { throw new IndexOutOfBoundsException(); } bin.readFully(buf, off, len, false); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.ObjectOutputStream.write(byte[], int, int)
/** * Writes a sub array of bytes. * @param buf the data to be written * @param off the start offset in the data * @param len the number of bytes that are written * @throws IOException If an I/O error has occurred. */ public void write(byte[] buf, int off, int len) throws IOException { if (buf == null) { throw new NullPointerException(); } int endoff = off + len; if (off < 0 || len < 0 || endoff > buf.length || endoff < 0) { throw new IndexOutOfBoundsException(); } bout.write(buf, off, len, false); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.OutputStream.write(byte, int, int)
/** * Writes <code>len</code> bytes from the specified byte array * starting at offset <code>off</code> to this output stream. * The general contract for <code>write(b, off, len)</code> is that * some of the bytes in the array <code>b</code> are written to the * output stream in order; element <code>b[off]</code> is the first * byte written and <code>b[off+len-1]</code> is the last byte written * by this operation. * The <code>write</code> method of <code>OutputStream</code> calls * the write method of one argument on each of the bytes to be * written out. Subclasses are encouraged to override this method and * provide a more efficient implementation. * If <code>b</code> is <code>null</code>, a * <code>NullPointerException</code> is thrown. * If <code>off</code> is negative, or <code>len</code> is negative, or * <code>off+len</code> is greater than the length of the array * <code>b</code>, then an <tt>IndexOutOfBoundsException</tt> is thrown. * @param b the data. * @param off the start offset in the data. * @param len the number of bytes to write. * @exception IOException if an I/O error occurs. In particular, * an <code>IOException</code> is thrown if the output * stream is closed. */ public void write(byte b[], int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } for (int i = 0; i < len; i++) { write(b[off + i]); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.PipedInputStream.read(byte, int, int)
/** * Reads up to <code>len</code> bytes of data from this piped input * stream into an array of bytes. Less than <code>len</code> bytes * will be read if the end of the data stream is reached. This method * blocks until at least one byte of input is available. * If a thread was providing data bytes * to the connected piped output stream, but * the thread is no longer alive, then an * <code>IOException</code> is thrown. * @param b the buffer into which the data is read. * @param off the start offset of the data. * @param len the maximum number of bytes read. * @return the total number of bytes read into the buffer, or * <code>-1</code> if there is no more data because the end of * the stream has been reached. * @exception IOException if an I/O error occurs. */ public synchronized int read(byte b[], int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } int c = read(); if (c < 0) { return -1; } b[off] = (byte) c; int rlen = 1; while ((in >= 0) && (--len > 0)) { b[off + rlen] = buffer[out++]; rlen++; if (out >= buffer.length) { out = 0; } if (in == out) { in = -1; } } return rlen; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.PipedOutputStream.write(byte, int, int)
/** * Writes <code>len</code> bytes from the specified byte array * starting at offset <code>off</code> to this piped output stream. * If a thread was reading data bytes from the connected piped input * stream, but the thread is no longer alive, then an * <code>IOException</code> is thrown. * @param b the data. * @param off the start offset in the data. * @param len the number of bytes to write. * @exception IOException if an I/O error occurs. */ public void write(byte b[], int off, int len) throws IOException { if (sink == null) { throw new IOException('Pipe not connected'); } else if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } sink.receive(b, off, len); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.PipedReader.read(char, int, int)
/** * Reads up to <code>len</code> characters of data from this piped * stream into an array of characters. Less than <code>len</code> characters * will be read if the end of the data stream is reached. This method * blocks until at least one character of input is available. * If a thread was providing data characters to the connected piped output, * but the thread is no longer alive, then an <code>IOException</code> * is thrown. * @param cbuf the buffer into which the data is read. * @param off the start offset of the data. * @param len the maximum number of characters read. * @return the total number of characters read into the buffer, or * <code>-1</code> if there is no more data because the end of * the stream has been reached. * @exception IOException if an I/O error occurs. */ public synchronized int read(char cbuf[], int off, int len) throws IOException { if (!connected) { throw new IOException('Pipe not connected'); } else if (closedByReader) { throw new IOException('Pipe closed'); } else if (writeSide != null && !writeSide.isAlive() && !closedByWriter && (in < 0)) { throw new IOException('Write end dead'); } if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } int c = read(); if (c < 0) { return -1; } cbuf[off] = (char) c; int rlen = 1; while ((in >= 0) && (--len > 0)) { cbuf[off + rlen] = buffer[out++]; rlen++; if (out >= buffer.length) { out = 0; } if (in == out) { in = -1; } } return rlen; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.PipedWriter.write(char, int, int)
/** * Writes <code>len</code> characters from the specified character array * starting at offset <code>off</code> to this piped output stream. * If a thread was reading data characters from the connected piped input * stream, but the thread is no longer alive, then an * <code>IOException</code> is thrown. * @param cbuf the data. * @param off the start offset in the data. * @param len the number of characters to write. * @exception IOException if an I/O error occurs. */ public void write(char cbuf[], int off, int len) throws IOException { if (sink == null) { throw new IOException('Pipe not connected'); } else if ((off | len | (off + len) | (cbuf.length - (off + len))) < 0) { throw new IndexOutOfBoundsException(); } sink.receive(cbuf, off, len); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.PushbackInputStream.read(byte[], int, int)
/** * Reads up to <code>len</code> bytes of data from this input stream into * an array of bytes. This method first reads any pushed-back bytes; after * that, if fewer than <code>len</code> bytes have been read then it * reads from the underlying input stream. This method blocks until at * least 1 byte of input is available. * @param b the buffer into which the data is read. * @param off the start offset of the data. * @param len the maximum number of bytes read. * @return the total number of bytes read into the buffer, or * <code>-1</code> if there is no more data because the end of * the stream has been reached. * @exception IOException if an I/O error occurs. * @see java.io.InputStream#read(byte[], int, int) */ public int read(byte[] b, int off, int len) throws IOException { ensureOpen(); if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } if (len == 0) { return 0; } int avail = buf.length - pos; if (avail > 0) { if (len < avail) { avail = len; } System.arraycopy(buf, pos, b, off, avail); pos += avail; off += avail; len -= avail; } if (len > 0) { len = super.read(b, off, len); if (len == -1) { return avail == 0 ? -1 : avail; } return avail + len; } return avail; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.PushbackReader.read(char, int, int)
/** * Read characters into a portion of an array. * @param cbuf Destination buffer * @param off Offset at which to start writing characters * @param len Maximum number of characters to read * @return The number of characters read, or -1 if the end of the * stream has been reached * @exception IOException If an I/O error occurs */ public int read(char cbuf[], int off, int len) throws IOException { synchronized (lock) { ensureOpen(); try { if (len <= 0) { if (len < 0) { throw new IndexOutOfBoundsException(); } else if ((off < 0) || (off > cbuf.length)) { throw new IndexOutOfBoundsException(); } return 0; } int avail = buf.length - pos; if (avail > 0) { if (len < avail) avail = len; System.arraycopy(buf, pos, cbuf, off, avail); pos += avail; off += avail; len -= avail; } if (len > 0) { len = super.read(cbuf, off, len); if (len == -1) { return (avail == 0) ? -1 : avail; } return avail + len; } return avail; } catch (ArrayIndexOutOfBoundsException e) { throw new IndexOutOfBoundsException(); } } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.SequenceInputStream.read(byte, int, int)
/** * Reads up to <code>len</code> bytes of data from this input stream * into an array of bytes. This method blocks until at least 1 byte * of input is available. If the first argument is <code>null</code>, * up to <code>len</code> bytes are read and discarded. * The <code>read</code> method of <code>SequenceInputStream</code> * tries to read the data from the current substream. If it fails to * read any characters because the substream has reached the end of * the stream, it calls the <code>close</code> method of the current * substream and begins reading from the next substream. * @param b the buffer into which the data is read. * @param off the start offset of the data. * @param len the maximum number of bytes read. * @return int the number of bytes read. * @exception IOException if an I/O error occurs. */ public int read(byte b[], int off, int len) throws IOException { if (in == null) { return -1; } else if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } int n = in.read(b, off, len); if (n <= 0) { nextStream(); return read(b, off, len); } return n; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.StringBufferInputStream.read(byte, int, int)
/** * Reads up to <code>len</code> bytes of data from this input stream * into an array of bytes. * The <code>read</code> method of * <code>StringBufferInputStream</code> cannot block. It copies the * low eight bits from the characters in this input stream's buffer into * the byte array argument. * @param b the buffer into which the data is read. * @param off the start offset of the data. * @param len the maximum number of bytes read. * @return the total number of bytes read into the buffer, or * <code>-1</code> if there is no more data because the end of * the stream has been reached. */ public synchronized int read(byte b[], int off, int len) { if (b == null) { throw new NullPointerException(); } else if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } if (pos >= count) { return -1; } if (pos + len > count) { len = count - pos; } if (len <= 0) { return 0; } String s = buffer; int cnt = len; while (--cnt >= 0) { b[off++] = (byte) s.charAt(pos++); } return len; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.StringReader.read(char, int, int)
/** * Read characters into a portion of an array. * @param cbuf Destination buffer * @param off Offset at which to start writing characters * @param len Maximum number of characters to read * @return The number of characters read, or -1 if the end of the * stream has been reached * @exception IOException If an I/O error occurs */ public int read(char cbuf[], int off, int len) throws IOException { synchronized (lock) { ensureOpen(); if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } if (next >= length) return -1; int n = Math.min(length - next, len); str.getChars(next, next + n, cbuf, off); next += n; return n; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.io.StringWriter.write(char, int, int)
/** * Write a portion of an array of characters. * @param cbuf Array of characters * @param off Offset from which to start writing characters * @param len Number of characters to write */ public void write(char cbuf[], int off, int len) { if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } buf.append(cbuf, off, len); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.lang.AbstractStringBuilder.codePointCount(int, int)
/** * Returns the number of Unicode code points in the specified text * range of this sequence. The text range begins at the specified * <code>beginIndex</code> and extends to the <code>char</code> at * index <code>endIndex - 1</code>. Thus the length (in * <code>char</code>s) of the text range is * <code>endIndex-beginIndex</code>. Unpaired surrogates within * this sequence count as one code point each. * @param beginIndex the index to the first <code>char</code> of * the text range. * @param endIndex the index after the last <code>char</code> of * the text range. * @return the number of Unicode code points in the specified text * range * @exception IndexOutOfBoundsException if the * <code>beginIndex</code> is negative, or <code>endIndex</code> * is larger than the length of this sequence, or * <code>beginIndex</code> is larger than <code>endIndex</code>. */ public int codePointCount(int beginIndex, int endIndex) { if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) { throw new IndexOutOfBoundsException(); } return Character.codePointCountImpl(value, beginIndex, endIndex - beginIndex); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.lang.AbstractStringBuilder.offsetByCodePoints(int, int)
/** * Returns the index within this sequence that is offset from the * given <code>index</code> by <code>codePointOffset</code> code * points. Unpaired surrogates within the text range given by * <code>index</code> and <code>codePointOffset</code> count as * one code point each. * @param index the index to be offset * @param codePointOffset the offset in code points * @return the index within this sequence * @exception IndexOutOfBoundsException if <code>index</code> * is negative or larger then the length of this sequence, * or if <code>codePointOffset</code> is positive and the subsequence * starting with <code>index</code> has fewer than * <code>codePointOffset</code> code points, * or if <code>codePointOffset</code> is negative and the subsequence * before <code>index</code> has fewer than the absolute value of * <code>codePointOffset</code> code points. */ public int offsetByCodePoints(int index, int codePointOffset) { if (index < 0 || index > count) { throw new IndexOutOfBoundsException(); } return Character.offsetByCodePointsImpl(value, 0, count, index, codePointOffset); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.lang.Character.codePointAt(char[], int, int)
/** * Returns the code point at the given index of the * <code>char</code> array, where only array elements with * <code>index</code> less than <code>limit</code> can be used. If * the <code>char</code> value at the given index in the * <code>char</code> array is in the high-surrogate range, the * following index is less than the <code>limit</code>, and the * <code>char</code> value at the following index is in the * low-surrogate range, then the supplementary code point * corresponding to this surrogate pair is returned. Otherwise, * the <code>char</code> value at the given index is returned. * @param a the <code>char</code> array * @param index the index to the <code>char</code> values (Unicode * code units) in the <code>char</code> array to be converted * @param limit the index after the last array element that can be used in the * <code>char</code> array * @return the Unicode code point at the given index * @exception NullPointerException if <code>a</code> is null. * @exception IndexOutOfBoundsException if the <code>index</code> * argument is negative or not less than the <code>limit</code> * argument, or if the <code>limit</code> argument is negative or * greater than the length of the <code>char</code> array. * @since 1.5 */ public static int codePointAt(char[] a, int index, int limit) { if (index >= limit || limit < 0 || limit > a.length) { throw new IndexOutOfBoundsException(); } return codePointAtImpl(a, index, limit); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.lang.Character.codePointBefore(char[], int, int)
/** * Returns the code point preceding the given index of the * <code>char</code> array, where only array elements with * <code>index</code> greater than or equal to <code>start</code> * can be used. If the <code>char</code> value at <code>(index - * 1)</code> in the <code>char</code> array is in the * low-surrogate range, <code>(index - 2)</code> is not less than * <code>start</code>, and the <code>char</code> value at * <code>(index - 2)</code> in the <code>char</code> array is in * the high-surrogate range, then the supplementary code point * corresponding to this surrogate pair is returned. Otherwise, * the <code>char</code> value at <code>(index - 1)</code> is * returned. * @param a the <code>char</code> array * @param index the index following the code point that should be returned * @param start the index of the first array element in the * <code>char</code> array * @return the Unicode code point value before the given index. * @exception NullPointerException if <code>a</code> is null. * @exception IndexOutOfBoundsException if the <code>index</code> * argument is not greater than the <code>start</code> argument or * is greater than the length of the <code>char</code> array, or * if the <code>start</code> argument is negative or not less than * the length of the <code>char</code> array. * @since 1.5 */ public static int codePointBefore(char[] a, int index, int start) { if (index <= start || start < 0 || start >= a.length) { throw new IndexOutOfBoundsException(); } return codePointBeforeImpl(a, index, start); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.lang.Character.codePointCount(CharSequence, int, int)
/** * Returns the number of Unicode code points in the text range of * the specified char sequence. The text range begins at the * specified <code>beginIndex</code> and extends to the * <code>char</code> at index <code>endIndex - 1</code>. Thus the * length (in <code>char</code>s) of the text range is * <code>endIndex-beginIndex</code>. Unpaired surrogates within * the text range count as one code point each. * @param seq the char sequence * @param beginIndex the index to the first <code>char</code> of * the text range. * @param endIndex the index after the last <code>char</code> of * the text range. * @return the number of Unicode code points in the specified text * range * @exception NullPointerException if <code>seq</code> is null. * @exception IndexOutOfBoundsException if the * <code>beginIndex</code> is negative, or <code>endIndex</code> * is larger than the length of the given sequence, or * <code>beginIndex</code> is larger than <code>endIndex</code>. * @since 1.5 */ public static int codePointCount(CharSequence seq, int beginIndex, int endIndex) { int length = seq.length(); if (beginIndex < 0 || endIndex > length || beginIndex > endIndex) { throw new IndexOutOfBoundsException(); } int n = 0; for (int i = beginIndex; i < endIndex; ) { n++; if (isHighSurrogate(seq.charAt(i++))) { if (i < endIndex && isLowSurrogate(seq.charAt(i))) { i++; } } } return n; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.lang.Character.codePointCount(char[], int, int)
/** * Returns the number of Unicode code points in a subarray of the * <code>char</code> array argument. The <code>offset</code> * argument is the index of the first <code>char</code> of the * subarray and the <code>count</code> argument specifies the * length of the subarray in <code>char</code>s. Unpaired * surrogates within the subarray count as one code point each. * @param a the <code>char</code> array * @param offset the index of the first <code>char</code> in the * given <code>char</code> array * @param count the length of the subarray in <code>char</code>s * @return the number of Unicode code points in the specified subarray * @exception NullPointerException if <code>a</code> is null. * @exception IndexOutOfBoundsException if <code>offset</code> or * <code>count</code> is negative, or if <code>offset + * count</code> is larger than the length of the given array. * @since 1.5 */ public static int codePointCount(char[] a, int offset, int count) { if (count > a.length - offset || offset < 0 || count < 0) { throw new IndexOutOfBoundsException(); } return codePointCountImpl(a, offset, count); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.lang.Character.offsetByCodePoints(CharSequence, int, int)
/** * Returns the index within the given char sequence that is offset * from the given <code>index</code> by <code>codePointOffset</code> * code points. Unpaired surrogates within the text range given by * <code>index</code> and <code>codePointOffset</code> count as * one code point each. * @param seq the char sequence * @param index the index to be offset * @param codePointOffset the offset in code points * @return the index within the char sequence * @exception NullPointerException if <code>seq</code> is null. * @exception IndexOutOfBoundsException if <code>index</code> * is negative or larger then the length of the char sequence, * or if <code>codePointOffset</code> is positive and the * subsequence starting with <code>index</code> has fewer than * <code>codePointOffset</code> code points, or if * <code>codePointOffset</code> is negative and the subsequence * before <code>index</code> has fewer than the absolute value * of <code>codePointOffset</code> code points. * @since 1.5 */ public static int offsetByCodePoints(CharSequence seq, int index, int codePointOffset) { int length = seq.length(); if (index < 0 || index > length) { throw new IndexOutOfBoundsException(); } int x = index; if (codePointOffset >= 0) { int i; for (i = 0; x < length && i < codePointOffset; i++) { if (isHighSurrogate(seq.charAt(x++))) { if (x < length && isLowSurrogate(seq.charAt(x))) { x++; } } } if (i < codePointOffset) { throw new IndexOutOfBoundsException(); } } else { int i; for (i = codePointOffset; x > 0 && i < 0; i++) { if (isLowSurrogate(seq.charAt(--x))) { if (x > 0 && isHighSurrogate(seq.charAt(x - 1))) { x--; } } } if (i < 0) { throw new IndexOutOfBoundsException(); } } return x; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.lang.Character.offsetByCodePoints(char[], int, int, int, int)
/** * Returns the index within the given <code>char</code> subarray * that is offset from the given <code>index</code> by * <code>codePointOffset</code> code points. The * <code>start</code> and <code>count</code> arguments specify a * subarray of the <code>char</code> array. Unpaired surrogates * within the text range given by <code>index</code> and * <code>codePointOffset</code> count as one code point each. * @param a the <code>char</code> array * @param start the index of the first <code>char</code> of the * subarray * @param count the length of the subarray in <code>char</code>s * @param index the index to be offset * @param codePointOffset the offset in code points * @return the index within the subarray * @exception NullPointerException if <code>a</code> is null. * @exception IndexOutOfBoundsException * if <code>start</code> or <code>count</code> is negative, * or if <code>start + count</code> is larger than the length of * the given array, * or if <code>index</code> is less than <code>start</code> or * larger then <code>start + count</code>, * or if <code>codePointOffset</code> is positive and the text range * starting with <code>index</code> and ending with <code>start * + count - 1</code> has fewer than <code>codePointOffset</code> code * points, * or if <code>codePointOffset</code> is negative and the text range * starting with <code>start</code> and ending with <code>index * - 1</code> has fewer than the absolute value of * <code>codePointOffset</code> code points. * @since 1.5 */ public static int offsetByCodePoints(char[] a, int start, int count, int index, int codePointOffset) { if (count > a.length - start || start < 0 || count < 0 || index < start || index > start + count) { throw new IndexOutOfBoundsException(); } return offsetByCodePointsImpl(a, start, count, index, codePointOffset); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.lang.Character.offsetByCodePointsImpl(char[], int, int, int, int)
static int offsetByCodePointsImpl(char[] a, int start, int count, int index, int codePointOffset) { int x = index; if (codePointOffset >= 0) { int limit = start + count; int i; for (i = 0; x < limit && i < codePointOffset; i++) { if (isHighSurrogate(a[x++])) { if (x < limit && isLowSurrogate(a[x])) { x++; } } } if (i < codePointOffset) { throw new IndexOutOfBoundsException(); } } else { int i; for (i = codePointOffset; x > start && i < 0; i++) { if (isLowSurrogate(a[--x])) { if (x > start && isHighSurrogate(a[x - 1])) { x--; } } } if (i < 0) { throw new IndexOutOfBoundsException(); } } return x; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.lang.String.codePointCount(int, int)
/** * Returns the number of Unicode code points in the specified text * range of this <code>String</code>. The text range begins at the * specified <code>beginIndex</code> and extends to the * <code>char</code> at index <code>endIndex - 1</code>. Thus the * length (in <code>char</code>s) of the text range is * <code>endIndex-beginIndex</code>. Unpaired surrogates within * the text range count as one code point each. * @param beginIndex the index to the first <code>char</code> of * the text range. * @param endIndex the index after the last <code>char</code> of * the text range. * @return the number of Unicode code points in the specified text * range * @exception IndexOutOfBoundsException if the * <code>beginIndex</code> is negative, or <code>endIndex</code> * is larger than the length of this <code>String</code>, or * <code>beginIndex</code> is larger than <code>endIndex</code>. * @since 1.5 */ public int codePointCount(int beginIndex, int endIndex) { if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) { throw new IndexOutOfBoundsException(); } return Character.codePointCountImpl(value, offset + beginIndex, endIndex - beginIndex); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.lang.String.offsetByCodePoints(int, int)
/** * Returns the index within this <code>String</code> that is * offset from the given <code>index</code> by * <code>codePointOffset</code> code points. Unpaired surrogates * within the text range given by <code>index</code> and * <code>codePointOffset</code> count as one code point each. * @param index the index to be offset * @param codePointOffset the offset in code points * @return the index within this <code>String</code> * @exception IndexOutOfBoundsException if <code>index</code> * is negative or larger then the length of this * <code>String</code>, or if <code>codePointOffset</code> is positive * and the substring starting with <code>index</code> has fewer * than <code>codePointOffset</code> code points, * or if <code>codePointOffset</code> is negative and the substring * before <code>index</code> has fewer than the absolute value * of <code>codePointOffset</code> code points. * @since 1.5 */ public int offsetByCodePoints(int index, int codePointOffset) { if (index < 0 || index > count) { throw new IndexOutOfBoundsException(); } return Character.offsetByCodePointsImpl(value, offset, count, offset + index, codePointOffset); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.Buffer.checkBounds(int, int, int)
static void checkBounds(int off, int len, int size) { if ((off | len | (off + len) | (size - (off + len))) < 0) throw new IndexOutOfBoundsException(); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.Buffer.checkIndex(int)
/** * Checks the given index against the limit, throwing an {@link * IndexOutOfBoundsException} if it is not smaller than the limit * or is smaller than zero. */ final int checkIndex(int i) { if ((i < 0) || (i >= limit)) throw new IndexOutOfBoundsException(); return i; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.Buffer.checkIndex(int, int)
final int checkIndex(int i, int nb) { if ((i < 0) || (nb > limit - i)) throw new IndexOutOfBoundsException(); return i; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.ByteBuffer.wrap(byte[], int, int)
/** * Wraps a byte array into a buffer. * The new buffer will be backed by the given byte array; * that is, modifications to the buffer will cause the array to be modified * and vice versa. The new buffer's capacity will be * <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit * will be <tt>offset + length</tt>, and its mark will be undefined. Its * {@link #array </code>backing array<code>} will be the given array, and * its {@link #arrayOffset </code>array offset<code>} will be zero. * @param array * The array that will back the new buffer * @param offset * The offset of the subarray to be used; must be non-negative and * no larger than <tt>array.length</tt>. The new buffer's position * will be set to this value. * @param length * The length of the subarray to be used; * must be non-negative and no larger than * <tt>array.length - offset</tt>. * The new buffer's limit will be set to <tt>offset + length</tt>. * @return The new byte buffer * @throws IndexOutOfBoundsException * If the preconditions on the <tt>offset</tt> and <tt>length</tt> * parameters do not hold */ public static ByteBuffer wrap(byte[] array, int offset, int length) { try { return new HeapByteBuffer(array, offset, length); } catch (IllegalArgumentException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.ByteBufferAsCharBufferB.subSequence(int, int)
public CharSequence subSequence(int start, int end) { int pos = position(); int lim = limit(); assert (pos <= lim); pos = (pos <= lim ? pos : lim); int len = lim - pos; if ((start < 0) || (end > len) || (start > end)) throw new IndexOutOfBoundsException(); int sublen = end - start; int off = offset + ((pos + start) << 1); assert (off >= 0); return new ByteBufferAsCharBufferB(bb, -1, 0, sublen, sublen, off); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.ByteBufferAsCharBufferB.toString(int, int)
public String toString(int start, int end) { if ((end > limit()) || (start > end)) throw new IndexOutOfBoundsException(); try { int len = end - start; char[] ca = new char[len]; CharBuffer cb = CharBuffer.wrap(ca); CharBuffer db = this.duplicate(); db.position(start); db.limit(end); cb.put(db); return new String(ca); } catch (StringIndexOutOfBoundsException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.ByteBufferAsCharBufferL.subSequence(int, int)
public CharSequence subSequence(int start, int end) { int pos = position(); int lim = limit(); assert (pos <= lim); pos = (pos <= lim ? pos : lim); int len = lim - pos; if ((start < 0) || (end > len) || (start > end)) throw new IndexOutOfBoundsException(); int sublen = end - start; int off = offset + ((pos + start) << 1); assert (off >= 0); return new ByteBufferAsCharBufferL(bb, -1, 0, sublen, sublen, off); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.ByteBufferAsCharBufferL.toString(int, int)
public String toString(int start, int end) { if ((end > limit()) || (start > end)) throw new IndexOutOfBoundsException(); try { int len = end - start; char[] ca = new char[len]; CharBuffer cb = CharBuffer.wrap(ca); CharBuffer db = this.duplicate(); db.position(start); db.limit(end); cb.put(db); return new String(ca); } catch (StringIndexOutOfBoundsException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.ByteBufferAsCharBufferRB.subSequence(int, int)
public CharSequence subSequence(int start, int end) { int pos = position(); int lim = limit(); assert (pos <= lim); pos = (pos <= lim ? pos : lim); int len = lim - pos; if ((start < 0) || (end > len) || (start > end)) throw new IndexOutOfBoundsException(); int sublen = end - start; int off = offset + ((pos + start) << 1); assert (off >= 0); return new ByteBufferAsCharBufferRB(bb, -1, 0, sublen, sublen, off); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.ByteBufferAsCharBufferRB.toString(int, int)
public String toString(int start, int end) { if ((end > limit()) || (start > end)) throw new IndexOutOfBoundsException(); try { int len = end - start; char[] ca = new char[len]; CharBuffer cb = CharBuffer.wrap(ca); CharBuffer db = this.duplicate(); db.position(start); db.limit(end); cb.put(db); return new String(ca); } catch (StringIndexOutOfBoundsException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.ByteBufferAsCharBufferRL.subSequence(int, int)
public CharSequence subSequence(int start, int end) { int pos = position(); int lim = limit(); assert (pos <= lim); pos = (pos <= lim ? pos : lim); int len = lim - pos; if ((start < 0) || (end > len) || (start > end)) throw new IndexOutOfBoundsException(); int sublen = end - start; int off = offset + ((pos + start) << 1); assert (off >= 0); return new ByteBufferAsCharBufferRL(bb, -1, 0, sublen, sublen, off); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.ByteBufferAsCharBufferRL.toString(int, int)
public String toString(int start, int end) { if ((end > limit()) || (start > end)) throw new IndexOutOfBoundsException(); try { int len = end - start; char[] ca = new char[len]; CharBuffer cb = CharBuffer.wrap(ca); CharBuffer db = this.duplicate(); db.position(start); db.limit(end); cb.put(db); return new String(ca); } catch (StringIndexOutOfBoundsException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.CharBuffer.wrap(CharSequence, int, int)
/** * Wraps a character sequence into a buffer. * The content of the new, read-only buffer will be the content of the * given character sequence. The buffer's capacity will be * <tt>csq.length()</tt>, its position will be <tt>start</tt>, its limit * will be <tt>end</tt>, and its mark will be undefined. * @param csq * The character sequence from which the new character buffer is to * be created * @param start * The index of the first character to be used; * must be non-negative and no larger than <tt>csq.length()</tt>. * The new buffer's position will be set to this value. * @param end * The index of the character following the last character to be * used; must be no smaller than <tt>start</tt> and no larger * than <tt>csq.length()</tt>. * The new buffer's limit will be set to this value. * @return The new character buffer * @throws IndexOutOfBoundsException * If the preconditions on the <tt>start</tt> and <tt>end</tt> * parameters do not hold */ public static CharBuffer wrap(CharSequence csq, int start, int end) { try { return new StringCharBuffer(csq, start, end); } catch (IllegalArgumentException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.CharBuffer.wrap(char[], int, int)
/** * Wraps a character array into a buffer. * The new buffer will be backed by the given character array; * that is, modifications to the buffer will cause the array to be modified * and vice versa. The new buffer's capacity will be * <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit * will be <tt>offset + length</tt>, and its mark will be undefined. Its * {@link #array </code>backing array<code>} will be the given array, and * its {@link #arrayOffset </code>array offset<code>} will be zero. * @param array * The array that will back the new buffer * @param offset * The offset of the subarray to be used; must be non-negative and * no larger than <tt>array.length</tt>. The new buffer's position * will be set to this value. * @param length * The length of the subarray to be used; * must be non-negative and no larger than * <tt>array.length - offset</tt>. * The new buffer's limit will be set to <tt>offset + length</tt>. * @return The new character buffer * @throws IndexOutOfBoundsException * If the preconditions on the <tt>offset</tt> and <tt>length</tt> * parameters do not hold */ public static CharBuffer wrap(char[] array, int offset, int length) { try { return new HeapCharBuffer(array, offset, length); } catch (IllegalArgumentException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.DirectCharBufferRS.subSequence(int, int)
public CharSequence subSequence(int start, int end) { int pos = position(); int lim = limit(); assert (pos <= lim); pos = (pos <= lim ? pos : lim); int len = lim - pos; if ((start < 0) || (end > len) || (start > end)) throw new IndexOutOfBoundsException(); int sublen = end - start; int off = (pos + start) << 1; assert (off >= 0); return new DirectCharBufferRS(this, -1, 0, sublen, sublen, off); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.DirectCharBufferRS.toString(int, int)
public String toString(int start, int end) { if ((end > limit()) || (start > end)) throw new IndexOutOfBoundsException(); try { int len = end - start; char[] ca = new char[len]; CharBuffer cb = CharBuffer.wrap(ca); CharBuffer db = this.duplicate(); db.position(start); db.limit(end); cb.put(db); return new String(ca); } catch (StringIndexOutOfBoundsException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.DirectCharBufferRU.subSequence(int, int)
public CharSequence subSequence(int start, int end) { int pos = position(); int lim = limit(); assert (pos <= lim); pos = (pos <= lim ? pos : lim); int len = lim - pos; if ((start < 0) || (end > len) || (start > end)) throw new IndexOutOfBoundsException(); int sublen = end - start; int off = (pos + start) << 1; assert (off >= 0); return new DirectCharBufferRU(this, -1, 0, sublen, sublen, off); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.DirectCharBufferRU.toString(int, int)
public String toString(int start, int end) { if ((end > limit()) || (start > end)) throw new IndexOutOfBoundsException(); try { int len = end - start; char[] ca = new char[len]; CharBuffer cb = CharBuffer.wrap(ca); CharBuffer db = this.duplicate(); db.position(start); db.limit(end); cb.put(db); return new String(ca); } catch (StringIndexOutOfBoundsException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.DirectCharBufferS.subSequence(int, int)
public CharSequence subSequence(int start, int end) { int pos = position(); int lim = limit(); assert (pos <= lim); pos = (pos <= lim ? pos : lim); int len = lim - pos; if ((start < 0) || (end > len) || (start > end)) throw new IndexOutOfBoundsException(); int sublen = end - start; int off = (pos + start) << 1; assert (off >= 0); return new DirectCharBufferS(this, -1, 0, sublen, sublen, off); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.DirectCharBufferS.toString(int, int)
public String toString(int start, int end) { if ((end > limit()) || (start > end)) throw new IndexOutOfBoundsException(); try { int len = end - start; char[] ca = new char[len]; CharBuffer cb = CharBuffer.wrap(ca); CharBuffer db = this.duplicate(); db.position(start); db.limit(end); cb.put(db); return new String(ca); } catch (StringIndexOutOfBoundsException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.DirectCharBufferU.subSequence(int, int)
public CharSequence subSequence(int start, int end) { int pos = position(); int lim = limit(); assert (pos <= lim); pos = (pos <= lim ? pos : lim); int len = lim - pos; if ((start < 0) || (end > len) || (start > end)) throw new IndexOutOfBoundsException(); int sublen = end - start; int off = (pos + start) << 1; assert (off >= 0); return new DirectCharBufferU(this, -1, 0, sublen, sublen, off); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.DirectCharBufferU.toString(int, int)
public String toString(int start, int end) { if ((end > limit()) || (start > end)) throw new IndexOutOfBoundsException(); try { int len = end - start; char[] ca = new char[len]; CharBuffer cb = CharBuffer.wrap(ca); CharBuffer db = this.duplicate(); db.position(start); db.limit(end); cb.put(db); return new String(ca); } catch (StringIndexOutOfBoundsException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.DoubleBuffer.wrap(double[], int, int)
/** * Wraps a double array into a buffer. * The new buffer will be backed by the given double array; * that is, modifications to the buffer will cause the array to be modified * and vice versa. The new buffer's capacity will be * <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit * will be <tt>offset + length</tt>, and its mark will be undefined. Its * {@link #array </code>backing array<code>} will be the given array, and * its {@link #arrayOffset </code>array offset<code>} will be zero. * @param array * The array that will back the new buffer * @param offset * The offset of the subarray to be used; must be non-negative and * no larger than <tt>array.length</tt>. The new buffer's position * will be set to this value. * @param length * The length of the subarray to be used; * must be non-negative and no larger than * <tt>array.length - offset</tt>. * The new buffer's limit will be set to <tt>offset + length</tt>. * @return The new double buffer * @throws IndexOutOfBoundsException * If the preconditions on the <tt>offset</tt> and <tt>length</tt> * parameters do not hold */ public static DoubleBuffer wrap(double[] array, int offset, int length) { try { return new HeapDoubleBuffer(array, offset, length); } catch (IllegalArgumentException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.FloatBuffer.wrap(float[], int, int)
/** * Wraps a float array into a buffer. * The new buffer will be backed by the given float array; * that is, modifications to the buffer will cause the array to be modified * and vice versa. The new buffer's capacity will be * <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit * will be <tt>offset + length</tt>, and its mark will be undefined. Its * {@link #array </code>backing array<code>} will be the given array, and * its {@link #arrayOffset </code>array offset<code>} will be zero. * @param array * The array that will back the new buffer * @param offset * The offset of the subarray to be used; must be non-negative and * no larger than <tt>array.length</tt>. The new buffer's position * will be set to this value. * @param length * The length of the subarray to be used; * must be non-negative and no larger than * <tt>array.length - offset</tt>. * The new buffer's limit will be set to <tt>offset + length</tt>. * @return The new float buffer * @throws IndexOutOfBoundsException * If the preconditions on the <tt>offset</tt> and <tt>length</tt> * parameters do not hold */ public static FloatBuffer wrap(float[] array, int offset, int length) { try { return new HeapFloatBuffer(array, offset, length); } catch (IllegalArgumentException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.HeapCharBuffer.subSequence(int, int)
public CharSequence subSequence(int start, int end) { if ((start < 0) || (end > length()) || (start > end)) throw new IndexOutOfBoundsException(); int len = end - start; return new HeapCharBuffer(hb, -1, 0, len, len, offset + position() + start); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.HeapCharBuffer.toString(int, int)
String toString(int start, int end) { try { return new String(hb, start + offset, end - start); } catch (StringIndexOutOfBoundsException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.HeapCharBufferR.subSequence(int, int)
public CharSequence subSequence(int start, int end) { if ((start < 0) || (end > length()) || (start > end)) throw new IndexOutOfBoundsException(); int len = end - start; return new HeapCharBufferR(hb, -1, 0, len, len, offset + position() + start); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.HeapCharBufferR.toString(int, int)
String toString(int start, int end) { try { return new String(hb, start + offset, end - start); } catch (StringIndexOutOfBoundsException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.IntBuffer.wrap(int[], int, int)
/** * Wraps a int array into a buffer. * The new buffer will be backed by the given int array; * that is, modifications to the buffer will cause the array to be modified * and vice versa. The new buffer's capacity will be * <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit * will be <tt>offset + length</tt>, and its mark will be undefined. Its * {@link #array </code>backing array<code>} will be the given array, and * its {@link #arrayOffset </code>array offset<code>} will be zero. * @param array * The array that will back the new buffer * @param offset * The offset of the subarray to be used; must be non-negative and * no larger than <tt>array.length</tt>. The new buffer's position * will be set to this value. * @param length * The length of the subarray to be used; * must be non-negative and no larger than * <tt>array.length - offset</tt>. * The new buffer's limit will be set to <tt>offset + length</tt>. * @return The new int buffer * @throws IndexOutOfBoundsException * If the preconditions on the <tt>offset</tt> and <tt>length</tt> * parameters do not hold */ public static IntBuffer wrap(int[] array, int offset, int length) { try { return new HeapIntBuffer(array, offset, length); } catch (IllegalArgumentException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.LongBuffer.wrap(long[], int, int)
/** * Wraps a long array into a buffer. * The new buffer will be backed by the given long array; * that is, modifications to the buffer will cause the array to be modified * and vice versa. The new buffer's capacity will be * <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit * will be <tt>offset + length</tt>, and its mark will be undefined. Its * {@link #array </code>backing array<code>} will be the given array, and * its {@link #arrayOffset </code>array offset<code>} will be zero. * @param array * The array that will back the new buffer * @param offset * The offset of the subarray to be used; must be non-negative and * no larger than <tt>array.length</tt>. The new buffer's position * will be set to this value. * @param length * The length of the subarray to be used; * must be non-negative and no larger than * <tt>array.length - offset</tt>. * The new buffer's limit will be set to <tt>offset + length</tt>. * @return The new long buffer * @throws IndexOutOfBoundsException * If the preconditions on the <tt>offset</tt> and <tt>length</tt> * parameters do not hold */ public static LongBuffer wrap(long[] array, int offset, int length) { try { return new HeapLongBuffer(array, offset, length); } catch (IllegalArgumentException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.ShortBuffer.wrap(short[], int, int)
/** * Wraps a short array into a buffer. * The new buffer will be backed by the given short array; * that is, modifications to the buffer will cause the array to be modified * and vice versa. The new buffer's capacity will be * <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit * will be <tt>offset + length</tt>, and its mark will be undefined. Its * {@link #array </code>backing array<code>} will be the given array, and * its {@link #arrayOffset </code>array offset<code>} will be zero. * @param array * The array that will back the new buffer * @param offset * The offset of the subarray to be used; must be non-negative and * no larger than <tt>array.length</tt>. The new buffer's position * will be set to this value. * @param length * The length of the subarray to be used; * must be non-negative and no larger than * <tt>array.length - offset</tt>. * The new buffer's limit will be set to <tt>offset + length</tt>. * @return The new short buffer * @throws IndexOutOfBoundsException * If the preconditions on the <tt>offset</tt> and <tt>length</tt> * parameters do not hold */ public static ShortBuffer wrap(short[] array, int offset, int length) { try { return new HeapShortBuffer(array, offset, length); } catch (IllegalArgumentException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.StringCharBuffer.subSequence(int, int)
public final CharSequence subSequence(int start, int end) { try { int pos = position(); return new StringCharBuffer(str, pos + checkIndex(start, pos), pos + checkIndex(end, pos)); } catch (IllegalArgumentException x) { throw new IndexOutOfBoundsException(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.nio.channels.Channels.newOutputStream(WritableByteChannel)
/** * Constructs a stream that writes bytes to the given channel. * The <tt>write</tt> methods of the resulting stream will throw an * {@link IllegalBlockingModeException} if invoked while the underlying * channel is in non-blocking mode. The stream will not be buffered. The * stream will be safe for access by multiple concurrent threads. Closing * the stream will in turn cause the channel to be closed. * @param ch * The channel to which bytes will be written * @return A new output stream */ public static OutputStream newOutputStream(final WritableByteChannel ch) { return new OutputStream() { private ByteBuffer bb = null; private byte[] bs = null; private byte[] b1 = null; public synchronized void write(int b) throws IOException { if (b1 == null) b1 = new byte[1]; b1[0] = (byte) b; this.write(b1); } public synchronized void write(byte[] bs, int off, int len) throws IOException { if ((off < 0) || (off > bs.length) || (len < 0) || ((off + len) > bs.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } ByteBuffer bb = ((this.bs == bs) ? this.bb : ByteBuffer.wrap(bs)); bb.limit(Math.min(off + len, bb.capacity())); bb.position(off); this.bb = bb; this.bs = bs; Channels.write(ch, bb); } public void close() throws IOException { ch.close(); } }; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.AbstractList.add(int, E)
/** * Inserts the specified element at the specified position in this list * (optional operation). Shifts the element currently at that position * (if any) and any subsequent elements to the right (adds one to their * indices). * This implementation always throws an UnsupportedOperationException. * @param index index at which the specified element is to be inserted. * @param element element to be inserted. * @throws UnsupportedOperationException if the <tt>add</tt> method is not * supported by this list. * @throws ClassCastException if the class of the specified element * prevents it from being added to this list. * @throws IllegalArgumentException if some aspect of the specified * element prevents it from being added to this list. * @throws IndexOutOfBoundsException index is out of range (<tt>index < * 0 || index > size()</tt>). */ public void add(int index, E element) { throw new UnsupportedOperationException(); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.AbstractList.add(int, E)
public void add(int index, E element) { if (index < 0 || index > size) throw new IndexOutOfBoundsException(); checkForComodification(); l.add(index + offset, element); expectedModCount = l.modCount; size++; modCount++; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.concurrent.CopyOnWriteArrayList.removeRange(int, int)
/** * Removes from this List all of the elements whose index is between * fromIndex, inclusive and toIndex, exclusive. Shifts any succeeding * elements to the left (reduces their index). * This call shortens the list by <tt>(toIndex - fromIndex)</tt> elements. * (If <tt>toIndex==fromIndex</tt>, this operation has no effect.) * @param fromIndex index of first element to be removed. * @param toIndex index after last element to be removed. * @throws IndexOutOfBoundsException fromIndex or toIndex out of * range (fromIndex < 0 || fromIndex >= size() || toIndex * > size() || toIndex < fromIndex). */ private synchronized void removeRange(int fromIndex, int toIndex) { int len = array.length; if (fromIndex < 0 || fromIndex >= len || toIndex > len || toIndex < fromIndex) throw new IndexOutOfBoundsException(); int numMoved = len - toIndex; int newlen = len - (toIndex - fromIndex); E[] newArray = (E[]) new Object[newlen]; System.arraycopy(array, 0, newArray, 0, fromIndex); System.arraycopy(array, toIndex, newArray, fromIndex, numMoved); array = newArray; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.concurrent.CopyOnWriteArrayList.subList(int, int)
/** * Returns a view of the portion of this List between fromIndex, * inclusive, and toIndex, exclusive. The returned List is backed by this * List, so changes in the returned List are reflected in this List, and * vice-versa. While mutative operations are supported, they are * probably not very useful for CopyOnWriteArrayLists. * The semantics of the List returned by this method become undefined if * the backing list (i.e., this List) is <i>structurally modified</i> in * any way other than via the returned List. (Structural modifications are * those that change the size of the List, or otherwise perturb it in such * a fashion that iterations in progress may yield incorrect results.) * @param fromIndex low endpoint (inclusive) of the subList. * @param toIndex high endpoint (exclusive) of the subList. * @return a view of the specified range within this List. * @throws IndexOutOfBoundsException Illegal endpoint index value * (fromIndex < 0 || toIndex > size || fromIndex > toIndex). */ public synchronized List<E> subList(int fromIndex, int toIndex) { int len = array.length; if (fromIndex < 0 || toIndex > len || fromIndex > toIndex) throw new IndexOutOfBoundsException(); return new COWSubList<E>(this, fromIndex, toIndex); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.zip.DeflaterOutputStream.write(byte[], int, int)
/** * Writes an array of bytes to the compressed output stream. This * method will block until all the bytes are written. * @param b the data to be written * @param off the start offset of the data * @param len the length of the data * @exception IOException if an I/O error has occurred */ public void write(byte[] b, int off, int len) throws IOException { if (def.finished()) { throw new IOException('write beyond end of stream'); } if ((off | len | (off + len) | (b.length - (off + len))) < 0) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } if (!def.finished()) { int stride = buf.length; for (int i = 0; i < len; i += stride) { def.setInput(b, off + i, Math.min(stride, len - i)); while (!def.needsInput()) { deflate(); } } } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.zip.InflaterInputStream.read(byte[], int, int)
/** * Reads uncompressed data into an array of bytes. This method will * block until some input can be decompressed. * @param b the buffer into which the data is read * @param off the start offset of the data * @param len the maximum number of bytes read * @return the actual number of bytes read, or -1 if the end of the * compressed input is reached or a preset dictionary is needed * @exception ZipException if a ZIP format error has occurred * @exception IOException if an I/O error has occurred */ public int read(byte[] b, int off, int len) throws IOException { ensureOpen(); if ((off | len | (off + len) | (b.length - (off + len))) < 0) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } try { int n; while ((n = inf.inflate(b, off, len)) == 0) { if (inf.finished() || inf.needsDictionary()) { reachEOF = true; return -1; } if (inf.needsInput()) { fill(); } } return n; } catch (DataFormatException e) { String s = e.getMessage(); throw new ZipException(s != null ? s : 'Invalid ZLIB data format'); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.zip.ZipInputStream.read(byte[], int, int)
/** * Reads from the current ZIP entry into an array of bytes. Blocks until * some input is available. * @param b the buffer into which the data is read * @param off the start offset of the data * @param len the maximum number of bytes read * @return the actual number of bytes read, or -1 if the end of the * entry is reached * @exception ZipException if a ZIP file error has occurred * @exception IOException if an I/O error has occurred */ public int read(byte[] b, int off, int len) throws IOException { ensureOpen(); if (off < 0 || len < 0 || off > b.length - len) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } if (entry == null) { return -1; } switch(entry.method) { case DEFLATED: len = super.read(b, off, len); if (len == -1) { readEnd(entry); entryEOF = true; entry = null; } else { crc.update(b, off, len); } return len; case STORED: if (remaining <= 0) { entryEOF = true; entry = null; return -1; } if (len > remaining) { len = (int) remaining; } len = in.read(b, off, len); if (len == -1) { throw new ZipException('unexpected EOF'); } crc.update(b, off, len); remaining -= len; if (remaining == 0 && entry.crc != crc.getValue()) { throw new ZipException('invalid entry CRC (expected 0x' + Long.toHexString(entry.crc) + ' but got 0x' + Long.toHexString(crc.getValue()) + ')'); } return len; default: throw new InternalError('invalid compression method'); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.zip.ZipOutputStream.write(byte[], int, int)
/** * Writes an array of bytes to the current ZIP entry data. This method * will block until all the bytes are written. * @param b the data to be written * @param off the start offset in the data * @param len the number of bytes that are written * @exception ZipException if a ZIP file error has occurred * @exception IOException if an I/O error has occurred */ public synchronized void write(byte[] b, int off, int len) throws IOException { ensureOpen(); if (off < 0 || len < 0 || off > b.length - len) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return; } if (entry == null) { throw new ZipException('no current ZIP entry'); } switch(entry.method) { case DEFLATED: super.write(b, off, len); break; case STORED: written += len; if (written - locoff > entry.size) { throw new ZipException('attempt to write past end of STORED entry'); } out.write(b, off, len); break; default: throw new InternalError('invalid compression method'); } crc.update(b, off, len); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.FileCacheImageInputStream.read(byte[], int, int)
public int read(byte[] b, int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off + len > b.length || off + len < 0) { throw new IndexOutOfBoundsException(); } if (len == 0) { return 0; } checkClosed(); bitOffset = 0; long pos = readUntil(streamPos + len); len = (int) Math.min((long) len, pos - streamPos); if (len > 0) { cache.seek(streamPos); cache.readFully(b, off, len); streamPos += len; return len; } else { return -1; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.FileCacheImageOutputStream.seek(long)
/** * Sets the current stream position and resets the bit offset to * 0. It is legal to seek past the end of the file; an * <code>EOFException</code> will be thrown only if a read is * performed. The file length will not be increased until a write * is performed. * @exception IndexOutOfBoundsException if <code>pos</code> is smaller * than the flushed position. * @exception IOException if any other I/O error occurs. */ public void seek(long pos) throws IOException { checkClosed(); if (pos < flushedPos) { throw new IndexOutOfBoundsException(); } cache.seek(pos); this.streamPos = cache.getFilePointer(); maxStreamPos = Math.max(maxStreamPos, streamPos); this.bitOffset = 0; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.MemoryCache.read(byte[], int, int, long)
/** * Copy <code>len</code> bytes from the cache, starting * at cache position <code>pos</code>, into the array * <code>b</code> at offset <code>off</code>. * @exception NullPointerException if b is <code>null</code> * @exception IndexOutOfBoundsException if <code>off</code>, * <code>len</code> or <code>pos</code> are negative or if * <code>off + len > b.length</code> or if any portion of the * requested data is not in the cache (including if * <code>pos</code> is in a block that has already been disposed). */ public void read(byte[] b, int off, int len, long pos) throws IOException { if (b == null) { throw new NullPointerException('b == null!'); } if ((off < 0) || (len < 0) || (pos < 0) || (off + len > b.length) || (off + len < 0)) { throw new IndexOutOfBoundsException(); } if (pos + len > length) { throw new IndexOutOfBoundsException(); } long index = pos / BUFFER_LENGTH; int offset = (int) pos % BUFFER_LENGTH; while (len > 0) { int nbytes = Math.min(len, BUFFER_LENGTH - offset); byte[] buf = getCacheBlock(index++); System.arraycopy(buf, offset, b, off, nbytes); len -= nbytes; off += nbytes; offset = 0; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.MemoryCache.write(byte[], int, int, long)
/** * Overwrites and/or appends the cache from a byte array. * The length of the cache will be extended as needed to hold * the incoming data. * @param b an array of bytes containing data to be written. * @param off the starting offset withing the data array. * @param len the number of bytes to be written. * @param pos the cache position at which to begin writing. * @exception NullPointerException if <code>b</code> is <code>null</code>. * @exception IndexOutOfBoundsException if <code>off</code>, * <code>len</code>, or <code>pos</code> are negative, * or if <code>off+len > b.length</code>. */ public void write(byte[] b, int off, int len, long pos) throws IOException { if (b == null) { throw new NullPointerException('b == null!'); } if ((off < 0) || (len < 0) || (pos < 0) || (off + len > b.length) || (off + len < 0)) { throw new IndexOutOfBoundsException(); } long lastPos = pos + len - 1; if (lastPos >= length) { pad(lastPos); length = lastPos + 1; } int offset = (int) (pos % BUFFER_LENGTH); while (len > 0) { byte[] buf = getCacheBlock(pos / BUFFER_LENGTH); int nbytes = Math.min(len, BUFFER_LENGTH - offset); System.arraycopy(b, off, buf, offset, nbytes); pos += nbytes; off += nbytes; len -= nbytes; offset = 0; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.jmx.remote.internal.ArrayQueue.get(int)
public T get(int i) { int size = size(); if (i < 0 || i >= size) { final String msg = 'Index ' + i + ', queue size ' + size; throw new IndexOutOfBoundsException(msg); } int index = (head + i) % capacity; return queue[index]; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.Vector.lastIndexOf(Object, int)
/** * Searches backwards for the specified object, starting from the * specified index, and returns an index to it. * @param elem the desired component. * @param index the index to start searching from. * @return the index of the last occurrence of the specified object in this * vector at position less than or equal to <code>index</code> in * the vector, that is, the largest value <tt>k</tt> such that * <tt>elem.equals(elementData[k]) && (k <= index)</tt> is * <tt>true</tt>; <code>-1</code> if the object is not found. * (Returns <code>-1</code> if <tt>index</tt> is negative.) * @exception IndexOutOfBoundsException if <tt>index</tt> is greater * than or equal to the current size of this vector. */ public synchronized int lastIndexOf(Object elem, int index) { if (index >= elementCount) throw new IndexOutOfBoundsException(index + ' >= ' + elementCount); if (elem == null) { for (int i = index; i >= 0; i--) if (elementData[i] == null) return i; } else { for (int i = index; i >= 0; i--) if (elem.equals(elementData[i])) return i; } return -1; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.bmp.BMPImageReader.checkIndex(int)
private void checkIndex(int imageIndex) { if (imageIndex != 0) { throw new IndexOutOfBoundsException(I18N.getString('BMPImageReader0')); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.wbmp.WBMPImageReader.checkIndex(int)
private void checkIndex(int imageIndex) { if (imageIndex != 0) { throw new IndexOutOfBoundsException(I18N.getString('WBMPImageReader0')); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.MemoryCache.writeToStream(OutputStream, long, long)
/** * Writes out a portion of the cache to an <code>OutputStream</code>. * This method preserves no state about the output stream, and does * not dispose of any blocks containing bytes written. To dispose * blocks, use {@link #disposeBefore <code>disposeBefore()</code>}. * @exception IndexOutOfBoundsException if any portion of * the requested data is not in the cache (including if <code>pos</code> * is in a block already disposed), or if either <code>pos</code> or * <code>len</code> is < 0. */ public void writeToStream(OutputStream stream, long pos, long len) throws IOException { if (pos + len > length) { throw new IndexOutOfBoundsException('Argument out of cache'); } if ((pos < 0) || (len < 0)) { throw new IndexOutOfBoundsException('Negative pos or len'); } if (len == 0) { return; } long bufIndex = pos / BUFFER_LENGTH; if (bufIndex < cacheStart) { throw new IndexOutOfBoundsException('pos already disposed'); } int offset = (int) (pos % BUFFER_LENGTH); byte[] buf = getCacheBlock(bufIndex++); while (len > 0) { if (buf == null) { buf = getCacheBlock(bufIndex++); offset = 0; } int nbytes = (int) Math.min(len, (long) (BUFFER_LENGTH - offset)); stream.write(buf, offset, nbytes); buf = null; len -= nbytes; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.gif.GIFImageReader.readMetadata()
private void readMetadata() throws IIOException { if (stream == null) { throw new IllegalStateException('Input not set!'); } try { this.imageMetadata = new GIFImageMetadata(); long startPosition = stream.getStreamPosition(); while (true) { int blockType = stream.readUnsignedByte(); if (blockType == 0x2c) { imageMetadata.imageLeftPosition = stream.readUnsignedShort(); imageMetadata.imageTopPosition = stream.readUnsignedShort(); imageMetadata.imageWidth = stream.readUnsignedShort(); imageMetadata.imageHeight = stream.readUnsignedShort(); int idPackedFields = stream.readUnsignedByte(); boolean localColorTableFlag = (idPackedFields & 0x80) != 0; imageMetadata.interlaceFlag = (idPackedFields & 0x40) != 0; imageMetadata.sortFlag = (idPackedFields & 0x20) != 0; int numLCTEntries = 1 << ((idPackedFields & 0x7) + 1); if (localColorTableFlag) { imageMetadata.localColorTable = new byte[3 * numLCTEntries]; stream.readFully(imageMetadata.localColorTable); } else { imageMetadata.localColorTable = null; } this.imageMetadataLength = (int) (stream.getStreamPosition() - startPosition); return; } else if (blockType == 0x21) { int label = stream.readUnsignedByte(); if (label == 0xf9) { int gceLength = stream.readUnsignedByte(); int gcePackedFields = stream.readUnsignedByte(); imageMetadata.disposalMethod = (gcePackedFields >> 2) & 0x3; imageMetadata.userInputFlag = (gcePackedFields & 0x2) != 0; imageMetadata.transparentColorFlag = (gcePackedFields & 0x1) != 0; imageMetadata.delayTime = stream.readUnsignedShort(); imageMetadata.transparentColorIndex = stream.readUnsignedByte(); int terminator = stream.readUnsignedByte(); } else if (label == 0x1) { int length = stream.readUnsignedByte(); imageMetadata.hasPlainTextExtension = true; imageMetadata.textGridLeft = stream.readUnsignedShort(); imageMetadata.textGridTop = stream.readUnsignedShort(); imageMetadata.textGridWidth = stream.readUnsignedShort(); imageMetadata.textGridHeight = stream.readUnsignedShort(); imageMetadata.characterCellWidth = stream.readUnsignedByte(); imageMetadata.characterCellHeight = stream.readUnsignedByte(); imageMetadata.textForegroundColor = stream.readUnsignedByte(); imageMetadata.textBackgroundColor = stream.readUnsignedByte(); imageMetadata.text = concatenateBlocks(); } else if (label == 0xfe) { byte[] comment = concatenateBlocks(); if (imageMetadata.comments == null) { imageMetadata.comments = new ArrayList(); } imageMetadata.comments.add(comment); } else if (label == 0xff) { int blockSize = stream.readUnsignedByte(); byte[] applicationID = new byte[8]; stream.readFully(applicationID); byte[] authCode = new byte[3]; stream.readFully(authCode); byte[] applicationData = concatenateBlocks(); if (imageMetadata.applicationIDs == null) { imageMetadata.applicationIDs = new ArrayList(); imageMetadata.authenticationCodes = new ArrayList(); imageMetadata.applicationData = new ArrayList(); } imageMetadata.applicationIDs.add(applicationID); imageMetadata.authenticationCodes.add(authCode); imageMetadata.applicationData.add(applicationData); } else { int length = 0; do { length = stream.readUnsignedByte(); stream.skipBytes(length); } while (length > 0); } } else if (blockType == 0x3b) { throw new IndexOutOfBoundsException('Attempt to read past end of image sequence!'); } else { throw new IIOException('Unexpected block type ' + blockType + '!'); } } } catch (IIOException iioe) { throw iioe; } catch (IOException ioe) { throw new IIOException('I/O error reading image metadata!', ioe); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.gif.GIFImageReader.getImageMetadata(int)
public IIOMetadata getImageMetadata(int imageIndex) throws IIOException { checkIndex(imageIndex); int index = locateImage(imageIndex); if (index != imageIndex) { throw new IndexOutOfBoundsException('Bad image index!'); } readMetadata(); return imageMetadata; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.jmx.snmp.BerDecoder.fetchAny()
/** * Fetch an <CODE>ANY</CODE> value. In fact, this method does not decode anything * it simply returns the next TLV as an array of bytes. * @return The TLV as a byte array. * @exception BerException The next TLV is really badly encoded... */ public byte[] fetchAny() throws BerException { byte[] result = null; final int backup = next; try { final int tag = fetchTag(); final int contentLength = fetchLength(); if (contentLength < 0) throw new BerException(); final int tlvLength = next + contentLength - backup; if (contentLength > (bytes.length - next)) throw new IndexOutOfBoundsException('Decoded length exceeds buffer'); final byte[] data = new byte[tlvLength]; java.lang.System.arraycopy(bytes, backup, data, 0, tlvLength); next = next + contentLength; result = data; } catch (IndexOutOfBoundsException e) { next = backup; throw new BerException(); } return result; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.jmx.snmp.BerDecoder.fetchIntegerValue()
/** * Fetch an integer value and move the current position forward. * @return The integer */ private int fetchIntegerValue() throws BerException { int result = 0; final int backup = next; try { final int length = fetchLength(); if (length <= 0) throw new BerException(); if (length > (bytes.length - next)) throw new IndexOutOfBoundsException('Decoded length exceeds buffer'); final int end = next + length; result = bytes[next++]; while (next < end) { final byte b = bytes[next++]; if (b < 0) { result = (result << 8) | (256 + b); } else { result = (result << 8) | b; } } } catch (BerException e) { next = backup; throw e; } catch (IndexOutOfBoundsException e) { next = backup; throw new BerException(); } catch (ArithmeticException e) { next = backup; throw new BerException(); } return result; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.jmx.snmp.BerDecoder.fetchIntegerValueAsLong()
/** * Fetch an integer value and return a long value. * FIX ME: someday we could have only on fetchIntegerValue() which always * returns a long value. * @return The integer */ private final long fetchIntegerValueAsLong() throws BerException { long result = 0; final int backup = next; try { final int length = fetchLength(); if (length <= 0) throw new BerException(); if (length > (bytes.length - next)) throw new IndexOutOfBoundsException('Decoded length exceeds buffer'); final int end = next + length; result = bytes[next++]; while (next < end) { final byte b = bytes[next++]; if (b < 0) { result = (result << 8) | (256 + b); } else { result = (result << 8) | b; } } } catch (BerException e) { next = backup; throw e; } catch (IndexOutOfBoundsException e) { next = backup; throw new BerException(); } catch (ArithmeticException e) { next = backup; throw new BerException(); } return result; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.jmx.snmp.BerDecoder.fetchOidValue()
/** * Fetch an oid and move the current position forward. * @return The oid */ private final long[] fetchOidValue() throws BerException { long[] result = null; final int backup = next; try { final int length = fetchLength(); if (length <= 0) throw new BerException(); if (length > (bytes.length - next)) throw new IndexOutOfBoundsException('Decoded length exceeds buffer'); int subidCount = 2; for (int i = 1; i < length; i++) { if ((bytes[next + i] & 0x80) == 0) { subidCount++; } } final int datalen = subidCount; final long[] data = new long[datalen]; final byte b0 = bytes[next++]; if (b0 < 0) throw new BerException(); final long lb0 = b0 / 40; if (lb0 > 2) throw new BerException(); final long lb1 = b0 % 40; data[0] = lb0; data[1] = lb1; int i = 2; while (i < datalen) { long subid = 0; byte b = bytes[next++]; while ((b & 0x80) != 0) { subid = (subid << 7) | (b & 0x7f); if (subid < 0) throw new BerException(); b = bytes[next++]; } subid = (subid << 7) | b; if (subid < 0) throw new BerException(); data[i++] = subid; } result = data; } catch (BerException e) { next = backup; throw e; } catch (IndexOutOfBoundsException e) { next = backup; throw new BerException(); } return result; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.jmx.snmp.BerDecoder.fetchStringValue()
/** * Fetch a byte string and move the current position forward. * @return The byte string */ private byte[] fetchStringValue() throws BerException { byte[] result = null; final int backup = next; try { final int length = fetchLength(); if (length < 0) throw new BerException(); if (length > (bytes.length - next)) throw new IndexOutOfBoundsException('Decoded length exceeds buffer'); final byte data[] = new byte[length]; java.lang.System.arraycopy(bytes, next, data, 0, length); next += length; result = data; } catch (BerException e) { next = backup; throw e; } catch (IndexOutOfBoundsException e) { next = backup; throw new BerException(); } catch (ArithmeticException e) { next = backup; throw new BerException(); } return result; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.regex.Matcher.find(int)
/** * Resets this matcher and then attempts to find the next subsequence of * the input sequence that matches the pattern, starting at the specified * index. * If the match succeeds then more information can be obtained via the * <tt>start</tt>, <tt>end</tt>, and <tt>group</tt> methods, and subsequent * invocations of the {@link #find()} method will start at the first * character not matched by this match. * @throws IndexOutOfBoundsException * If start is less than zero or if start is greater than the * length of the input sequence. * @return <tt>true</tt> if, and only if, a subsequence of the input * sequence starting at the given index matches this matcher's * pattern */ public boolean find(int start) { int limit = getTextLength(); if ((start < 0) || (start > limit)) throw new IndexOutOfBoundsException('Illegal start index'); reset(); return search(start); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.AbstractList.listIterator(int)
/** * Returns a list iterator of the elements in this list (in proper * sequence), starting at the specified position in the list. The * specified index indicates the first element that would be returned by * an initial call to the <tt>next</tt> method. An initial call to * the <tt>previous</tt> method would return the element with the * specified index minus one. * This implementation returns a straightforward implementation of the * <tt>ListIterator</tt> interface that extends the implementation of the * <tt>Iterator</tt> interface returned by the <tt>iterator()</tt> method. * The <tt>ListIterator</tt> implementation relies on the backing list's * <tt>get(int)</tt>, <tt>set(int, Object)</tt>, <tt>add(int, Object)</tt> * and <tt>remove(int)</tt> methods. * Note that the list iterator returned by this implementation will throw * an <tt>UnsupportedOperationException</tt> in response to its * <tt>remove</tt>, <tt>set</tt> and <tt>add</tt> methods unless the * list's <tt>remove(int)</tt>, <tt>set(int, Object)</tt>, and * <tt>add(int, Object)</tt> methods are overridden. * This implementation can be made to throw runtime exceptions in the * face of concurrent modification, as described in the specification for * the (protected) <tt>modCount</tt> field. * @param index index of the first element to be returned from the list * iterator (by a call to the <tt>next</tt> method). * @return a list iterator of the elements in this list (in proper * sequence), starting at the specified position in the list. * @throws IndexOutOfBoundsException if the specified index is out of * range (<tt>index < 0 || index > size()</tt>). * @see #modCount */ public ListIterator<E> listIterator(final int index) { if (index < 0 || index > size()) throw new IndexOutOfBoundsException('Index: ' + index); return new ListItr(index); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.AbstractList.listIterator(int)
public ListIterator<E> listIterator(final int index) { checkForComodification(); if (index < 0 || index > size) throw new IndexOutOfBoundsException('Index: ' + index + ', Size: ' + size); return new ListIterator<E>() { private ListIterator<E> i = l.listIterator(index + offset); public boolean hasNext() { return nextIndex() < size; } public E next() { if (hasNext()) return i.next(); else throw new NoSuchElementException(); } public boolean hasPrevious() { return previousIndex() >= 0; } public E previous() { if (hasPrevious()) return i.previous(); else throw new NoSuchElementException(); } public int nextIndex() { return i.nextIndex() - offset; } public int previousIndex() { return i.previousIndex() - offset; } public void remove() { i.remove(); expectedModCount = l.modCount; size--; modCount++; } public void set(E o) { i.set(o); } public void add(E o) { i.add(o); expectedModCount = l.modCount; size++; modCount++; } }; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.concurrent.CopyOnWriteArrayList.listIterator(int)
/** * Returns a ListIterator of the elements in this List (in proper * sequence), starting at the specified position in the List. The * specified index indicates the first element that would be returned by * an initial call to nextElement. An initial call to previousElement * would return the element with the specified index minus one. * The ListIterator returned by this implementation will throw * an UnsupportedOperationException in its remove, set and * add methods. * @param index index of first element to be returned from the * ListIterator (by a call to getNext). * @return the iterator * @throws IndexOutOfBoundsException index is out of range * (index < 0 || index > size()). */ public ListIterator<E> listIterator(final int index) { E[] elementData = array(); int len = elementData.length; if (index < 0 || index > len) throw new IndexOutOfBoundsException('Index: ' + index); return new COWIterator<E>(array(), index); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.ArrayList.RangeCheck(int)
/** * Check if the given index is in range. If not, throw an appropriate * runtime exception. This method does *not* check if the index is * negative: It is always used immediately prior to an array access, * which throws an ArrayIndexOutOfBoundsException if index is negative. */ private void RangeCheck(int index) { if (index >= size) throw new IndexOutOfBoundsException('Index: ' + index + ', Size: ' + size); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.ArrayList.add(int, E)
/** * Inserts the specified element at the specified position in this * list. Shifts the element currently at that position (if any) and * any subsequent elements to the right (adds one to their indices). * @param index index at which the specified element is to be inserted. * @param element element to be inserted. * @throws IndexOutOfBoundsException if index is out of range * <tt>(index < 0 || index > size())</tt>. */ public void add(int index, E element) { if (index > size || index < 0) throw new IndexOutOfBoundsException('Index: ' + index + ', Size: ' + size); ensureCapacity(size + 1); System.arraycopy(elementData, index, elementData, index + 1, size - index); elementData[index] = element; size++; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.LinkedList.entry(int)
/** * Return the indexed entry. */ private Entry<E> entry(int index) { if (index < 0 || index >= size) throw new IndexOutOfBoundsException('Index: ' + index + ', Size: ' + size); Entry<E> e = header; if (index < (size >> 1)) { for (int i = 0; i <= index; i++) e = e.next; } else { for (int i = size; i > index; i--) e = e.previous; } return e; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.concurrent.CopyOnWriteArrayList.add(int, E)
/** * Inserts the specified element at the specified position in this * list. Shifts the element currently at that position (if any) and * any subsequent elements to the right (adds one to their indices). * @param index index at which the specified element is to be inserted. * @param element element to be inserted. * @throws IndexOutOfBoundsException if index is out of range * <tt>(index < 0 || index > size())</tt>. */ public synchronized void add(int index, E element) { int len = array.length; if (index > len || index < 0) throw new IndexOutOfBoundsException('Index: ' + index + ', Size: ' + len); E[] newArray = (E[]) new Object[len + 1]; System.arraycopy(array, 0, newArray, 0, index); newArray[index] = element; System.arraycopy(array, index, newArray, index + 1, len - index); array = newArray; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.concurrent.CopyOnWriteArrayList.rangeCheck(int, int)
/** * Check if the given index is in range. If not, throw an appropriate * runtime exception. */ private void rangeCheck(int index, int length) { if (index >= length || index < 0) throw new IndexOutOfBoundsException('Index: ' + index + ', Size: ' + length); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.swing.JTabbedPane.checkIndex(int)
private void checkIndex(int index) { if (index < 0 || index >= pages.size()) { throw new IndexOutOfBoundsException('Index: ' + index + ', Tab count: ' + pages.size()); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.AbstractList.rangeCheck(int)
private void rangeCheck(int index) { if (index < 0 || index >= size) throw new IndexOutOfBoundsException('Index: ' + index + ',Size: ' + size); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.regex.Matcher.end(int)
/** * Returns the offset after the last character of the subsequence * captured by the given group during the previous match operation. * <a href='Pattern.html#cg'>Capturing groups</a> are indexed from left * to right, starting at one. Group zero denotes the entire pattern, so * the expression <i>m.</i><tt>end(0)</tt> is equivalent to * <i>m.</i><tt>end()</tt>. * @param group * The index of a capturing group in this matcher's pattern * @return The offset after the last character captured by the group, * or <tt>-1</tt> if the match was successful * but the group itself did not match anything * @throws IllegalStateException * If no match has yet been attempted, * or if the previous match operation failed * @throws IndexOutOfBoundsException * If there is no capturing group in the pattern * with the given index */ public int end(int group) { if (first < 0) throw new IllegalStateException('No match available'); if (group > groupCount()) throw new IndexOutOfBoundsException('No group ' + group); return groups[group * 2 + 1]; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.regex.Matcher.group(int)
/** * Returns the input subsequence captured by the given group during the * previous match operation. * For a matcher <i>m</i>, input sequence <i>s</i>, and group index * <i>g</i>, the expressions <i>m.</i><tt>group(</tt><i>g</i><tt>)</tt> and * <i>s.</i><tt>substring(</tt><i>m.</i><tt>start(</tt><i>g</i><tt>),</tt> <i>m.</i><tt>end(</tt><i>g</i><tt>))</tt> * are equivalent. * <a href='Pattern.html#cg'>Capturing groups</a> are indexed from left * to right, starting at one. Group zero denotes the entire pattern, so * the expression <tt>m.group(0)</tt> is equivalent to <tt>m.group()</tt>. * * If the match was successful but the group specified failed to match * any part of the input sequence, then <tt>null</tt> is returned. Note * that some groups, for example <tt>(a*)</tt>, match the empty string. * This method will return the empty string when such a group successfully * matches the empty string in the input. * @param group * The index of a capturing group in this matcher's pattern * @return The (possibly empty) subsequence captured by the group * during the previous match, or <tt>null</tt> if the group * failed to match part of the input * @throws IllegalStateException * If no match has yet been attempted, * or if the previous match operation failed * @throws IndexOutOfBoundsException * If there is no capturing group in the pattern * with the given index */ public String group(int group) { if (first < 0) throw new IllegalStateException('No match found'); if (group < 0 || group > groupCount()) throw new IndexOutOfBoundsException('No group ' + group); if ((groups[group * 2] == -1) || (groups[group * 2 + 1] == -1)) return null; return getSubSequence(groups[group * 2], groups[group * 2 + 1]).toString(); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.regex.Matcher.start(int)
/** * Returns the start index of the subsequence captured by the given group * during the previous match operation. * <a href='Pattern.html#cg'>Capturing groups</a> are indexed from left * to right, starting at one. Group zero denotes the entire pattern, so * the expression <i>m.</i><tt>start(0)</tt> is equivalent to * <i>m.</i><tt>start()</tt>. * @param group * The index of a capturing group in this matcher's pattern * @return The index of the first character captured by the group, * or <tt>-1</tt> if the match was successful but the group * itself did not match anything * @throws IllegalStateException * If no match has yet been attempted, * or if the previous match operation failed * @throws IndexOutOfBoundsException * If there is no capturing group in the pattern * with the given index */ public int start(int group) { if (first < 0) throw new IllegalStateException('No match available'); if (group > groupCount()) throw new IndexOutOfBoundsException('No group ' + group); return groups[group * 2]; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.jpeg.JPEGImageReader.getThumbnailHeight(int, int)
public int getThumbnailHeight(int imageIndex, int thumbnailIndex) throws IOException { if ((thumbnailIndex < 0) || (thumbnailIndex >= getNumThumbnails(imageIndex))) { throw new IndexOutOfBoundsException('No such thumbnail'); } JFIFMarkerSegment jfif = (JFIFMarkerSegment) imageMetadata.findMarkerSegment(JFIFMarkerSegment.class, true); return jfif.getThumbnailHeight(thumbnailIndex); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.jpeg.JPEGImageReader.getThumbnailWidth(int, int)
public int getThumbnailWidth(int imageIndex, int thumbnailIndex) throws IOException { if ((thumbnailIndex < 0) || (thumbnailIndex >= getNumThumbnails(imageIndex))) { throw new IndexOutOfBoundsException('No such thumbnail'); } JFIFMarkerSegment jfif = (JFIFMarkerSegment) imageMetadata.findMarkerSegment(JFIFMarkerSegment.class, true); return jfif.getThumbnailWidth(thumbnailIndex); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.jpeg.JPEGImageReader.readThumbnail(int, int)
public BufferedImage readThumbnail(int imageIndex, int thumbnailIndex) throws IOException { if ((thumbnailIndex < 0) || (thumbnailIndex >= getNumThumbnails(imageIndex))) { throw new IndexOutOfBoundsException('No such thumbnail'); } JFIFMarkerSegment jfif = (JFIFMarkerSegment) imageMetadata.findMarkerSegment(JFIFMarkerSegment.class, true); return jfif.getThumbnail(iis, thumbnailIndex, this); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.IIOImage.getThumbnail(int)
/** * Returns a thumbnail associated with the main image. * @param index the index of the desired thumbnail image. * @return a thumbnail image, as a <code>BufferedImage</code>. * @exception IndexOutOfBoundsException if the supplied index is * negative or larger than the largest valid index. * @exception ClassCastException if a * non-<code>BufferedImage</code> object is encountered in the * list of thumbnails at the given index. * @see #getThumbnails * @see #setThumbnails */ public BufferedImage getThumbnail(int index) { if (thumbnails == null) { throw new IndexOutOfBoundsException('No thumbnails available!'); } return (BufferedImage) thumbnails.get(index); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.naming.ldap.LdapName.getPrefix(int)
/** * Creates a name whose components consist of a prefix of the * components of this LDAP name. * Subsequent changes to this name will not affect the name * that is returned and vice versa. * @param posn The 0-based index of the component at which to stop. * Must be in the range [0,size()]. * @return An instance of <tt>LdapName</tt> consisting of the * components at indexes in the range [0,posn). * If posn is zero, an empty LDAP name is returned. * @exception IndexOutOfBoundsException * If posn is outside the specified range. */ public Name getPrefix(int posn) { try { return new LdapName(null, rdns, 0, posn); } catch (IllegalArgumentException e) { throw new IndexOutOfBoundsException('Posn: ' + posn + ', Size: ' + rdns.size()); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.naming.ldap.LdapName.getSuffix(int)
/** * Creates a name whose components consist of a suffix of the * components in this LDAP name. * Subsequent changes to this name do not affect the name that is * returned and vice versa. * @param posn The 0-based index of the component at which to start. * Must be in the range [0,size()]. * @return An instance of <tt>LdapName</tt> consisting of the * components at indexes in the range [posn,size()). * If posn is equal to size(), an empty LDAP name is * returned. * @exception IndexOutOfBoundsException * If posn is outside the specified range. */ public Name getSuffix(int posn) { try { return new LdapName(null, rdns, posn, rdns.size()); } catch (IllegalArgumentException e) { throw new IndexOutOfBoundsException('Posn: ' + posn + ', Size: ' + rdns.size()); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.jmx.remote.internal.ArrayQueue.remove(int)
public T remove(int i) { if (i != 0) throw new IllegalArgumentException('Can only remove head of queue'); if (head == tail) throw new IndexOutOfBoundsException('Queue empty'); T removed = queue[head]; queue[head] = null; head = (head + 1) % capacity; return removed; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.jmx.remote.internal.ArrayQueue.add(T)
public boolean add(T o) { queue[tail] = o; int newtail = (tail + 1) % capacity; if (newtail == head) throw new IndexOutOfBoundsException('Queue full'); tail = newtail; return true; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.jmx.remote.internal.ArrayQueue.resize(int)
public void resize(int newcapacity) { int size = size(); if (newcapacity < size) throw new IndexOutOfBoundsException('Resizing would lose data'); newcapacity++; if (newcapacity == this.capacity) return; T[] newqueue = (T[]) new Object[newcapacity]; for (int i = 0; i < size; i++) newqueue[i] = get(i); this.capacity = newcapacity; this.queue = newqueue; this.head = 0; this.tail = size; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.Font.getStringBounds(CharacterIterator, int, int, FontRenderContext)
/** * Returns the logical bounds of the characters indexed in the * specified {@link CharacterIterator} in the * specified <code>FontRenderContext</code>. The logical bounds * contains the origin, ascent, advance, and height, which includes * the leading. The logical bounds does not always enclose all the * text. For example, in some languages and in some fonts, accent * marks can be positioned above the ascent or below the descent. * To obtain a visual bounding box, which encloses all the text, * use the {@link TextLayout#getBounds() getBounds} method of * <code>TextLayout</code>. * @param ci the specified <code>CharacterIterator</code> * @param beginIndex the initial offset in <code>ci</code> * @param limit the end offset in <code>ci</code> * @param frc the specified <code>FontRenderContext</code> * @return a <code>Rectangle2D</code> that is the bounding box of the * characters indexed in the specified <code>CharacterIterator</code> * in the specified <code>FontRenderContext</code>. * @see FontRenderContext * @see Font#createGlyphVector * @since 1.2 * @throws IndexOutOfBoundsException if <code>beginIndex</code> is * less than the start index of <code>ci</code>, or * <code>limit</code> is greater than the end index of * <code>ci</code>, or <code>beginIndex</code> is greater * than <code>limit</code> */ public Rectangle2D getStringBounds(CharacterIterator ci, int beginIndex, int limit, FontRenderContext frc) { int start = ci.getBeginIndex(); int end = ci.getEndIndex(); if (beginIndex < start) { throw new IndexOutOfBoundsException('beginIndex: ' + beginIndex); } if (limit > end) { throw new IndexOutOfBoundsException('limit: ' + limit); } if (beginIndex > limit) { throw new IndexOutOfBoundsException('range length: ' + (limit - beginIndex)); } char[] arr = new char[limit - beginIndex]; ci.setIndex(beginIndex); for (int idx = 0; idx < arr.length; idx++) { arr[idx] = ci.current(); ci.next(); } return getStringBounds(arr, 0, arr.length, frc); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.Font.getStringBounds(char[], int, int, FontRenderContext)
/** * Returns the logical bounds of the specified array of characters * in the specified <code>FontRenderContext</code>. The logical * bounds contains the origin, ascent, advance, and height, which * includes the leading. The logical bounds does not always enclose * all the text. For example, in some languages and in some fonts, * accent marks can be positioned above the ascent or below the * descent. To obtain a visual bounding box, which encloses all the * text, use the {@link TextLayout#getBounds() getBounds} method of * <code>TextLayout</code>. * @param chars an array of characters * @param beginIndex the initial offset in the array of * characters * @param limit the end offset in the array of characters * @param frc the specified <code>FontRenderContext</code> * @return a <code>Rectangle2D</code> that is the bounding box of the * specified array of characters in the specified * <code>FontRenderContext</code>. * @throws IndexOutOfBoundsException if <code>beginIndex</code> is * less than zero, or <code>limit</code> is greater than the * length of <code>chars</code>, or <code>beginIndex</code> * is greater than <code>limit</code>. * @see FontRenderContext * @see Font#createGlyphVector * @since 1.2 */ public Rectangle2D getStringBounds(char[] chars, int beginIndex, int limit, FontRenderContext frc) { if (beginIndex < 0) { throw new IndexOutOfBoundsException('beginIndex: ' + beginIndex); } if (limit > chars.length) { throw new IndexOutOfBoundsException('limit: ' + limit); } if (beginIndex > limit) { throw new IndexOutOfBoundsException('range length: ' + (limit - beginIndex)); } boolean simple = true; for (int i = beginIndex; i < limit; ++i) { char c = chars[i]; if (c >= '?' && c <= '?') { simple = false; break; } } if (simple) { GlyphVector gv = new StandardGlyphVector(this, chars, beginIndex, limit - beginIndex, frc); return gv.getLogicalBounds(); } else { String str = new String(chars, beginIndex, limit - beginIndex); TextLayout tl = new TextLayout(str, this, frc); return new Rectangle2D.Float(0, -tl.getAscent(), tl.getAdvance(), tl.getDescent() + tl.getLeading()); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.BitSet.clear(int)
/** * Sets the bit specified by the index to <code>false</code>. * @param bitIndex the index of the bit to be cleared. * @exception IndexOutOfBoundsException if the specified index is negative. * @since JDK1.0 */ public void clear(int bitIndex) { if (bitIndex < 0) throw new IndexOutOfBoundsException('bitIndex < 0: ' + bitIndex); int unitIndex = unitIndex(bitIndex); if (unitIndex >= unitsInUse) return; bits[unitIndex] &= ~bit(bitIndex); if (bits[unitsInUse - 1] == 0) recalculateUnitsInUse(); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.BitSet.flip(int)
/** * Sets the bit at the specified index to the complement of its * current value. * @param bitIndex the index of the bit to flip. * @exception IndexOutOfBoundsException if the specified index is negative. * @since 1.4 */ public void flip(int bitIndex) { if (bitIndex < 0) throw new IndexOutOfBoundsException('bitIndex < 0: ' + bitIndex); int unitIndex = unitIndex(bitIndex); int unitsRequired = unitIndex + 1; if (unitsInUse < unitsRequired) { ensureCapacity(unitsRequired); bits[unitIndex] ^= bit(bitIndex); unitsInUse = unitsRequired; } else { bits[unitIndex] ^= bit(bitIndex); if (bits[unitsInUse - 1] == 0) recalculateUnitsInUse(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.BitSet.get(int)
/** * Returns the value of the bit with the specified index. The value * is <code>true</code> if the bit with the index <code>bitIndex</code> * is currently set in this <code>BitSet</code>; otherwise, the result * is <code>false</code>. * @param bitIndex the bit index. * @return the value of the bit with the specified index. * @exception IndexOutOfBoundsException if the specified index is negative. */ public boolean get(int bitIndex) { if (bitIndex < 0) throw new IndexOutOfBoundsException('bitIndex < 0: ' + bitIndex); boolean result = false; int unitIndex = unitIndex(bitIndex); if (unitIndex < unitsInUse) result = ((bits[unitIndex] & bit(bitIndex)) != 0); return result; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.BitSet.set(int)
/** * Sets the bit at the specified index to <code>true</code>. * @param bitIndex a bit index. * @exception IndexOutOfBoundsException if the specified index is negative. * @since JDK1.0 */ public void set(int bitIndex) { if (bitIndex < 0) throw new IndexOutOfBoundsException('bitIndex < 0: ' + bitIndex); int unitIndex = unitIndex(bitIndex); int unitsRequired = unitIndex + 1; if (unitsInUse < unitsRequired) { ensureCapacity(unitsRequired); bits[unitIndex] |= bit(bitIndex); unitsInUse = unitsRequired; } else { bits[unitIndex] |= bit(bitIndex); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.lang.AbstractStringBuilder.insert(int, CharSequence, int, int)
/** * Inserts a subsequence of the specified <code>CharSequence</code> into * this sequence. * The subsequence of the argument <code>s</code> specified by * <code>start</code> and <code>end</code> are inserted, * in order, into this sequence at the specified destination offset, moving * up any characters originally above that position. The length of this * sequence is increased by <code>end - start</code>. * The character at index <i>k</i> in this sequence becomes equal to: * <ul> * <li>the character at index <i>k</i> in this sequence, if * <i>k</i> is less than <code>dstOffset</code> * <li>the character at index <i>k</i><code>+start-dstOffset</code> in * the argument <code>s</code>, if <i>k</i> is greater than or equal to * <code>dstOffset</code> but is less than <code>dstOffset+end-start</code> * <li>the character at index <i>k</i><code>-(end-start)</code> in this * sequence, if <i>k</i> is greater than or equal to * <code>dstOffset+end-start</code> * </ul> * The dstOffset argument must be greater than or equal to * <code>0</code>, and less than or equal to the length of this * sequence. * The start argument must be nonnegative, and not greater than * <code>end</code>. * The end argument must be greater than or equal to * <code>start</code>, and less than or equal to the length of s. * If <code>s</code> is <code>null</code>, then this method inserts * characters as if the s parameter was a sequence containing the four * characters <code>'null'</code>. * @param dstOffset the offset in this sequence. * @param s the sequence to be inserted. * @param start the starting index of the subsequence to be inserted. * @param end the end index of the subsequence to be inserted. * @return a reference to this object. * @throws IndexOutOfBoundsException if <code>dstOffset</code> * is negative or greater than <code>this.length()</code>, or * <code>start</code> or <code>end</code> are negative, or * <code>start</code> is greater than <code>end</code> or * <code>end</code> is greater than <code>s.length()</code> */ public AbstractStringBuilder insert(int dstOffset, CharSequence s, int start, int end) { if (s == null) s = 'null'; if ((dstOffset < 0) || (dstOffset > this.length())) throw new IndexOutOfBoundsException('dstOffset ' + dstOffset); if ((start < 0) || (end < 0) || (start > end) || (end > s.length())) throw new IndexOutOfBoundsException('start ' + start + ', end ' + end + ', s.length() ' + s.length()); int len = end - start; if (len == 0) return this; int newCount = count + len; if (newCount > value.length) expandCapacity(newCount); System.arraycopy(value, dstOffset, value, dstOffset + len, count - dstOffset); for (int i = start; i < end; i++) value[dstOffset++] = s.charAt(i); count = newCount; return this; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.regex.Matcher.region(int, int)
/** * Sets the limits of this matcher's region. The region is the part of the * input sequence that will be searched to find a match. Invoking this * method resets the matcher, and then sets the region to start at the * index specified by the <code>start</code> parameter and end at the * index specified by the <code>end</code> parameter. * Depending on the transparency and anchoring being used (see * {@link #useTransparentBounds useTransparentBounds} and * {@link #useAnchoringBounds useAnchoringBounds}), certain constructs such * as anchors may behave differently at or around the boundaries of the * region. * @param start * The index to start searching at (inclusive) * @param end * The index to end searching at (exclusive) * @throws IndexOutOfBoundsException * If start or end is less than zero, if * start is greater than the length of the input sequence, if * end is greater than the length of the input sequence, or if * start is greater than end. * @return this matcher * @since 1.5 */ public Matcher region(int start, int end) { if ((start < 0) || (start > getTextLength())) throw new IndexOutOfBoundsException('start'); if ((end < 0) || (end > getTextLength())) throw new IndexOutOfBoundsException('end'); if (start > end) throw new IndexOutOfBoundsException('start > end'); reset(); from = start; to = end; return this; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.BitSet.clear(int, int)
/** * Sets the bits from the specified fromIndex(inclusive) to the * specified toIndex(exclusive) to <code>false</code>. * @param fromIndex index of the first bit to be cleared. * @param toIndex index after the last bit to be cleared. * @exception IndexOutOfBoundsException if <tt>fromIndex</tt> is negative, * or <tt>toIndex</tt> is negative, or <tt>fromIndex</tt> is * larger than <tt>toIndex</tt>. * @since 1.4 */ public void clear(int fromIndex, int toIndex) { if (fromIndex < 0) throw new IndexOutOfBoundsException('fromIndex < 0: ' + fromIndex); if (toIndex < 0) throw new IndexOutOfBoundsException('toIndex < 0: ' + toIndex); if (fromIndex > toIndex) throw new IndexOutOfBoundsException('fromIndex: ' + fromIndex + ' > toIndex: ' + toIndex); int startUnitIndex = unitIndex(fromIndex); if (startUnitIndex >= unitsInUse) return; int endUnitIndex = unitIndex(toIndex); long bitMask = 0; if (startUnitIndex == endUnitIndex) { bitMask = (1L << (toIndex & BIT_INDEX_MASK)) - (1L << (fromIndex & BIT_INDEX_MASK)); bits[startUnitIndex] &= ~bitMask; if (bits[unitsInUse - 1] == 0) recalculateUnitsInUse(); return; } bitMask = bitsLeftOf(fromIndex & BIT_INDEX_MASK); bits[startUnitIndex] &= ~bitMask; if (endUnitIndex - startUnitIndex > 1) { for (int i = startUnitIndex + 1; i < endUnitIndex; i++) { if (i < unitsInUse) bits[i] = 0; } } if (endUnitIndex < unitsInUse) { bitMask = bitsRightOf(toIndex & BIT_INDEX_MASK); bits[endUnitIndex] &= ~bitMask; } if (bits[unitsInUse - 1] == 0) recalculateUnitsInUse(); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.BitSet.flip(int, int)
/** * Sets each bit from the specified fromIndex(inclusive) to the * specified toIndex(exclusive) to the complement of its current * value. * @param fromIndex index of the first bit to flip. * @param toIndex index after the last bit to flip. * @exception IndexOutOfBoundsException if <tt>fromIndex</tt> is negative, * or <tt>toIndex</tt> is negative, or <tt>fromIndex</tt> is * larger than <tt>toIndex</tt>. * @since 1.4 */ public void flip(int fromIndex, int toIndex) { if (fromIndex < 0) throw new IndexOutOfBoundsException('fromIndex < 0: ' + fromIndex); if (toIndex < 0) throw new IndexOutOfBoundsException('toIndex < 0: ' + toIndex); if (fromIndex > toIndex) throw new IndexOutOfBoundsException('fromIndex: ' + fromIndex + ' > toIndex: ' + toIndex); int endUnitIndex = unitIndex(toIndex); int unitsRequired = endUnitIndex + 1; if (unitsInUse < unitsRequired) { ensureCapacity(unitsRequired); unitsInUse = unitsRequired; } int startUnitIndex = unitIndex(fromIndex); long bitMask = 0; if (startUnitIndex == endUnitIndex) { bitMask = (1L << (toIndex & BIT_INDEX_MASK)) - (1L << (fromIndex & BIT_INDEX_MASK)); bits[startUnitIndex] ^= bitMask; if (bits[unitsInUse - 1] == 0) recalculateUnitsInUse(); return; } bitMask = bitsLeftOf(fromIndex & BIT_INDEX_MASK); bits[startUnitIndex] ^= bitMask; if (endUnitIndex - startUnitIndex > 1) { for (int i = startUnitIndex + 1; i < endUnitIndex; i++) bits[i] ^= WORD_MASK; } bitMask = bitsRightOf(toIndex & BIT_INDEX_MASK); bits[endUnitIndex] ^= bitMask; if (bits[unitsInUse - 1] == 0) recalculateUnitsInUse(); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.BitSet.get(int, int)
/** * Returns a new <tt>BitSet</tt> composed of bits from this <tt>BitSet</tt> * from <tt>fromIndex</tt>(inclusive) to <tt>toIndex</tt>(exclusive). * @param fromIndex index of the first bit to include. * @param toIndex index after the last bit to include. * @return a new <tt>BitSet</tt> from a range of this <tt>BitSet</tt>. * @exception IndexOutOfBoundsException if <tt>fromIndex</tt> is negative, * or <tt>toIndex</tt> is negative, or <tt>fromIndex</tt> is * larger than <tt>toIndex</tt>. * @since 1.4 */ public BitSet get(int fromIndex, int toIndex) { if (fromIndex < 0) throw new IndexOutOfBoundsException('fromIndex < 0: ' + fromIndex); if (toIndex < 0) throw new IndexOutOfBoundsException('toIndex < 0: ' + toIndex); if (fromIndex > toIndex) throw new IndexOutOfBoundsException('fromIndex: ' + fromIndex + ' > toIndex: ' + toIndex); if (length() <= fromIndex || fromIndex == toIndex) return new BitSet(0); if (length() < toIndex) toIndex = length(); BitSet result = new BitSet(toIndex - fromIndex); int startBitIndex = fromIndex & BIT_INDEX_MASK; int endBitIndex = toIndex & BIT_INDEX_MASK; int targetWords = (toIndex - fromIndex + 63) / 64; int sourceWords = unitIndex(toIndex) - unitIndex(fromIndex) + 1; int inverseIndex = 64 - startBitIndex; int targetIndex = 0; int sourceIndex = unitIndex(fromIndex); while (targetIndex < targetWords - 1) result.bits[targetIndex++] = (bits[sourceIndex++] >>> startBitIndex) | ((inverseIndex == 64) ? 0 : bits[sourceIndex] << inverseIndex); result.bits[targetIndex] = (sourceWords == targetWords ? (bits[sourceIndex] & bitsRightOf(endBitIndex)) >>> startBitIndex : (bits[sourceIndex++] >>> startBitIndex) | ((inverseIndex == 64) ? 0 : (getBits(sourceIndex) & bitsRightOf(endBitIndex)) << inverseIndex)); result.unitsInUse = targetWords; result.recalculateUnitsInUse(); return result; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.BitSet.nextClearBit(int)
/** * Returns the index of the first bit that is set to <code>false</code> * that occurs on or after the specified starting index. * @param fromIndex the index to start checking from (inclusive). * @return the index of the next clear bit. * @throws IndexOutOfBoundsException if the specified index is negative. * @since 1.4 */ public int nextClearBit(int fromIndex) { if (fromIndex < 0) throw new IndexOutOfBoundsException('fromIndex < 0: ' + fromIndex); int u = unitIndex(fromIndex); if (u >= unitsInUse) return fromIndex; int testIndex = (fromIndex & BIT_INDEX_MASK); long unit = bits[u] >> testIndex; if (unit == (WORD_MASK >> testIndex)) testIndex = 0; while ((unit == WORD_MASK) && (u < unitsInUse - 1)) unit = bits[++u]; if (unit == WORD_MASK) return length(); if (unit == 0) return u * BITS_PER_UNIT + testIndex; testIndex += trailingZeroCnt(~unit); return ((u * BITS_PER_UNIT) + testIndex); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.BitSet.nextSetBit(int)
/** * Returns the index of the first bit that is set to <code>true</code> * that occurs on or after the specified starting index. If no such * bit exists then -1 is returned. * To iterate over the <code>true</code> bits in a <code>BitSet</code>, * use the following loop: * for(int i=bs.nextSetBit(0); i>=0; i=bs.nextSetBit(i+1)) { * // operate on index i here * } * @param fromIndex the index to start checking from (inclusive). * @return the index of the next set bit. * @throws IndexOutOfBoundsException if the specified index is negative. * @since 1.4 */ public int nextSetBit(int fromIndex) { if (fromIndex < 0) throw new IndexOutOfBoundsException('fromIndex < 0: ' + fromIndex); int u = unitIndex(fromIndex); if (u >= unitsInUse) return -1; int testIndex = (fromIndex & BIT_INDEX_MASK); long unit = bits[u] >> testIndex; if (unit == 0) testIndex = 0; while ((unit == 0) && (u < unitsInUse - 1)) unit = bits[++u]; if (unit == 0) return -1; testIndex += trailingZeroCnt(unit); return ((u * BITS_PER_UNIT) + testIndex); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.BitSet.set(int, int)
/** * Sets the bits from the specified fromIndex(inclusive) to the * specified toIndex(exclusive) to <code>true</code>. * @param fromIndex index of the first bit to be set. * @param toIndex index after the last bit to be set. * @exception IndexOutOfBoundsException if <tt>fromIndex</tt> is negative, * or <tt>toIndex</tt> is negative, or <tt>fromIndex</tt> is * larger than <tt>toIndex</tt>. * @since 1.4 */ public void set(int fromIndex, int toIndex) { if (fromIndex < 0) throw new IndexOutOfBoundsException('fromIndex < 0: ' + fromIndex); if (toIndex < 0) throw new IndexOutOfBoundsException('toIndex < 0: ' + toIndex); if (fromIndex > toIndex) throw new IndexOutOfBoundsException('fromIndex: ' + fromIndex + ' > toIndex: ' + toIndex); int endUnitIndex = unitIndex(toIndex); int unitsRequired = endUnitIndex + 1; if (unitsInUse < unitsRequired) { ensureCapacity(unitsRequired); unitsInUse = unitsRequired; } int startUnitIndex = unitIndex(fromIndex); long bitMask = 0; if (startUnitIndex == endUnitIndex) { bitMask = (1L << (toIndex & BIT_INDEX_MASK)) - (1L << (fromIndex & BIT_INDEX_MASK)); bits[startUnitIndex] |= bitMask; return; } bitMask = bitsLeftOf(fromIndex & BIT_INDEX_MASK); bits[startUnitIndex] |= bitMask; if (endUnitIndex - startUnitIndex > 1) { for (int i = startUnitIndex + 1; i < endUnitIndex; i++) bits[i] |= WORD_MASK; } bitMask = bitsRightOf(toIndex & BIT_INDEX_MASK); bits[endUnitIndex] |= bitMask; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.png.PNGImageReader.getImageMetadata(int)
public IIOMetadata getImageMetadata(int imageIndex) throws IIOException { if (imageIndex != 0) { throw new IndexOutOfBoundsException('imageIndex != 0!'); } readMetadata(); return metadata; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.png.PNGImageReader.getImageTypes(int)
public Iterator getImageTypes(int imageIndex) throws IIOException { if (imageIndex != 0) { throw new IndexOutOfBoundsException('imageIndex != 0!'); } readHeader(); ArrayList l = new ArrayList(1); ColorSpace rgb; ColorSpace gray; int[] bandOffsets; int bitDepth = metadata.IHDR_bitDepth; int colorType = metadata.IHDR_colorType; int dataType; if (bitDepth <= 8) { dataType = DataBuffer.TYPE_BYTE; } else { dataType = DataBuffer.TYPE_USHORT; } switch(colorType) { case PNG_COLOR_GRAY: l.add(ImageTypeSpecifier.createGrayscale(bitDepth, dataType, false)); break; case PNG_COLOR_RGB: rgb = ColorSpace.getInstance(ColorSpace.CS_sRGB); bandOffsets = new int[3]; bandOffsets[0] = 0; bandOffsets[1] = 1; bandOffsets[2] = 2; l.add(ImageTypeSpecifier.createInterleaved(rgb, bandOffsets, dataType, false, false)); break; case PNG_COLOR_PALETTE: readMetadata(); int plength = 1 << bitDepth; byte[] red = metadata.PLTE_red; byte[] green = metadata.PLTE_green; byte[] blue = metadata.PLTE_blue; if (metadata.PLTE_red.length < plength) { red = new byte[plength]; System.arraycopy(metadata.PLTE_red, 0, red, 0, metadata.PLTE_red.length); Arrays.fill(red, metadata.PLTE_red.length, plength, metadata.PLTE_red[metadata.PLTE_red.length - 1]); green = new byte[plength]; System.arraycopy(metadata.PLTE_green, 0, green, 0, Math.min(metadata.PLTE_green.length, plength)); Arrays.fill(green, metadata.PLTE_green.length, plength, metadata.PLTE_green[metadata.PLTE_green.length - 1]); blue = new byte[plength]; System.arraycopy(metadata.PLTE_blue, 0, blue, 0, Math.min(metadata.PLTE_blue.length, plength)); Arrays.fill(blue, metadata.PLTE_blue.length, plength, metadata.PLTE_blue[metadata.PLTE_blue.length - 1]); } byte[] alpha = null; if (metadata.tRNS_present && (metadata.tRNS_alpha != null)) { if (metadata.tRNS_alpha.length == red.length) { alpha = metadata.tRNS_alpha; } else { alpha = new byte[red.length]; System.arraycopy(metadata.tRNS_alpha, 0, alpha, 0, Math.min(metadata.tRNS_alpha.length, red.length)); Arrays.fill(alpha, metadata.tRNS_alpha.length, red.length, (byte) 255); } } l.add(ImageTypeSpecifier.createIndexed(red, green, blue, alpha, bitDepth, DataBuffer.TYPE_BYTE)); break; case PNG_COLOR_GRAY_ALPHA: gray = ColorSpace.getInstance(ColorSpace.CS_GRAY); bandOffsets = new int[2]; bandOffsets[0] = 0; bandOffsets[1] = 1; l.add(ImageTypeSpecifier.createInterleaved(gray, bandOffsets, dataType, true, false)); break; case PNG_COLOR_RGB_ALPHA: rgb = ColorSpace.getInstance(ColorSpace.CS_sRGB); bandOffsets = new int[4]; bandOffsets[0] = 0; bandOffsets[1] = 1; bandOffsets[2] = 2; bandOffsets[3] = 3; l.add(ImageTypeSpecifier.createInterleaved(rgb, bandOffsets, dataType, true, false)); break; default: break; } return l.iterator(); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.png.PNGImageReader.read(int, ImageReadParam)
public BufferedImage read(int imageIndex, ImageReadParam param) throws IIOException { if (imageIndex != 0) { throw new IndexOutOfBoundsException('imageIndex != 0!'); } readImage(param); return theImage; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.ImageReader.readAll(int, ImageReadParam)
/** * Reads the image indexed by <code>imageIndex</code> and returns * an <code>IIOImage</code> containing the image, thumbnails, and * associated image metadata, using a supplied * <code>ImageReadParam</code>. * The actual <code>BufferedImage</code> referenced by the * returned <code>IIOImage</code> will be chosen using the * algorithm defined by the <code>getDestination</code> method. * Any registered <code>IIOReadProgressListener</code> objects * will be notified by calling their <code>imageStarted</code> * method, followed by calls to their <code>imageProgress</code> * method as the read progresses. Finally their * <code>imageComplete</code> method will be called. * <code>IIOReadUpdateListener</code> objects may be updated at * other times during the read as pixels are decoded. Finally, * <code>IIOReadWarningListener</code> objects will receive * notification of any non-fatal warnings that occur during * decoding. * The set of source bands to be read and destination bands to * be written is determined by calling <code>getSourceBands</code> * and <code>getDestinationBands</code> on the supplied * <code>ImageReadParam</code>. If the lengths of the arrays * returned by these methods differ, the set of source bands * contains an index larger that the largest available source * index, or the set of destination bands contains an index larger * than the largest legal destination index, an * <code>IllegalArgumentException</code> is thrown. * Thumbnails will be returned in their entirety regardless of * the region settings. * If the supplied <code>ImageReadParam</code> contains * optional setting values not supported by this reader (<i>e.g.</i> * source render size or any format-specific settings), those * values will be ignored. * @param imageIndex the index of the image to be retrieved. * @param param an <code>ImageReadParam</code> used to control * the reading process, or <code>null</code>. * @return an <code>IIOImage</code> containing the desired portion * of the image, a set of thumbnails, and associated image * metadata. * @exception IllegalStateException if the input source has not been * set. * @exception IndexOutOfBoundsException if the supplied index is * out of bounds. * @exception IllegalArgumentException if the set of source and * destination bands specified by * <code>param.getSourceBands</code> and * <code>param.getDestinationBands</code> differ in length or * include indices that are out of bounds. * @exception IllegalArgumentException if the resulting image * would have a width or height less than 1. * @exception IOException if an error occurs during reading. */ public IIOImage readAll(int imageIndex, ImageReadParam param) throws IOException { if (imageIndex < getMinIndex()) { throw new IndexOutOfBoundsException('imageIndex < getMinIndex()!'); } BufferedImage im = read(imageIndex, param); ArrayList thumbnails = null; int numThumbnails = getNumThumbnails(imageIndex); if (numThumbnails > 0) { thumbnails = new ArrayList(); for (int j = 0; j < numThumbnails; j++) { thumbnails.add(readThumbnail(imageIndex, j)); } } IIOMetadata metadata = getImageMetadata(imageIndex); return new IIOImage(im, thumbnails, metadata); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.gif.GIFImageReader.checkIndex(int)
private void checkIndex(int imageIndex) { if (imageIndex < minIndex) { throw new IndexOutOfBoundsException('imageIndex < minIndex!'); } if (seekForwardOnly) { minIndex = imageIndex; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.imageio.plugins.gif.GIFImageReader.read(int, ImageReadParam)
public BufferedImage read(int imageIndex, ImageReadParam param) throws IIOException { if (stream == null) { throw new IllegalStateException('Input not set!'); } checkIndex(imageIndex); int index = locateImage(imageIndex); if (index != imageIndex) { throw new IndexOutOfBoundsException('imageIndex out of bounds!'); } clearAbortRequest(); readMetadata(); if (param == null) { param = getDefaultReadParam(); } Iterator imageTypes = getImageTypes(imageIndex); this.theImage = getDestination(param, imageTypes, imageMetadata.imageWidth, imageMetadata.imageHeight); this.theTile = theImage.getWritableTile(0, 0); this.width = imageMetadata.imageWidth; this.height = imageMetadata.imageHeight; this.streamX = 0; this.streamY = 0; this.rowsDone = 0; this.interlacePass = 0; this.sourceRegion = new Rectangle(0, 0, 0, 0); this.destinationRegion = new Rectangle(0, 0, 0, 0); computeRegions(param, width, height, theImage, sourceRegion, destinationRegion); this.destinationOffset = new Point(destinationRegion.x, destinationRegion.y); this.sourceXSubsampling = param.getSourceXSubsampling(); this.sourceYSubsampling = param.getSourceYSubsampling(); this.sourceMinProgressivePass = Math.max(param.getSourceMinProgressivePass(), 0); this.sourceMaxProgressivePass = Math.min(param.getSourceMaxProgressivePass(), 3); this.destY = destinationRegion.y + (streamY - sourceRegion.y) / sourceYSubsampling; computeDecodeThisRow(); processImageStarted(imageIndex); startPass(0); this.rowBuf = new byte[width]; try { this.initCodeSize = stream.readUnsignedByte(); this.blockLength = stream.readUnsignedByte(); int left = blockLength; int off = 0; while (left > 0) { int nbytes = stream.read(block, off, left); left -= nbytes; off += nbytes; } this.bitPos = 0; this.nextByte = 0; this.lastBlockFound = false; this.interlacePass = 0; initNext32Bits(); this.clearCode = 1 << initCodeSize; this.eofCode = clearCode + 1; int code, oldCode = 0; int[] prefix = new int[4096]; byte[] suffix = new byte[4096]; byte[] initial = new byte[4096]; int[] length = new int[4096]; byte[] string = new byte[4096]; initializeStringTable(prefix, suffix, initial, length); int tableIndex = (1 << initCodeSize) + 2; int codeSize = initCodeSize + 1; int codeMask = (1 << codeSize) - 1; while (!abortRequested()) { code = getCode(codeSize, codeMask); if (code == clearCode) { initializeStringTable(prefix, suffix, initial, length); tableIndex = (1 << initCodeSize) + 2; codeSize = initCodeSize + 1; codeMask = (1 << codeSize) - 1; code = getCode(codeSize, codeMask); if (code == eofCode) { processImageComplete(); return theImage; } } else if (code == eofCode) { processImageComplete(); return theImage; } else { int newSuffixIndex; if (code < tableIndex) { newSuffixIndex = code; } else { newSuffixIndex = oldCode; if (code != tableIndex) { processWarningOccurred('Out-of-sequence code!'); } } int ti = tableIndex; int oc = oldCode; prefix[ti] = oc; suffix[ti] = initial[newSuffixIndex]; initial[ti] = initial[oc]; length[ti] = length[oc] + 1; ++tableIndex; if ((tableIndex == (1 << codeSize)) && (tableIndex < 4096)) { ++codeSize; codeMask = (1 << codeSize) - 1; } } int c = code; int len = length[c]; for (int i = len - 1; i >= 0; i--) { string[i] = suffix[c]; c = prefix[c]; } outputPixels(string, len); oldCode = code; } processReadAborted(); return theImage; } catch (IOException e) { e.printStackTrace(); throw new IIOException('I/O error reading image!', e); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.concurrent.atomic.AtomicIntegerArray.rawIndex(int)
private long rawIndex(int i) { if (i < 0 || i >= array.length) throw new IndexOutOfBoundsException('index ' + i); return base + i * scale; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.concurrent.atomic.AtomicLongArray.rawIndex(int)
private long rawIndex(int i) { if (i < 0 || i >= array.length) throw new IndexOutOfBoundsException('index ' + i); return base + i * scale; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.concurrent.atomic.AtomicReferenceArray.rawIndex(int)
private long rawIndex(int i) { if (i < 0 || i >= array.length) throw new IndexOutOfBoundsException('index ' + i); return base + i * scale; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageInputStreamImpl.readBytes(IIOByteBuffer, int)
public void readBytes(IIOByteBuffer buf, int len) throws IOException { if (len < 0) { throw new IndexOutOfBoundsException('len < 0!'); } if (buf == null) { throw new NullPointerException('buf == null!'); } byte[] data = new byte[len]; len = read(data, 0, len); buf.setData(data); buf.setOffset(0); buf.setLength(len); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.sound.midi.MidiMessage.setMessage(byte[], int)
/** * Sets the data for the MIDI message. This protected * method is called by concrete subclasses, which should * ensure that the data array specifies a complete, valid MIDI * message. */ protected void setMessage(byte[] data, int length) throws InvalidMidiDataException { if (length < 0 || (length > 0 && length > data.length)) { throw new IndexOutOfBoundsException('length out of bounds: ' + length); } this.length = length; if (this.data == null || this.data.length < this.length) { this.data = new byte[this.length]; } System.arraycopy(data, 0, this.data, 0, length); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.sound.midi.SysexMessage.setMessage(int, byte[], int)
/** * Sets the data for the system exclusive message. * @param status the status byte for the message (0xF0 or 0xF7) * @param data the system exclusive message data * @param length the length of the valid message data in * the array */ public void setMessage(int status, byte[] data, int length) throws InvalidMidiDataException { if ((status != 0xF0) && (status != 0xF7)) { throw new InvalidMidiDataException('Invalid status byte for sysex message: 0x' + Integer.toHexString(status)); } if (length < 0 || length > data.length) { throw new IndexOutOfBoundsException('length out of bounds: ' + length); } this.length = length + 1; if (this.data == null || this.data.length < this.length) { this.data = new byte[this.length]; } this.data[0] = (byte) (status & 0xFF); if (length > 0) { System.arraycopy(data, 0, this.data, 1, length); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageInputStreamImpl.readFully(byte[], int, int)
public void readFully(byte[] b, int off, int len) throws IOException { if (off < 0 || len < 0 || off + len > b.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > b.length!'); } while (len > 0) { int nbytes = read(b, off, len); if (nbytes == -1) { throw new EOFException(); } off += nbytes; len -= nbytes; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.MemoryCacheImageInputStream.read(byte[], int, int)
public int read(byte[] b, int off, int len) throws IOException { checkClosed(); if (off < 0 || len < 0 || off + len > b.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > b.length!'); } bitOffset = 0; if (len == 0) { return 0; } long pos = cache.loadFromStream(stream, streamPos + len); len = (int) (pos - streamPos); if (len > 0) { cache.read(b, off, len, streamPos); streamPos += len; return len; } else { return -1; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.MemoryCacheImageOutputStream.read(byte[], int, int)
public int read(byte[] b, int off, int len) throws IOException { checkClosed(); if (off < 0 || len < 0 || off + len > b.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > b.length!'); } bitOffset = 0; if (len == 0) { return 0; } long bytesLeftInCache = cache.getLength() - streamPos; if (bytesLeftInCache <= 0) { return -1; } len = (int) Math.min(bytesLeftInCache, (long) len); cache.read(b, off, len, streamPos); streamPos += len; return len; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageInputStreamImpl.readFully(char[], int, int)
public void readFully(char[] c, int off, int len) throws IOException { if (off < 0 || len < 0 || off + len > c.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > c.length!'); } while (len > 0) { int nelts = Math.min(len, byteBuf.length / 2); readFully(byteBuf, 0, nelts * 2); toChars(byteBuf, c, off, nelts); off += nelts; len -= nelts; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageOutputStreamImpl.writeChars(char[], int, int)
public void writeChars(char[] c, int off, int len) throws IOException { if (off < 0 || len < 0 || off + len > c.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > c.length!'); } byte[] b = new byte[len * 2]; int boff = 0; if (byteOrder == ByteOrder.BIG_ENDIAN) { for (int i = 0; i < len; i++) { char v = c[off + i]; b[boff++] = (byte) (v >>> 8); b[boff++] = (byte) (v >>> 0); } } else { for (int i = 0; i < len; i++) { char v = c[off + i]; b[boff++] = (byte) (v >>> 0); b[boff++] = (byte) (v >>> 8); } } write(b, 0, len * 2); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageInputStreamImpl.readFully(double[], int, int)
public void readFully(double[] d, int off, int len) throws IOException { if (off < 0 || len < 0 || off + len > d.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > d.length!'); } while (len > 0) { int nelts = Math.min(len, byteBuf.length / 8); readFully(byteBuf, 0, nelts * 8); toDoubles(byteBuf, d, off, nelts); off += nelts; len -= nelts; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageOutputStreamImpl.writeDoubles(double[], int, int)
public void writeDoubles(double[] d, int off, int len) throws IOException { if (off < 0 || len < 0 || off + len > d.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > d.length!'); } byte[] b = new byte[len * 8]; int boff = 0; if (byteOrder == ByteOrder.BIG_ENDIAN) { for (int i = 0; i < len; i++) { long v = Double.doubleToLongBits(d[off + i]); b[boff++] = (byte) (v >>> 56); b[boff++] = (byte) (v >>> 48); b[boff++] = (byte) (v >>> 40); b[boff++] = (byte) (v >>> 32); b[boff++] = (byte) (v >>> 24); b[boff++] = (byte) (v >>> 16); b[boff++] = (byte) (v >>> 8); b[boff++] = (byte) (v >>> 0); } } else { for (int i = 0; i < len; i++) { long v = Double.doubleToLongBits(d[off + i]); b[boff++] = (byte) (v >>> 0); b[boff++] = (byte) (v >>> 8); b[boff++] = (byte) (v >>> 16); b[boff++] = (byte) (v >>> 24); b[boff++] = (byte) (v >>> 32); b[boff++] = (byte) (v >>> 40); b[boff++] = (byte) (v >>> 48); b[boff++] = (byte) (v >>> 56); } } write(b, 0, len * 8); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageInputStreamImpl.readFully(float[], int, int)
public void readFully(float[] f, int off, int len) throws IOException { if (off < 0 || len < 0 || off + len > f.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > f.length!'); } while (len > 0) { int nelts = Math.min(len, byteBuf.length / 4); readFully(byteBuf, 0, nelts * 4); toFloats(byteBuf, f, off, nelts); off += nelts; len -= nelts; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageOutputStreamImpl.writeFloats(float[], int, int)
public void writeFloats(float[] f, int off, int len) throws IOException { if (off < 0 || len < 0 || off + len > f.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > f.length!'); } byte[] b = new byte[len * 4]; int boff = 0; if (byteOrder == ByteOrder.BIG_ENDIAN) { for (int i = 0; i < len; i++) { int v = Float.floatToIntBits(f[off + i]); b[boff++] = (byte) (v >>> 24); b[boff++] = (byte) (v >>> 16); b[boff++] = (byte) (v >>> 8); b[boff++] = (byte) (v >>> 0); } } else { for (int i = 0; i < len; i++) { int v = Float.floatToIntBits(f[off + i]); b[boff++] = (byte) (v >>> 0); b[boff++] = (byte) (v >>> 8); b[boff++] = (byte) (v >>> 16); b[boff++] = (byte) (v >>> 24); } } write(b, 0, len * 4); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageInputStreamImpl.readFully(int[], int, int)
public void readFully(int[] i, int off, int len) throws IOException { if (off < 0 || len < 0 || off + len > i.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > i.length!'); } while (len > 0) { int nelts = Math.min(len, byteBuf.length / 4); readFully(byteBuf, 0, nelts * 4); toInts(byteBuf, i, off, nelts); off += nelts; len -= nelts; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageOutputStreamImpl.writeInts(int[], int, int)
public void writeInts(int[] i, int off, int len) throws IOException { if (off < 0 || len < 0 || off + len > i.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > i.length!'); } byte[] b = new byte[len * 4]; int boff = 0; if (byteOrder == ByteOrder.BIG_ENDIAN) { for (int j = 0; j < len; j++) { int v = i[off + j]; b[boff++] = (byte) (v >>> 24); b[boff++] = (byte) (v >>> 16); b[boff++] = (byte) (v >>> 8); b[boff++] = (byte) (v >>> 0); } } else { for (int j = 0; j < len; j++) { int v = i[off + j]; b[boff++] = (byte) (v >>> 0); b[boff++] = (byte) (v >>> 8); b[boff++] = (byte) (v >>> 16); b[boff++] = (byte) (v >>> 24); } } write(b, 0, len * 4); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageInputStreamImpl.readFully(long[], int, int)
public void readFully(long[] l, int off, int len) throws IOException { if (off < 0 || len < 0 || off + len > l.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > l.length!'); } while (len > 0) { int nelts = Math.min(len, byteBuf.length / 8); readFully(byteBuf, 0, nelts * 8); toLongs(byteBuf, l, off, nelts); off += nelts; len -= nelts; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageOutputStreamImpl.writeLongs(long[], int, int)
public void writeLongs(long[] l, int off, int len) throws IOException { if (off < 0 || len < 0 || off + len > l.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > l.length!'); } byte[] b = new byte[len * 8]; int boff = 0; if (byteOrder == ByteOrder.BIG_ENDIAN) { for (int i = 0; i < len; i++) { long v = l[off + i]; b[boff++] = (byte) (v >>> 56); b[boff++] = (byte) (v >>> 48); b[boff++] = (byte) (v >>> 40); b[boff++] = (byte) (v >>> 32); b[boff++] = (byte) (v >>> 24); b[boff++] = (byte) (v >>> 16); b[boff++] = (byte) (v >>> 8); b[boff++] = (byte) (v >>> 0); } } else { for (int i = 0; i < len; i++) { long v = l[off + i]; b[boff++] = (byte) (v >>> 0); b[boff++] = (byte) (v >>> 8); b[boff++] = (byte) (v >>> 16); b[boff++] = (byte) (v >>> 24); b[boff++] = (byte) (v >>> 32); b[boff++] = (byte) (v >>> 40); b[boff++] = (byte) (v >>> 48); b[boff++] = (byte) (v >>> 56); } } write(b, 0, len * 8); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageInputStreamImpl.readFully(short[], int, int)
public void readFully(short[] s, int off, int len) throws IOException { if (off < 0 || len < 0 || off + len > s.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > s.length!'); } while (len > 0) { int nelts = Math.min(len, byteBuf.length / 2); readFully(byteBuf, 0, nelts * 2); toShorts(byteBuf, s, off, nelts); off += nelts; len -= nelts; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageOutputStreamImpl.writeShorts(short[], int, int)
public void writeShorts(short[] s, int off, int len) throws IOException { if (off < 0 || len < 0 || off + len > s.length || off + len < 0) { throw new IndexOutOfBoundsException('off < 0 || len < 0 || off + len > s.length!'); } byte[] b = new byte[len * 2]; int boff = 0; if (byteOrder == ByteOrder.BIG_ENDIAN) { for (int i = 0; i < len; i++) { short v = s[off + i]; b[boff++] = (byte) (v >>> 8); b[boff++] = (byte) (v >>> 0); } } else { for (int i = 0; i < len; i++) { short v = s[off + i]; b[boff++] = (byte) (v >>> 0); b[boff++] = (byte) (v >>> 8); } } write(b, 0, len * 2); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.FileImageInputStream.seek(long)
public void seek(long pos) throws IOException { checkClosed(); if (pos < flushedPos) { throw new IndexOutOfBoundsException('pos < flushedPos!'); } bitOffset = 0; raf.seek(pos); streamPos = raf.getFilePointer(); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.FileImageOutputStream.seek(long)
/** * Sets the current stream position and resets the bit offset to * 0. It is legal to seeking past the end of the file; an * <code>EOFException</code> will be thrown only if a read is * performed. The file length will not be increased until a write * is performed. * @exception IndexOutOfBoundsException if <code>pos</code> is smaller * than the flushed position. * @exception IOException if any other I/O error occurs. */ public void seek(long pos) throws IOException { checkClosed(); if (pos < flushedPos) { throw new IndexOutOfBoundsException('pos < flushedPos!'); } bitOffset = 0; raf.seek(pos); streamPos = raf.getFilePointer(); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageInputStreamImpl.flushBefore(long)
public void flushBefore(long pos) throws IOException { if (pos < flushedPos) { throw new IndexOutOfBoundsException('pos < flushedPos!'); } if (pos > getStreamPosition()) { throw new IndexOutOfBoundsException('pos > getStreamPosition()!'); } flushedPos = pos; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.ImageInputStreamImpl.seek(long)
public void seek(long pos) throws IOException { checkClosed(); if (pos < flushedPos) { throw new IndexOutOfBoundsException('pos < flushedPos!'); } this.streamPos = pos; this.bitOffset = 0; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.imageio.stream.MemoryCache.disposeBefore(long)
/** * Free the blocks up to the position <code>pos</code>. * The byte at <code>pos</code> remains available. * @exception IndexOutOfBoundsException if <code>pos</code> * is in a block that has already been disposed. */ public void disposeBefore(long pos) { long index = pos / BUFFER_LENGTH; if (index < cacheStart) { throw new IndexOutOfBoundsException('pos already disposed'); } long numBlocks = Math.min(index - cacheStart, cache.size()); for (long i = 0; i < numBlocks; i++) { cache.remove(0); } this.cacheStart = index; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.lang.AbstractStringBuilder.append(CharSequence, int, int)
/** * Appends a subsequence of the specified <code>CharSequence</code> to this * sequence. * Characters of the argument <code>s</code>, starting at * index <code>start</code>, are appended, in order, to the contents of * this sequence up to the (exclusive) index <code>end</code>. The length * of this sequence is increased by the value of <code>end - start</code>. * Let <i>n</i> be the length of this character sequence just prior to * execution of the <code>append</code> method. Then the character at * index <i>k</i> in this character sequence becomes equal to the * character at index <i>k</i> in this sequence, if <i>k</i> is less than * <i>n</i>; otherwise, it is equal to the character at index * <i>k+start-n</i> in the argument <code>s</code>. * If <code>s</code> is <code>null</code>, then this method appends * characters as if the s parameter was a sequence containing the four * characters <code>'null'</code>. * @param s the sequence to append. * @param start the starting index of the subsequence to be appended. * @param end the end index of the subsequence to be appended. * @return a reference to this object. * @throws IndexOutOfBoundsException if * <code>start</code> or <code>end</code> are negative, or * <code>start</code> is greater than <code>end</code> or * <code>end</code> is greater than <code>s.length()</code> */ public AbstractStringBuilder append(CharSequence s, int start, int end) { if (s == null) s = 'null'; if ((start < 0) || (end < 0) || (start > end) || (end > s.length())) throw new IndexOutOfBoundsException('start ' + start + ', end ' + end + ', s.length() ' + s.length()); int len = end - start; if (len == 0) return this; int newCount = count + len; if (newCount > value.length) expandCapacity(newCount); for (int i = start; i < end; i++) value[count++] = s.charAt(i); count = newCount; return this; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
inglutpeizu_1995 Ana Stephens Free Download
ReplyDeletegodtbudtiren