java.lang.ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException is described in the javadoc comments as:
Thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array.
author: unascribed version: 1.21, 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.ArrayIndexOutOfBoundsException: ' is thrown within the method:
java.net.SocketInputStream.read(byte, int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ' is thrown within the method:
java.net.SocketOutputStream.socketWrite(byte, int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ' is thrown within the method:
java.util.zip.Adler32.update(byte[], int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ' is thrown within the method:
java.util.zip.CRC32.update(byte[], int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ' is thrown within the method:
java.util.zip.Deflater.deflate(byte[], int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ' is thrown within the method:
java.util.zip.Deflater.setDictionary(byte[], int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ' is thrown within the method:
java.util.zip.Deflater.setInput(byte[], int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ' is thrown within the method:
java.util.zip.Inflater.inflate(byte[], int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ' is thrown within the method:
java.util.zip.Inflater.setDictionary(byte[], int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ' is thrown within the method:
java.util.zip.Inflater.setInput(byte[], int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
com.sun.org.apache.xml.internal.dtm.ref.ChunkedIntArray.readEntry(int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
com.sun.org.apache.xml.internal.dtm.ref.ChunkedIntArray.writeEntry(int, int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
java.awt.Container.remove(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
java.rmi.server.LogStream.write(byte, int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
java.util.Arrays.rangeCheck(int, int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
java.util.GregorianCalendar.getActualMaximum(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
java.util.Vector.addAll(int, Collection<? extends E>) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
java.util.Vector.get(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
java.util.Vector.remove(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
java.util.Vector.removeElementAt(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
java.util.Vector.set(int, E) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
javax.naming.NameImpl.getPrefix(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
javax.naming.NameImpl.getSuffix(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
javax.sound.midi.Track.get(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ...' is thrown within the method:
org.xml.sax.helpers.AttributesImpl.badIndex(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ... > ...' is thrown within the method:
java.util.Vector.insertElementAt(E, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ... >= ...' is thrown within the method:
com.sun.org.apache.xpath.internal.NodeSet.removeElementAt(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ... >= ...' is thrown within the method:
java.util.Vector.elementAt(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ... >= ...' is thrown within the method:
java.util.Vector.removeElementAt(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: ... >= ...' is thrown within the method:
java.util.Vector.setElementAt(E, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: Band offsets array is null' is thrown within the method:
java.awt.image.Raster.createBandedRaster(int, int, int, int, int, int, Point) - The message 'java.lang.ArrayIndexOutOfBoundsException: Bank indices array is null' is thrown within the method:
java.awt.image.Raster.createBandedRaster(int, int, int, int, int, int, Point) - The message 'java.lang.ArrayIndexOutOfBoundsException: BufferedImages only have ... one tile with index 0,0' is thrown within the method:
java.awt.image.BufferedImage.getTile(int, int) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.BandedSampleModel.getDataElements(int, int, Object, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.BandedSampleModel.getPixel(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.BandedSampleModel.getPixels(int, int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.BandedSampleModel.getSample(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.BandedSampleModel.getSampleDouble(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.BandedSampleModel.getSampleFloat(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.BandedSampleModel.getSamples(int, int, int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.BandedSampleModel.setDataElements(int, int, Object, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.BandedSampleModel.setPixel(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.BandedSampleModel.setPixels(int, int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.BandedSampleModel.setSample(int, int, int, double, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.BandedSampleModel.setSample(int, int, int, float, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.BandedSampleModel.setSample(int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.BandedSampleModel.setSamples(int, int, int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.ComponentSampleModel.getDataElements(int, int, Object, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.ComponentSampleModel.getPixel(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.ComponentSampleModel.getPixels(int, int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.ComponentSampleModel.getSample(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.ComponentSampleModel.getSampleDouble(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.ComponentSampleModel.getSampleFloat(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.ComponentSampleModel.getSamples(int, int, int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.ComponentSampleModel.setDataElements(int, int, Object, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.ComponentSampleModel.setPixel(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.ComponentSampleModel.setPixels(int, int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.ComponentSampleModel.setSample(int, int, int, double, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.ComponentSampleModel.setSample(int, int, int, float, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.ComponentSampleModel.setSample(int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.ComponentSampleModel.setSamples(int, int, int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.MultiPixelPackedSampleModel.getDataElements(int, int, Object, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.MultiPixelPackedSampleModel.getPixel(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.MultiPixelPackedSampleModel.getSample(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.MultiPixelPackedSampleModel.setDataElements(int, int, Object, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.MultiPixelPackedSampleModel.setPixel(int, int, int[], DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.MultiPixelPackedSampleModel.setSample(int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.SinglePixelPackedSampleModel.getDataElements(int, int, Object, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.SinglePixelPackedSampleModel.getPixel(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.SinglePixelPackedSampleModel.getPixels(int, int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.SinglePixelPackedSampleModel.getSample(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.SinglePixelPackedSampleModel.getSamples(int, int, int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.SinglePixelPackedSampleModel.setDataElements(int, int, Object, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.SinglePixelPackedSampleModel.setPixel(int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.SinglePixelPackedSampleModel.setPixels(int, int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.SinglePixelPackedSampleModel.setSample(int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.SinglePixelPackedSampleModel.setSamples(int, int, int, int, int, int, DataBuffer) - The message 'java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!' is thrown within the method:
java.awt.image.WritableRaster.setDataElements(int, int, Raster) - The message 'java.lang.ArrayIndexOutOfBoundsException: No attribute at index: ...' is thrown within the method:
org.xml.sax.ext.Attributes2Impl.isDeclared(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: No attribute at index: ...' is thrown within the method:
org.xml.sax.ext.Attributes2Impl.isSpecified(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: No attribute at index: ...' is thrown within the method:
org.xml.sax.ext.Attributes2Impl.setDeclared(int, boolean) - The message 'java.lang.ArrayIndexOutOfBoundsException: No attribute at index: ...' is thrown within the method:
org.xml.sax.ext.Attributes2Impl.setSpecified(int, boolean) - The message 'java.lang.ArrayIndexOutOfBoundsException: No such child: ...' is thrown within the method:
java.awt.Container.getComponent(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: Number of bands ( ... ) must ... be greater than 0' is thrown within the method:
java.awt.image.Raster.createBandedRaster(int, int, int, int, Point) - The message 'java.lang.ArrayIndexOutOfBoundsException: colorvalue.length < getNumComponents()' is thrown within the method:
com.sun.imageio.plugins.common.BogusColorSpace.toCIEXYZ(float[]) - The message 'java.lang.ArrayIndexOutOfBoundsException: colorvalue.length < getNumComponents()' is thrown within the method:
com.sun.imageio.plugins.common.BogusColorSpace.toRGB(float[]) - The message 'java.lang.ArrayIndexOutOfBoundsException: node has no children' is thrown within the method:
javax.swing.tree.DefaultMutableTreeNode.getChildAt(int) - The message 'java.lang.ArrayIndexOutOfBoundsException: pos < 0' is thrown within the method:
javax.imageio.stream.MemoryCache.write(int, long) - The message 'java.lang.ArrayIndexOutOfBoundsException: rgbvalue.length < 3' is thrown within the method:
com.sun.imageio.plugins.common.BogusColorSpace.fromRGB(float[]) - The message 'java.lang.ArrayIndexOutOfBoundsException: src[ ... ]-offset is ... less than zero' is thrown within the method:
java.awt.image.ByteLookupTable.lookupPixel(byte[], byte[]) - The message 'java.lang.ArrayIndexOutOfBoundsException: src[ ... ]-offset is ... less than zero' is thrown within the method:
java.awt.image.ByteLookupTable.lookupPixel(int[], int[]) - The message 'java.lang.ArrayIndexOutOfBoundsException: src[ ... ]-offset is ... less than zero' is thrown within the method:
java.awt.image.ShortLookupTable.lookupPixel(int[], int[]) - The message 'java.lang.ArrayIndexOutOfBoundsException: src[ ... ]-offset is ... less than zero' is thrown within the method:
java.awt.image.ShortLookupTable.lookupPixel(short[], short[]) - The message 'java.lang.ArrayIndexOutOfBoundsException: xyzvalue.length < 3' is thrown within the method:
com.sun.imageio.plugins.common.BogusColorSpace.fromCIEXYZ(float[])
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.
java.net.SocketInputStream.read(byte, int, int)
/** * Reads into a byte array <i>b</i> at offset <i>off</i>, * <i>length</i> bytes of data. * @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, -1 is * returned when the end of the stream is reached. * @exception IOException If an I/O error has occurred. */ public int read(byte b[], int off, int length) throws IOException { int n; if (eof) { return -1; } if (impl.isConnectionReset()) { throw new SocketException('Connection reset'); } if (length <= 0 || off < 0 || off + length > b.length) { if (length == 0) { return 0; } throw new ArrayIndexOutOfBoundsException(); } boolean gotReset = false; FileDescriptor fd = impl.acquireFD(); try { n = socketRead0(fd, b, off, length, impl.getTimeout()); if (n > 0) { return n; } } catch (ConnectionResetException rstExc) { gotReset = true; } finally { impl.releaseFD(); } if (gotReset) { impl.setConnectionResetPending(); impl.acquireFD(); try { n = socketRead0(fd, b, off, length, impl.getTimeout()); if (n > 0) { return n; } } catch (ConnectionResetException rstExc) { } finally { impl.releaseFD(); } } if (impl.isClosedOrPending()) { throw new SocketException('Socket closed'); } if (impl.isConnectionResetPending()) { impl.setConnectionReset(); } if (impl.isConnectionReset()) { throw new SocketException('Connection reset'); } eof = true; return -1; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.net.SocketOutputStream.socketWrite(byte, int, int)
/** * Writes to the socket with appropriate locking of the * FileDescriptor. * @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 IOException If an I/O error has occurred. */ private void socketWrite(byte b[], int off, int len) throws IOException { if (len <= 0 || off < 0 || off + len > b.length) { if (len == 0) { return; } throw new ArrayIndexOutOfBoundsException(); } FileDescriptor fd = impl.acquireFD(); try { socketWrite0(fd, b, off, len); } catch (SocketException se) { if (se instanceof sun.net.ConnectionResetException) { impl.setConnectionResetPending(); se = new SocketException('Connection reset'); } if (impl.isClosedOrPending()) { throw new SocketException('Socket closed'); } else { throw se; } } finally { impl.releaseFD(); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.zip.Adler32.update(byte[], int, int)
/** * Updates checksum with specified array of bytes. */ public void update(byte[] b, int off, int len) { if (b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } adler = updateBytes(adler, 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.util.zip.CRC32.update(byte[], int, int)
/** * Updates CRC-32 with specified array of bytes. */ public void update(byte[] b, int off, int len) { if (b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } crc = updateBytes(crc, 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.util.zip.Deflater.deflate(byte[], int, int)
/** * Fills specified buffer with compressed data. Returns actual number * of bytes of compressed data. A return value of 0 indicates that * needsInput() should be called in order to determine if more input * data is required. * @param b the buffer for the compressed data * @param off the start offset of the data * @param len the maximum number of bytes of compressed data * @return the actual number of bytes of compressed data */ public synchronized int deflate(byte[] b, int off, int len) { if (b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } return deflateBytes(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.util.zip.Deflater.setDictionary(byte[], int, int)
/** * Sets preset dictionary for compression. A preset dictionary is used * when the history buffer can be predetermined. When the data is later * uncompressed with Inflater.inflate(), Inflater.getAdler() can be called * in order to get the Adler-32 value of the dictionary required for * decompression. * @param b the dictionary data bytes * @param off the start offset of the data * @param len the length of the data * @see Inflater#inflate * @see Inflater#getAdler */ public synchronized void setDictionary(byte[] b, int off, int len) { if (strm == 0 || b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } setDictionary(strm, 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.util.zip.Deflater.setInput(byte[], int, int)
/** * Sets input data for compression. This should be called whenever * needsInput() returns true indicating that more input data is required. * @param b the input data bytes * @param off the start offset of the data * @param len the length of the data * @see Deflater#needsInput */ public synchronized void setInput(byte[] b, int off, int len) { if (b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } this.buf = b; this.off = off; this.len = len; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.zip.Inflater.inflate(byte[], int, int)
/** * Uncompresses bytes into specified buffer. Returns actual number * of bytes uncompressed. A return value of 0 indicates that * needsInput() or needsDictionary() should be called in order to * determine if more input data or a preset dictionary is required. * In the later case, getAdler() can be used to get the Adler-32 * value of the dictionary required. * @param b the buffer for the uncompressed data * @param off the start offset of the data * @param len the maximum number of uncompressed bytes * @return the actual number of uncompressed bytes * @exception DataFormatException if the compressed data format is invalid * @see Inflater#needsInput * @see Inflater#needsDictionary */ public synchronized int inflate(byte[] b, int off, int len) throws DataFormatException { if (b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } return inflateBytes(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.util.zip.Inflater.setDictionary(byte[], int, int)
/** * Sets the preset dictionary to the given array of bytes. Should be * called when inflate() returns 0 and needsDictionary() returns true * indicating that a preset dictionary is required. The method getAdler() * can be used to get the Adler-32 value of the dictionary needed. * @param b the dictionary data bytes * @param off the start offset of the data * @param len the length of the data * @see Inflater#needsDictionary * @see Inflater#getAdler */ public synchronized void setDictionary(byte[] b, int off, int len) { if (strm == 0 || b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } setDictionary(strm, b, off, len); needDict = false; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.zip.Inflater.setInput(byte[], int, int)
/** * Sets input data for decompression. Should be called whenever * needsInput() returns true indicating that more input data is * required. * @param b the input data bytes * @param off the start offset of the input data * @param len the length of the input data * @see Inflater#needsInput */ public synchronized void setInput(byte[] b, int off, int len) { if (b == null) { throw new NullPointerException(); } if (off < 0 || len < 0 || off > b.length - len) { throw new ArrayIndexOutOfBoundsException(); } this.buf = b; this.off = off; this.len = len; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.xml.internal.dtm.ref.ChunkedIntArray.readEntry(int, int)
/** * Retrieve an integer from the CIA by record number and column within * the record, both 0-based (though position 0 is reserved for special * purposes). * @param position int Record number * @param slotpos int Column number */ int readEntry(int position, int offset) throws ArrayIndexOutOfBoundsException { { if (offset >= slotsize) throw new ArrayIndexOutOfBoundsException(XMLMessages.createXMLMessage(XMLErrorResources.ER_OFFSET_BIGGER_THAN_SLOT, null)); position *= slotsize; int chunkpos = position >> lowbits; int slotpos = position & lowmask; int[] chunk = chunks.elementAt(chunkpos); return chunk[slotpos + offset]; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.xml.internal.dtm.ref.ChunkedIntArray.writeEntry(int, int, int)
/** * Overwrite the integer found at a specific record and column. * Used to back-patch existing records, most often changing their * 'next sibling' reference from 0 (unknown) to something meaningful * @param position int Record number * @param offset int Column number * @param value int New contents */ void writeEntry(int position, int offset, int value) throws ArrayIndexOutOfBoundsException { { if (offset >= slotsize) throw new ArrayIndexOutOfBoundsException(XMLMessages.createXMLMessage(XMLErrorResources.ER_OFFSET_BIGGER_THAN_SLOT, null)); position *= slotsize; int chunkpos = position >> lowbits; int slotpos = position & lowmask; int[] chunk = chunks.elementAt(chunkpos); chunk[slotpos + offset] = value; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.Container.remove(int)
/** * Removes the component, specified by <code>index</code>, * from this container. * This method also notifies the layout manager to remove the * component from this container's layout via the * <code>removeLayoutComponent</code> method. * @param index the index of the component to be removed * @see #add * @since JDK1.1 */ public void remove(int index) { synchronized (getTreeLock()) { if (index < 0 || index >= ncomponents) { throw new ArrayIndexOutOfBoundsException(index); } Component comp = component[index]; if (peer != null) { comp.removeNotify(); } if (layoutMgr != null) { layoutMgr.removeLayoutComponent(comp); } adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK, -comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK)); adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK, -comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK)); adjustDescendants(-(comp.countHierarchyMembers())); comp.parent = null; System.arraycopy(component, index + 1, component, index, ncomponents - index - 1); component[--ncomponents] = null; if (valid) { invalidate(); } if (containerListener != null || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 || Toolkit.enabledOnToolkit(AWTEvent.CONTAINER_EVENT_MASK)) { ContainerEvent e = new ContainerEvent(this, ContainerEvent.COMPONENT_REMOVED, comp); dispatchEvent(e); } comp.createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED, comp, this, HierarchyEvent.PARENT_CHANGED, Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK)); if (peer != null && layoutMgr == null && isVisible()) { updateCursorImmediately(); } } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.rmi.server.LogStream.write(byte, int, int)
/** * Write a subarray of bytes. Pass each through write byte method. * @since JDK1.1 * @deprecated no replacement */ @Deprecated public void write(byte b[], int off, int len) { if (len < 0) throw new ArrayIndexOutOfBoundsException(len); 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.util.Arrays.rangeCheck(int, int, int)
/** * Check that fromIndex and toIndex are in range, and throw an * appropriate exception if they aren't. */ private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) { if (fromIndex > toIndex) throw new IllegalArgumentException('fromIndex(' + fromIndex + ') > toIndex(' + toIndex + ')'); if (fromIndex < 0) throw new ArrayIndexOutOfBoundsException(fromIndex); if (toIndex > arrayLen) throw new ArrayIndexOutOfBoundsException(toIndex); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.GregorianCalendar.getActualMaximum(int)
/** * Returns the maximum value that this calendar field could have, * taking into consideration the given time value and the current * values of the * {@link Calendar#getFirstDayOfWeek() getFirstDayOfWeek}, * {@link Calendar#getMinimalDaysInFirstWeek() getMinimalDaysInFirstWeek}, * {@link #getGregorianChange(Date) getGregorianChange} and * {@link Calendar#getTimeZone() getTimeZone} methods. * For example, if the date of this instance is February 1, 2004, * the actual maximum value of the <code>DAY_OF_MONTH</code> field * is 29 because 2004 is a leap year, and if the date of this * instance is February 1, 2005, it's 28. * @param field the calendar field * @return the maximum of the given field for the time value of * this <code>GregorianCalendar</code> * @see #getMinimum(int) * @see #getMaximum(int) * @see #getGreatestMinimum(int) * @see #getLeastMaximum(int) * @see #getActualMinimum(int) * @since 1.2 */ public int getActualMaximum(int field) { final int fieldsForFixedMax = ERA_MASK | DAY_OF_WEEK_MASK | HOUR_MASK | AM_PM_MASK | HOUR_OF_DAY_MASK | MINUTE_MASK | SECOND_MASK | MILLISECOND_MASK | ZONE_OFFSET_MASK | DST_OFFSET_MASK; if ((fieldsForFixedMax & (1 << field)) != 0) { return getMaximum(field); } GregorianCalendar gc = getNormalizedCalendar(); BaseCalendar.Date date = gc.cdate; BaseCalendar cal = gc.calsys; int normalizedYear = date.getNormalizedYear(); int value = -1; switch(field) { case MONTH: { if (!gc.isCutoverYear(normalizedYear)) { value = DECEMBER; break; } long nextJan1; do { nextJan1 = gcal.getFixedDate(++normalizedYear, BaseCalendar.JANUARY, 1, null); } while (nextJan1 < gregorianCutoverDate); BaseCalendar.Date d = (BaseCalendar.Date) date.clone(); cal.getCalendarDateFromFixedDate(d, nextJan1 - 1); value = d.getMonth() - 1; } break; case DAY_OF_MONTH: { value = cal.getMonthLength(date); if (!gc.isCutoverYear(normalizedYear) || date.getDayOfMonth() == value) { break; } long fd = gc.getCurrentFixedDate(); if (fd >= gregorianCutoverDate) { break; } int monthLength = gc.actualMonthLength(); long monthEnd = gc.getFixedDateMonth1(gc.cdate, fd) + monthLength - 1; BaseCalendar.Date d = gc.getCalendarDate(monthEnd); value = d.getDayOfMonth(); } break; case DAY_OF_YEAR: { if (!gc.isCutoverYear(normalizedYear)) { value = cal.getYearLength(date); break; } long jan1; if (gregorianCutoverYear == gregorianCutoverYearJulian) { BaseCalendar cocal = gc.getCutoverCalendarSystem(); jan1 = cocal.getFixedDate(normalizedYear, 1, 1, null); } else if (normalizedYear == gregorianCutoverYearJulian) { jan1 = cal.getFixedDate(normalizedYear, 1, 1, null); } else { jan1 = gregorianCutoverDate; } long nextJan1 = gcal.getFixedDate(++normalizedYear, 1, 1, null); if (nextJan1 < gregorianCutoverDate) { nextJan1 = gregorianCutoverDate; } assert jan1 <= cal.getFixedDate(date.getNormalizedYear(), date.getMonth(), date.getDayOfMonth(), date); assert nextJan1 >= cal.getFixedDate(date.getNormalizedYear(), date.getMonth(), date.getDayOfMonth(), date); value = (int) (nextJan1 - jan1); } break; case WEEK_OF_YEAR: { if (!gc.isCutoverYear(normalizedYear)) { CalendarDate d = cal.newCalendarDate(TimeZone.NO_TIMEZONE); d.setDate(date.getYear(), BaseCalendar.JANUARY, 1); int dayOfWeek = cal.getDayOfWeek(d); dayOfWeek -= getFirstDayOfWeek(); if (dayOfWeek < 0) { dayOfWeek += 7; } value = 52; int magic = dayOfWeek + getMinimalDaysInFirstWeek() - 1; if ((magic == 6) || (date.isLeapYear() && (magic == 5 || magic == 12))) { value++; } break; } if (gc == this) { gc = (GregorianCalendar) gc.clone(); } gc.set(DAY_OF_YEAR, getActualMaximum(DAY_OF_YEAR)); value = gc.get(WEEK_OF_YEAR); } break; case WEEK_OF_MONTH: { if (!gc.isCutoverYear(normalizedYear)) { CalendarDate d = cal.newCalendarDate(null); d.setDate(date.getYear(), date.getMonth(), 1); int dayOfWeek = cal.getDayOfWeek(d); int monthLength = cal.getMonthLength(d); dayOfWeek -= getFirstDayOfWeek(); if (dayOfWeek < 0) { dayOfWeek += 7; } int nDaysFirstWeek = 7 - dayOfWeek; value = 3; if (nDaysFirstWeek >= getMinimalDaysInFirstWeek()) { value++; } monthLength -= nDaysFirstWeek + 7 * 3; if (monthLength > 0) { value++; if (monthLength > 7) { value++; } } break; } if (gc == this) { gc = (GregorianCalendar) gc.clone(); } int y = gc.internalGet(YEAR); int m = gc.internalGet(MONTH); do { value = gc.get(WEEK_OF_MONTH); gc.add(WEEK_OF_MONTH, +1); } while (gc.get(YEAR) == y && gc.get(MONTH) == m); } break; case DAY_OF_WEEK_IN_MONTH: { int ndays, dow1; int dow = date.getDayOfWeek(); if (!gc.isCutoverYear(normalizedYear)) { BaseCalendar.Date d = (BaseCalendar.Date) date.clone(); ndays = cal.getMonthLength(d); d.setDayOfMonth(1); cal.normalize(d); dow1 = d.getDayOfWeek(); } else { if (gc == this) { gc = (GregorianCalendar) clone(); } ndays = gc.actualMonthLength(); gc.set(DAY_OF_MONTH, gc.getActualMinimum(DAY_OF_MONTH)); dow1 = gc.get(DAY_OF_WEEK); } int x = dow - dow1; if (x < 0) { x += 7; } ndays -= x; value = (ndays + 6) / 7; } break; case YEAR: { if (gc == this) { gc = (GregorianCalendar) clone(); } long current = gc.getYearOffsetInMillis(); if (gc.internalGetEra() == CE) { gc.setTimeInMillis(Long.MAX_VALUE); value = gc.get(YEAR); long maxEnd = gc.getYearOffsetInMillis(); if (current > maxEnd) { value--; } } else { CalendarSystem mincal = gc.getTimeInMillis() >= gregorianCutover ? gcal : getJulianCalendarSystem(); CalendarDate d = mincal.getCalendarDate(Long.MIN_VALUE, getZone()); long maxEnd = (cal.getDayOfYear(d) - 1) * 24 + d.getHours(); maxEnd *= 60; maxEnd += d.getMinutes(); maxEnd *= 60; maxEnd += d.getSeconds(); maxEnd *= 1000; maxEnd += d.getMillis(); value = d.getYear(); if (value <= 0) { assert mincal == gcal; value = 1 - value; } if (current < maxEnd) { value--; } } } break; default: throw new ArrayIndexOutOfBoundsException(field); } return value; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.Vector.get(int)
/** * Returns the element at the specified position in this Vector. * @param index index of element to return. * @return object at the specified index * @exception ArrayIndexOutOfBoundsException index is out of range (index * < 0 || index >= size()). * @since 1.2 */ public synchronized E get(int index) { if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); return (E) elementData[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.remove(int)
/** * Removes the element at the specified position in this Vector. * shifts any subsequent elements to the left (subtracts one from their * indices). Returns the element that was removed from the Vector. * @exception ArrayIndexOutOfBoundsException index out of range (index * < 0 || index >= size()). * @param index the index of the element to removed. * @return element that was removed * @since 1.2 */ public synchronized E remove(int index) { modCount++; if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); Object oldValue = elementData[index]; int numMoved = elementCount - index - 1; if (numMoved > 0) System.arraycopy(elementData, index + 1, elementData, index, numMoved); elementData[--elementCount] = null; return (E) oldValue; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.Vector.removeElementAt(int)
/** * Deletes the component at the specified index. Each component in * this vector with an index greater or equal to the specified * <code>index</code> is shifted downward to have an index one * smaller than the value it had previously. The size of this vector * is decreased by <tt>1</tt>. * The index must be a value greater than or equal to <code>0</code> * and less than the current size of the vector. * This method is identical in functionality to the remove method * (which is part of the List interface). Note that the remove method * returns the old value that was stored at the specified position. * @param index the index of the object to remove. * @exception ArrayIndexOutOfBoundsException if the index was invalid. * @see #size() * @see #remove(int) * @see List */ public synchronized void removeElementAt(int index) { modCount++; if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + ' >= ' + elementCount); } else if (index < 0) { throw new ArrayIndexOutOfBoundsException(index); } int j = elementCount - index - 1; if (j > 0) { System.arraycopy(elementData, index + 1, elementData, index, j); } elementCount--; elementData[elementCount] = null; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.Vector.set(int, E)
/** * Replaces the element at the specified position in this Vector with the * specified element. * @param index index of element to replace. * @param element element to be stored at the specified position. * @return the element previously at the specified position. * @exception ArrayIndexOutOfBoundsException index out of range * (index < 0 || index >= size()). * @since 1.2 */ public synchronized E set(int index, E element) { if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); Object oldValue = elementData[index]; elementData[index] = element; return (E) oldValue; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.naming.NameImpl.getPrefix(int)
public Enumeration getPrefix(int posn) { if (posn < 0 || posn > size()) { throw new ArrayIndexOutOfBoundsException(posn); } return new NameImplEnumerator(components, 0, posn); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.naming.NameImpl.getSuffix(int)
public Enumeration getSuffix(int posn) { int cnt = size(); if (posn < 0 || posn > cnt) { throw new ArrayIndexOutOfBoundsException(posn); } return new NameImplEnumerator(components, posn, cnt); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.sound.midi.Track.get(int)
/** * Obtains the event at the specified index. * @param index the location of the desired event in the event vector * @throws <code>ArrayIndexOutOfBoundsException</code> if the * specified index is negative or not less than the current size of * this track. * @see #size */ public MidiEvent get(int index) throws ArrayIndexOutOfBoundsException { try { synchronized (eventsList) { return (MidiEvent) eventsList.get(index); } } catch (IndexOutOfBoundsException ioobe) { throw new ArrayIndexOutOfBoundsException(ioobe.getMessage()); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
org.xml.sax.helpers.AttributesImpl.badIndex(int)
/** * Report a bad array index in a manipulator. * @param index The index to report. * @exception java.lang.ArrayIndexOutOfBoundsException Always. */ private void badIndex(int index) throws ArrayIndexOutOfBoundsException { String msg = 'Attempt to modify attribute at illegal index: ' + index; throw new ArrayIndexOutOfBoundsException(msg); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.Vector.insertElementAt(E, int)
/** * Inserts the specified object as a component in this vector at the * specified <code>index</code>. Each component in this vector with * an index greater or equal to the specified <code>index</code> is * shifted upward to have an index one greater than the value it had * previously. * The index must be a value greater than or equal to <code>0</code> * and less than or equal to the current size of the vector. (If the * index is equal to the current size of the vector, the new element * is appended to the Vector.) * This method is identical in functionality to the add(Object, int) method * (which is part of the List interface). Note that the add method reverses * the order of the parameters, to more closely match array usage. * @param obj the component to insert. * @param index where to insert the new component. * @exception ArrayIndexOutOfBoundsException if the index was invalid. * @see #size() * @see #add(int, Object) * @see List */ public synchronized void insertElementAt(E obj, int index) { modCount++; if (index > elementCount) { throw new ArrayIndexOutOfBoundsException(index + ' > ' + elementCount); } ensureCapacityHelper(elementCount + 1); System.arraycopy(elementData, index, elementData, index + 1, elementCount - index); elementData[index] = obj; elementCount++; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
com.sun.org.apache.xpath.internal.NodeSet.removeElementAt(int)
/** * Deletes the component at the specified index. Each component in * this vector with an index greater or equal to the specified * index is shifted downward to have an index one smaller than * the value it had previously. * @param i Index of node to remove */ public void removeElementAt(int i) { if (null == m_map) return; if (i >= m_firstFree) throw new ArrayIndexOutOfBoundsException(i + ' >= ' + m_firstFree); else if (i < 0) throw new ArrayIndexOutOfBoundsException(i); if (i < m_firstFree - 1) System.arraycopy(m_map, i + 1, m_map, i, m_firstFree - i - 1); m_firstFree--; m_map[m_firstFree] = null; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.util.Vector.elementAt(int)
/** * Returns the component at the specified index. * This method is identical in functionality to the get method * (which is part of the List interface). * @param index an index into this vector. * @return the component at the specified index. * @exception ArrayIndexOutOfBoundsException if the <tt>index</tt> * is negative or not less than the current size of this * <tt>Vector</tt> object. * given. * @see #get(int) * @see List */ public synchronized E elementAt(int index) { if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + ' >= ' + elementCount); } return (E) elementData[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.setElementAt(E, int)
/** * Sets the component at the specified <code>index</code> of this * vector to be the specified object. The previous component at that * position is discarded. * The index must be a value greater than or equal to <code>0</code> * and less than the current size of the vector. * This method is identical in functionality to the set method * (which is part of the List interface). Note that the set method reverses * the order of the parameters, to more closely match array usage. Note * also that the set method returns the old value that was stored at the * specified position. * @param obj what the component is to be set to. * @param index the specified index. * @exception ArrayIndexOutOfBoundsException if the index was invalid. * @see #size() * @see List * @see #set(int, java.lang.Object) */ public synchronized void setElementAt(E obj, int index) { if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + ' >= ' + elementCount); } elementData[index] = obj; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.Raster.createBandedRaster(int, int, int, int, int, int, Point)
/** * Creates a Raster based on a BandedSampleModel with the * specified data type, width, height, scanline stride, bank * indices and band offsets. The number of bands is inferred from * bankIndices.length and bandOffsets.length, which must be the * same. * The upper left corner of the Raster is given by the * location argument. The dataType parameter should be one of the * enumerated values defined in the DataBuffer class. * The only dataTypes supported currently are TYPE_BYTE, TYPE_USHORT, * and TYPE_INT. * @param dataType the data type for storing samples * @param w the width in pixels of the image data * @param h the height in pixels of the image data * @param scanlineStride the line stride of the image data * @param bankIndices the bank indices for each band * @param bandOffsets the offsets of all bands * @param location the upper-left corner of the <code>Raster</code> * @return a WritableRaster object with the specified data type, * width, height, scanline stride, bank indices and band * offsets. * @throws RasterFormatException if <code>w</code> or <code>h</code> * is less than or equal to zero, or computing either * <code>location.x + w</code> or * <code>location.y + h</code> results in integer * overflow * @throws IllegalArgumentException if <code>dataType</code> is not * one of the supported data types, which are * <code>DataBuffer.TYPE_BYTE</code>, * <code>DataBuffer.TYPE_USHORT</code> * or <code>DataBuffer.TYPE_INT</code> * @throws ArrayIndexOutOfBoundsException if <code>bankIndices</code> * or <code>bandOffsets</code> is <code>null</code> */ public static WritableRaster createBandedRaster(int dataType, int w, int h, int scanlineStride, int bankIndices[], int bandOffsets[], Point location) { DataBuffer d; int bands = bandOffsets.length; if (bankIndices == null) { throw new ArrayIndexOutOfBoundsException('Bank indices array is null'); } if (bandOffsets == null) { throw new ArrayIndexOutOfBoundsException('Band offsets array is null'); } int maxBank = bankIndices[0]; int maxBandOff = bandOffsets[0]; for (int i = 1; i < bands; i++) { if (bankIndices[i] > maxBank) { maxBank = bankIndices[i]; } if (bandOffsets[i] > maxBandOff) { maxBandOff = bandOffsets[i]; } } int banks = maxBank + 1; int size = maxBandOff + scanlineStride * (h - 1) + (w - 1) + 1; switch(dataType) { case DataBuffer.TYPE_BYTE: d = new DataBufferByte(size, banks); break; case DataBuffer.TYPE_USHORT: d = new DataBufferUShort(size, banks); break; case DataBuffer.TYPE_INT: d = new DataBufferInt(size, banks); break; default: throw new IllegalArgumentException('Unsupported data type ' + dataType); } SunWritableRaster raster = (SunWritableRaster) createBandedRaster(d, w, h, scanlineStride, bankIndices, bandOffsets, location); raster.setStolen(false); return raster; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BufferedImage.getTile(int, int)
/** * Returns tile (<code>tileX</code>, <code>tileY</code>). Note * that <code>tileX</code> and <code>tileY</code> are indices * into the tile array, not pixel locations. The <code>Raster</code> * that is returned is live, which means that it is updated if the * image is changed. * @param tileX the x index of the requested tile in the tile array * @param tileY the y index of the requested tile in the tile array * @return a <code>Raster</code> that is the tile defined by the * arguments <code>tileX</code> and <code>tileY</code>. * @exception <code>ArrayIndexOutOfBoundsException</code> if both * <code>tileX</code> and <code>tileY</code> are not * equal to 0 */ public Raster getTile(int tileX, int tileY) { if (tileX == 0 && tileY == 0) { return raster; } throw new ArrayIndexOutOfBoundsException('BufferedImages only have' + ' one tile with index 0,0'); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BandedSampleModel.getDataElements(int, int, Object, DataBuffer)
/** * Returns data for a single pixel in a primitive array of type * TransferType. For a BandedSampleModel, this will be the same * as the data type, and samples will be returned one per array * element. Generally, obj * should be passed in as null, so that the Object will be created * automatically and will be of the right primitive data type. * The following code illustrates transferring data for one pixel from * DataBuffer <code>db1</code>, whose storage layout is described by * BandedSampleModel <code>bsm1</code>, to DataBuffer <code>db2</code>, * whose storage layout is described by * BandedSampleModel <code>bsm2</code>. * The transfer will generally be more efficient than using * getPixel/setPixel. * BandedSampleModel bsm1, bsm2; * DataBufferInt db1, db2; * bsm2.setDataElements(x, y, bsm1.getDataElements(x, y, null, db1), * db2); * Using getDataElements/setDataElements to transfer between two * DataBuffer/SampleModel pairs is legitimate if the SampleModels have * the same number of bands, corresponding bands have the same number of * bits per sample, and the TransferTypes are the same. * If obj is non-null, it should be a primitive array of type TransferType. * Otherwise, a ClassCastException is thrown. An * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds, or if obj is non-null and is not large enough to hold * the pixel data. * @param x, y The coordinates of the pixel location * @param obj If non-null, a primitive array in which to return * the pixel data. * @param data The DataBuffer containing the image data. * @return the data for the specified pixel. * @see #setDataElements(int, int, Object, DataBuffer) */ public Object getDataElements(int x, int y, Object obj, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int type = getTransferType(); int numDataElems = getNumDataElements(); int pixelOffset = y * scanlineStride + x; switch(type) { case DataBuffer.TYPE_BYTE: byte[] bdata; if (obj == null) { bdata = new byte[numDataElems]; } else { bdata = (byte[]) obj; } for (int i = 0; i < numDataElems; i++) { bdata[i] = (byte) data.getElem(bankIndices[i], pixelOffset + bandOffsets[i]); } obj = (Object) bdata; break; case DataBuffer.TYPE_USHORT: case DataBuffer.TYPE_SHORT: short[] sdata; if (obj == null) { sdata = new short[numDataElems]; } else { sdata = (short[]) obj; } for (int i = 0; i < numDataElems; i++) { sdata[i] = (short) data.getElem(bankIndices[i], pixelOffset + bandOffsets[i]); } obj = (Object) sdata; break; case DataBuffer.TYPE_INT: int[] idata; if (obj == null) { idata = new int[numDataElems]; } else { idata = (int[]) obj; } for (int i = 0; i < numDataElems; i++) { idata[i] = data.getElem(bankIndices[i], pixelOffset + bandOffsets[i]); } obj = (Object) idata; break; case DataBuffer.TYPE_FLOAT: float[] fdata; if (obj == null) { fdata = new float[numDataElems]; } else { fdata = (float[]) obj; } for (int i = 0; i < numDataElems; i++) { fdata[i] = data.getElemFloat(bankIndices[i], pixelOffset + bandOffsets[i]); } obj = (Object) fdata; break; case DataBuffer.TYPE_DOUBLE: double[] ddata; if (obj == null) { ddata = new double[numDataElems]; } else { ddata = (double[]) obj; } for (int i = 0; i < numDataElems; i++) { ddata[i] = data.getElemDouble(bankIndices[i], pixelOffset + bandOffsets[i]); } obj = (Object) ddata; break; } return obj; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BandedSampleModel.getPixel(int, int, int, DataBuffer)
/** * Returns all samples for the specified pixel in an int array. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x, y The coordinates of the pixel location * @param iArray If non-null, returns the samples in this array * @param data The DataBuffer containing the image data * @return the samples for the specified pixel. * @see #setPixel(int, int, int[], DataBuffer) */ public int[] getPixel(int x, int y, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int[] pixels; if (iArray != null) { pixels = iArray; } else { pixels = new int[numBands]; } int pixelOffset = y * scanlineStride + x; for (int i = 0; i < numBands; i++) { pixels[i] = data.getElem(bankIndices[i], pixelOffset + bandOffsets[i]); } return pixels; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BandedSampleModel.getPixels(int, int, int, int, int, DataBuffer)
/** * Returns all samples for the specified rectangle of pixels in * an int array, one sample per data array element. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x, y The coordinates of the upper left pixel location * @param w The width of the pixel rectangle * @param h The height of the pixel rectangle * @param iArray If non-null, returns the samples in this array * @param data The DataBuffer containing the image data * @return the samples for the pixels within the specified region. * @see #setPixels(int, int, int, int, int[], DataBuffer) */ public int[] getPixels(int x, int y, int w, int h, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int[] pixels; if (iArray != null) { pixels = iArray; } else { pixels = new int[w * h * numBands]; } for (int k = 0; k < numBands; k++) { int lineOffset = y * scanlineStride + x + bandOffsets[k]; int srcOffset = k; int bank = bankIndices[k]; for (int i = 0; i < h; i++) { int pixelOffset = lineOffset; for (int j = 0; j < w; j++) { pixels[srcOffset] = data.getElem(bank, pixelOffset++); srcOffset += numBands; } lineOffset += scanlineStride; } } return pixels; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BandedSampleModel.getSample(int, int, int, DataBuffer)
/** * Returns as int the sample in a specified band for the pixel * located at (x,y). * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x, y The coordinates of the pixel location * @param b The band to return * @param data The DataBuffer containing the image data * @return the sample in the specified band for the specified pixel. * @see #setSample(int, int, int, int, DataBuffer) */ public int getSample(int x, int y, int b, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int sample = data.getElem(bankIndices[b], y * scanlineStride + x + bandOffsets[b]); return sample; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BandedSampleModel.getSampleDouble(int, int, int, DataBuffer)
/** * Returns the sample in a specified band * for a pixel located at (x,y) as a double. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x, y The coordinates of the pixel location * @param b The band to return * @param data The DataBuffer containing the image data * @return a double value that represents the sample in the specified * band for the specified pixel. */ public double getSampleDouble(int x, int y, int b, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } double sample = data.getElemDouble(bankIndices[b], y * scanlineStride + x + bandOffsets[b]); return sample; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BandedSampleModel.getSampleFloat(int, int, int, DataBuffer)
/** * Returns the sample in a specified band * for the pixel located at (x,y) as a float. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x, y Thecoordinates of the pixel location * @param b The band to return * @param data The DataBuffer containing the image data * @return a float value that represents the sample in the specified * band for the specified pixel. */ public float getSampleFloat(int x, int y, int b, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } float sample = data.getElemFloat(bankIndices[b], y * scanlineStride + x + bandOffsets[b]); return sample; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BandedSampleModel.getSamples(int, int, int, int, int, int, DataBuffer)
/** * Returns the samples in a specified band for the specified rectangle * of pixels in an int array, one sample per data array element. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x, y The coordinates of the upper left pixel location * @param w The width of the pixel rectangle * @param h The height of the pixel rectangle * @param b The band to return * @param iArray If non-null, returns the samples in this array * @param data The DataBuffer containing the image data * @return the samples in the specified band for the pixels within * the specified region. * @see #setSamples(int, int, int, int, int, int[], DataBuffer) */ public int[] getSamples(int x, int y, int w, int h, int b, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int samples[]; if (iArray != null) { samples = iArray; } else { samples = new int[w * h]; } int lineOffset = y * scanlineStride + x + bandOffsets[b]; int srcOffset = 0; int bank = bankIndices[b]; for (int i = 0; i < h; i++) { int sampleOffset = lineOffset; for (int j = 0; j < w; j++) { samples[srcOffset++] = data.getElem(bank, sampleOffset++); } lineOffset += scanlineStride; } return samples; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BandedSampleModel.setDataElements(int, int, Object, DataBuffer)
/** * Sets the data for a single pixel in the specified DataBuffer from a * primitive array of type TransferType. For a BandedSampleModel, * this will be the same as the data type, and samples are transferred * one per array element. * The following code illustrates transferring data for one pixel from * DataBuffer <code>db1</code>, whose storage layout is described by * BandedSampleModel <code>bsm1</code>, to DataBuffer <code>db2</code>, * whose storage layout is described by * BandedSampleModel <code>bsm2</code>. * The transfer will generally be more efficient than using * getPixel/setPixel. * BandedSampleModel bsm1, bsm2; * DataBufferInt db1, db2; * bsm2.setDataElements(x, y, bsm1.getDataElements(x, y, null, db1), * db2); * Using getDataElements/setDataElements to transfer between two * DataBuffer/SampleModel pairs is legitimate if the SampleModels have * the same number of bands, corresponding bands have the same number of * bits per sample, and the TransferTypes are the same. * obj must be a primitive array of type TransferType. Otherwise, * a ClassCastException is thrown. An * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds, or if obj is not large enough to hold the pixel data. * @param x, y The coordinates of the pixel location * @param obj If non-null, returns the primitive array in this * object * @param data The DataBuffer containing the image data * @see #getDataElements(int, int, Object, DataBuffer) */ public void setDataElements(int x, int y, Object obj, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int type = getTransferType(); int numDataElems = getNumDataElements(); int pixelOffset = y * scanlineStride + x; switch(type) { case DataBuffer.TYPE_BYTE: byte[] barray = (byte[]) obj; for (int i = 0; i < numDataElems; i++) { data.setElem(bankIndices[i], pixelOffset + bandOffsets[i], barray[i] & 0xff); } break; case DataBuffer.TYPE_USHORT: case DataBuffer.TYPE_SHORT: short[] sarray = (short[]) obj; for (int i = 0; i < numDataElems; i++) { data.setElem(bankIndices[i], pixelOffset + bandOffsets[i], sarray[i] & 0xffff); } break; case DataBuffer.TYPE_INT: int[] iarray = (int[]) obj; for (int i = 0; i < numDataElems; i++) { data.setElem(bankIndices[i], pixelOffset + bandOffsets[i], iarray[i]); } break; case DataBuffer.TYPE_FLOAT: float[] farray = (float[]) obj; for (int i = 0; i < numDataElems; i++) { data.setElemFloat(bankIndices[i], pixelOffset + bandOffsets[i], farray[i]); } break; case DataBuffer.TYPE_DOUBLE: double[] darray = (double[]) obj; for (int i = 0; i < numDataElems; i++) { data.setElemDouble(bankIndices[i], pixelOffset + bandOffsets[i], darray[i]); } break; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BandedSampleModel.setPixel(int, int, int, DataBuffer)
/** * Sets a pixel in the DataBuffer using an int array of samples for input. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x, y The coordinates of the pixel location * @param iArray The input samples in an int array * @param data The DataBuffer containing the image data * @see #getPixel(int, int, int[], DataBuffer) */ public void setPixel(int x, int y, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int pixelOffset = y * scanlineStride + x; for (int i = 0; i < numBands; i++) { data.setElem(bankIndices[i], pixelOffset + bandOffsets[i], iArray[i]); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BandedSampleModel.setPixels(int, int, int, int, int, DataBuffer)
/** * Sets all samples for a rectangle of pixels from an int array containing * one sample per array element. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x, y The coordinates of the upper left pixel location * @param w The width of the pixel rectangle * @param h The height of the pixel rectangle * @param iArray The input samples in an int array * @param data The DataBuffer containing the image data * @see #getPixels(int, int, int, int, int[], DataBuffer) */ public void setPixels(int x, int y, int w, int h, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } for (int k = 0; k < numBands; k++) { int lineOffset = y * scanlineStride + x + bandOffsets[k]; int srcOffset = k; int bank = bankIndices[k]; for (int i = 0; i < h; i++) { int pixelOffset = lineOffset; for (int j = 0; j < w; j++) { data.setElem(bank, pixelOffset++, iArray[srcOffset]); srcOffset += numBands; } lineOffset += scanlineStride; } } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BandedSampleModel.setSample(int, int, int, double, DataBuffer)
/** * Sets a sample in the specified band for the pixel located at (x,y) * in the DataBuffer using a double for input. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x, y The coordinates of the pixel location * @param b The band to set * @param s The input sample as a double * @param data The DataBuffer containing the image data * @see #getSample(int, int, int, DataBuffer) */ public void setSample(int x, int y, int b, double s, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } data.setElemDouble(bankIndices[b], y * scanlineStride + x + bandOffsets[b], s); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BandedSampleModel.setSample(int, int, int, float, DataBuffer)
/** * Sets a sample in the specified band for the pixel located at (x,y) * in the DataBuffer using a float for input. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x, y The coordinates of the pixel location * @param b The band to set * @param s The input sample as a float * @param data The DataBuffer containing the image data * @see #getSample(int, int, int, DataBuffer) */ public void setSample(int x, int y, int b, float s, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } data.setElemFloat(bankIndices[b], y * scanlineStride + x + bandOffsets[b], s); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BandedSampleModel.setSample(int, int, int, int, DataBuffer)
/** * Sets a sample in the specified band for the pixel located at (x,y) * in the DataBuffer using an int for input. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x, y The coordinates of the pixel location * @param b The band to set * @param s The input sample as an int * @param data The DataBuffer containing the image data * @see #getSample(int, int, int, DataBuffer) */ public void setSample(int x, int y, int b, int s, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } data.setElem(bankIndices[b], y * scanlineStride + x + bandOffsets[b], s); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.BandedSampleModel.setSamples(int, int, int, int, int, int, DataBuffer)
/** * Sets the samples in the specified band for the specified rectangle * of pixels from an int array containing one sample per data array element. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x, y The coordinates of the upper left pixel location * @param w The width of the pixel rectangle * @param h The height of the pixel rectangle * @param b The band to set * @param iArray The input sample array * @param data The DataBuffer containing the image data * @see #getSamples(int, int, int, int, int, int[], DataBuffer) */ public void setSamples(int x, int y, int w, int h, int b, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int lineOffset = y * scanlineStride + x + bandOffsets[b]; int srcOffset = 0; int bank = bankIndices[b]; for (int i = 0; i < h; i++) { int sampleOffset = lineOffset; for (int j = 0; j < w; j++) { data.setElem(bank, sampleOffset++, iArray[srcOffset++]); } lineOffset += scanlineStride; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ComponentSampleModel.getDataElements(int, int, Object, DataBuffer)
/** * Returns data for a single pixel in a primitive array of type * <code>TransferType</code>. For a <code>ComponentSampleModel</code>, * this is the same as the data type, and samples are returned * one per array element. Generally, <code>obj</code> should * be passed in as <code>null</code>, so that the <code>Object</code> * is created automatically and is the right primitive data type. * The following code illustrates transferring data for one pixel from * <code>DataBuffer</code> <code>db1</code>, whose storage layout is * described by <code>ComponentSampleModel</code> <code>csm1</code>, * to <code>DataBuffer</code> <code>db2</code>, whose storage layout * is described by <code>ComponentSampleModel</code> <code>csm2</code>. * The transfer is usually more efficient than using * <code>getPixel</code> and <code>setPixel</code>. * ComponentSampleModel csm1, csm2; * DataBufferInt db1, db2; * csm2.setDataElements(x, y, * csm1.getDataElements(x, y, null, db1), db2); * * Using <code>getDataElements</code> and <code>setDataElements</code> * to transfer between two <code>DataBuffer/SampleModel</code> * pairs is legitimate if the <code>SampleModel</code> objects have * the same number of bands, corresponding bands have the same number of * bits per sample, and the <code>TransferType</code>s are the same. * If <code>obj</code> is not <code>null</code>, it should be a * primitive array of type <code>TransferType</code>. * Otherwise, a <code>ClassCastException</code> is thrown. An * <code>ArrayIndexOutOfBoundsException</code> might be thrown if the * coordinates are not in bounds, or if <code>obj</code> is not * <code>null</code> and is not large enough to hold * the pixel data. * @param x, y the coordinates of the pixel location * @param obj if non-<code>null</code>, a primitive array * in which to return the pixel data * @param data the <code>DataBuffer</code> containing the image data * @return the data of the specified pixel * @see #setDataElements(int, int, Object, DataBuffer) * @throws NullPointerException if data is null. * @throws ArrayIndexOutOfBoundsException if the coordinates are * not in bounds, or if obj is too small to hold the ouput. */ public Object getDataElements(int x, int y, Object obj, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int type = getTransferType(); int numDataElems = getNumDataElements(); int pixelOffset = y * scanlineStride + x * pixelStride; switch(type) { case DataBuffer.TYPE_BYTE: byte[] bdata; if (obj == null) bdata = new byte[numDataElems]; else bdata = (byte[]) obj; for (int i = 0; i < numDataElems; i++) { bdata[i] = (byte) data.getElem(bankIndices[i], pixelOffset + bandOffsets[i]); } obj = (Object) bdata; break; case DataBuffer.TYPE_USHORT: case DataBuffer.TYPE_SHORT: short[] sdata; if (obj == null) sdata = new short[numDataElems]; else sdata = (short[]) obj; for (int i = 0; i < numDataElems; i++) { sdata[i] = (short) data.getElem(bankIndices[i], pixelOffset + bandOffsets[i]); } obj = (Object) sdata; break; case DataBuffer.TYPE_INT: int[] idata; if (obj == null) idata = new int[numDataElems]; else idata = (int[]) obj; for (int i = 0; i < numDataElems; i++) { idata[i] = data.getElem(bankIndices[i], pixelOffset + bandOffsets[i]); } obj = (Object) idata; break; case DataBuffer.TYPE_FLOAT: float[] fdata; if (obj == null) fdata = new float[numDataElems]; else fdata = (float[]) obj; for (int i = 0; i < numDataElems; i++) { fdata[i] = data.getElemFloat(bankIndices[i], pixelOffset + bandOffsets[i]); } obj = (Object) fdata; break; case DataBuffer.TYPE_DOUBLE: double[] ddata; if (obj == null) ddata = new double[numDataElems]; else ddata = (double[]) obj; for (int i = 0; i < numDataElems; i++) { ddata[i] = data.getElemDouble(bankIndices[i], pixelOffset + bandOffsets[i]); } obj = (Object) ddata; break; } return obj; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ComponentSampleModel.getPixel(int, int, int, DataBuffer)
/** * Returns all samples for the specified pixel in an int array, * one sample per array element. * An <code>ArrayIndexOutOfBoundsException</code> might be thrown if * the coordinates are not in bounds. * @param x, y The coordinates of the pixel location * @param iArray If non-null, returns the samples in this array * @param data The DataBuffer containing the image data * @return the samples of the specified pixel. * @see #setPixel(int, int, int[], DataBuffer) * @throws NullPointerException if data is null. * @throws ArrayIndexOutOfBoundsException if the coordinates are * not in bounds, or if iArray is too small to hold the output. */ public int[] getPixel(int x, int y, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int pixels[]; if (iArray != null) { pixels = iArray; } else { pixels = new int[numBands]; } int pixelOffset = y * scanlineStride + x * pixelStride; for (int i = 0; i < numBands; i++) { pixels[i] = data.getElem(bankIndices[i], pixelOffset + bandOffsets[i]); } return pixels; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ComponentSampleModel.getPixels(int, int, int, int, int, DataBuffer)
/** * Returns all samples for the specified rectangle of pixels in * an int array, one sample per array element. * An <code>ArrayIndexOutOfBoundsException</code> might be thrown if * the coordinates are not in bounds. * @param x, y the coordinates of the upper left pixel location * @param w The width of the pixel rectangle * @param h The height of the pixel rectangle * @param iArray If non-null, returns the samples in this array * @param data The DataBuffer containing the image data * @return the samples of the pixels within the specified region. * @see #setPixels(int, int, int, int, int[], DataBuffer) */ public int[] getPixels(int x, int y, int w, int h, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int pixels[]; if (iArray != null) { pixels = iArray; } else { pixels = new int[w * h * numBands]; } int lineOffset = y * scanlineStride + x * pixelStride; int srcOffset = 0; for (int i = 0; i < h; i++) { int pixelOffset = lineOffset; for (int j = 0; j < w; j++) { for (int k = 0; k < numBands; k++) { pixels[srcOffset++] = data.getElem(bankIndices[k], pixelOffset + bandOffsets[k]); } pixelOffset += pixelStride; } lineOffset += scanlineStride; } return pixels; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ComponentSampleModel.getSample(int, int, int, DataBuffer)
/** * Returns as int the sample in a specified band for the pixel * located at (x,y). * An <code>ArrayIndexOutOfBoundsException</code> might be thrown if * the coordinates are not in bounds. * @param x, y the coordinates of the pixel location * @param b the band to return * @param data the <code>DataBuffer</code> containing the image data * @return the sample in a specified band for the specified pixel * @see #setSample(int, int, int, int, DataBuffer) */ public int getSample(int x, int y, int b, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int sample = data.getElem(bankIndices[b], y * scanlineStride + x * pixelStride + bandOffsets[b]); return sample; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ComponentSampleModel.getSampleDouble(int, int, int, DataBuffer)
/** * Returns the sample in a specified band * for a pixel located at (x,y) as a double. * An <code>ArrayIndexOutOfBoundsException</code> might be * thrown if the coordinates are not in bounds. * @param x, y The coordinates of the pixel location * @param b The band to return * @param data The DataBuffer containing the image data * @return a double value representing the sample in the specified * band for the specified pixel. */ public double getSampleDouble(int x, int y, int b, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } double sample = data.getElemDouble(bankIndices[b], y * scanlineStride + x * pixelStride + bandOffsets[b]); return sample; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ComponentSampleModel.getSampleFloat(int, int, int, DataBuffer)
/** * Returns the sample in a specified band * for the pixel located at (x,y) as a float. * An <code>ArrayIndexOutOfBoundsException</code> might be * thrown if the coordinates are not in bounds. * @param x, y The coordinates of the pixel location * @param b The band to return * @param data The DataBuffer containing the image data * @return a float value representing the sample in the specified * band for the specified pixel. */ public float getSampleFloat(int x, int y, int b, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } float sample = data.getElemFloat(bankIndices[b], y * scanlineStride + x * pixelStride + bandOffsets[b]); return sample; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ComponentSampleModel.getSamples(int, int, int, int, int, int, DataBuffer)
/** * Returns the samples in a specified band for the specified rectangle * of pixels in an int array, one sample per data array element. * An <code>ArrayIndexOutOfBoundsException</code> might be thrown if * the coordinates are not in bounds. * @param x, y the coordinates of the upper left pixel location * @param w the width of the pixel rectangle * @param h the height of the pixel rectangle * @param b the band to return * @param iArray if non-<code>null</code>, returns the samples * in this array * @param data the <code>DataBuffer</code> containing the image data * @return the samples in the specified band of the specified pixel * @see #setSamples(int, int, int, int, int, int[], DataBuffer) */ public int[] getSamples(int x, int y, int w, int h, int b, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int samples[]; if (iArray != null) { samples = iArray; } else { samples = new int[w * h]; } int lineOffset = y * scanlineStride + x * pixelStride + bandOffsets[b]; int srcOffset = 0; for (int i = 0; i < h; i++) { int sampleOffset = lineOffset; for (int j = 0; j < w; j++) { samples[srcOffset++] = data.getElem(bankIndices[b], sampleOffset); sampleOffset += pixelStride; } lineOffset += scanlineStride; } return samples; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ComponentSampleModel.setDataElements(int, int, Object, DataBuffer)
/** * Sets the data for a single pixel in the specified * <code>DataBuffer</code> from a primitive array of type * <code>TransferType</code>. For a <code>ComponentSampleModel</code>, * this is the same as the data type, and samples are transferred * one per array element. * The following code illustrates transferring data for one pixel from * <code>DataBuffer</code> <code>db1</code>, whose storage layout is * described by <code>ComponentSampleModel</code> <code>csm1</code>, * to <code>DataBuffer</code> <code>db2</code>, whose storage layout * is described by <code>ComponentSampleModel</code> <code>csm2</code>. * The transfer is usually more efficient than using * <code>getPixel</code> and <code>setPixel</code>. * ComponentSampleModel csm1, csm2; * DataBufferInt db1, db2; * csm2.setDataElements(x, y, csm1.getDataElements(x, y, null, db1), * db2); * Using <code>getDataElements</code> and <code>setDataElements</code> * to transfer between two <code>DataBuffer/SampleModel</code> pairs * is legitimate if the <code>SampleModel</code> objects have * the same number of bands, corresponding bands have the same number of * bits per sample, and the <code>TransferType</code>s are the same. * A <code>ClassCastException</code> is thrown if <code>obj</code> is not * a primitive array of type <code>TransferType</code>. * An <code>ArrayIndexOutOfBoundsException</code> might be thrown if * the coordinates are not in bounds, or if <code>obj</code> is not large * enough to hold the pixel data. * @param x, y the coordinates of the pixel location * @param obj a primitive array containing pixel data * @param data the DataBuffer containing the image data * @see #getDataElements(int, int, Object, DataBuffer) */ public void setDataElements(int x, int y, Object obj, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int type = getTransferType(); int numDataElems = getNumDataElements(); int pixelOffset = y * scanlineStride + x * pixelStride; switch(type) { case DataBuffer.TYPE_BYTE: byte[] barray = (byte[]) obj; for (int i = 0; i < numDataElems; i++) { data.setElem(bankIndices[i], pixelOffset + bandOffsets[i], ((int) barray[i]) & 0xff); } break; case DataBuffer.TYPE_USHORT: case DataBuffer.TYPE_SHORT: short[] sarray = (short[]) obj; for (int i = 0; i < numDataElems; i++) { data.setElem(bankIndices[i], pixelOffset + bandOffsets[i], ((int) sarray[i]) & 0xffff); } break; case DataBuffer.TYPE_INT: int[] iarray = (int[]) obj; for (int i = 0; i < numDataElems; i++) { data.setElem(bankIndices[i], pixelOffset + bandOffsets[i], iarray[i]); } break; case DataBuffer.TYPE_FLOAT: float[] farray = (float[]) obj; for (int i = 0; i < numDataElems; i++) { data.setElemFloat(bankIndices[i], pixelOffset + bandOffsets[i], farray[i]); } break; case DataBuffer.TYPE_DOUBLE: double[] darray = (double[]) obj; for (int i = 0; i < numDataElems; i++) { data.setElemDouble(bankIndices[i], pixelOffset + bandOffsets[i], darray[i]); } break; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ComponentSampleModel.setPixel(int, int, int, DataBuffer)
/** * Sets a pixel in the <code>DataBuffer</code> using an int array of * samples for input. An <code>ArrayIndexOutOfBoundsException</code> * might be thrown if the coordinates are * not in bounds. * @param x, y The coordinates of the pixel location * @param iArray The input samples in an int array * @param data The DataBuffer containing the image data * @see #getPixel(int, int, int[], DataBuffer) */ public void setPixel(int x, int y, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int pixelOffset = y * scanlineStride + x * pixelStride; for (int i = 0; i < numBands; i++) { data.setElem(bankIndices[i], pixelOffset + bandOffsets[i], iArray[i]); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ComponentSampleModel.setPixels(int, int, int, int, int, DataBuffer)
/** * Sets all samples for a rectangle of pixels from an int array containing * one sample per array element. * An <code>ArrayIndexOutOfBoundsException</code> might be thrown if the * coordinates are not in bounds. * @param x, y The coordinates of the upper left pixel location * @param w The width of the pixel rectangle * @param h The height of the pixel rectangle * @param iArray The input samples in an int array * @param data The DataBuffer containing the image data * @see #getPixels(int, int, int, int, int[], DataBuffer) */ public void setPixels(int x, int y, int w, int h, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int lineOffset = y * scanlineStride + x * pixelStride; int srcOffset = 0; for (int i = 0; i < h; i++) { int pixelOffset = lineOffset; for (int j = 0; j < w; j++) { for (int k = 0; k < numBands; k++) { data.setElem(bankIndices[k], pixelOffset + bandOffsets[k], iArray[srcOffset++]); } pixelOffset += pixelStride; } lineOffset += scanlineStride; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ComponentSampleModel.setSample(int, int, int, double, DataBuffer)
/** * Sets a sample in the specified band for the pixel located at (x,y) * in the <code>DataBuffer</code> using a double for input. * An <code>ArrayIndexOutOfBoundsException</code> might be thrown if * the coordinates are not in bounds. * @param x, y The coordinates of the pixel location * @param b The band to set * @param s The input sample as a double * @param data The DataBuffer containing the image data * @see #getSample(int, int, int, DataBuffer) */ public void setSample(int x, int y, int b, double s, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } data.setElemDouble(bankIndices[b], y * scanlineStride + x * pixelStride + bandOffsets[b], s); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ComponentSampleModel.setSample(int, int, int, float, DataBuffer)
/** * Sets a sample in the specified band for the pixel located at (x,y) * in the <code>DataBuffer</code> using a float for input. * An <code>ArrayIndexOutOfBoundsException</code> might be thrown if * the coordinates are not in bounds. * @param x, y The coordinates of the pixel location * @param b The band to set * @param s The input sample as a float * @param data The DataBuffer containing the image data * @see #getSample(int, int, int, DataBuffer) */ public void setSample(int x, int y, int b, float s, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } data.setElemFloat(bankIndices[b], y * scanlineStride + x * pixelStride + bandOffsets[b], s); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ComponentSampleModel.setSample(int, int, int, int, DataBuffer)
/** * Sets a sample in the specified band for the pixel located at (x,y) * in the <code>DataBuffer</code> using an int for input. * An <code>ArrayIndexOutOfBoundsException</code> might be thrown if the * coordinates are not in bounds. * @param x, y the coordinates of the pixel location * @param b the band to set * @param s the input sample as an int * @param data the DataBuffer containing the image data * @see #getSample(int, int, int, DataBuffer) */ public void setSample(int x, int y, int b, int s, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } data.setElem(bankIndices[b], y * scanlineStride + x * pixelStride + bandOffsets[b], s); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ComponentSampleModel.setSamples(int, int, int, int, int, int, DataBuffer)
/** * Sets the samples in the specified band for the specified rectangle * of pixels from an int array containing one sample per data array element. * An <code>ArrayIndexOutOfBoundsException</code> might be thrown if the * coordinates are not in bounds. * @param x, y The coordinates of the upper left pixel location * @param w The width of the pixel rectangle * @param h The height of the pixel rectangle * @param b The band to set * @param iArray The input samples in an int array * @param data The DataBuffer containing the image data * @see #getSamples(int, int, int, int, int, int[], DataBuffer) */ public void setSamples(int x, int y, int w, int h, int b, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int lineOffset = y * scanlineStride + x * pixelStride + bandOffsets[b]; int srcOffset = 0; for (int i = 0; i < h; i++) { int sampleOffset = lineOffset; for (int j = 0; j < w; j++) { data.setElem(bankIndices[b], sampleOffset, iArray[srcOffset++]); sampleOffset += pixelStride; } lineOffset += scanlineStride; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.MultiPixelPackedSampleModel.getDataElements(int, int, Object, DataBuffer)
/** * Returns data for a single pixel in a primitive array of type * TransferType. For a <code>MultiPixelPackedSampleModel</code>, * the array has one element, and the type is the smallest of * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or DataBuffer.TYPE_INT * that can hold a single pixel. Generally, <code>obj</code> * should be passed in as <code>null</code>, so that the * <code>Object</code> is created automatically and is the * correct primitive data type. * The following code illustrates transferring data for one pixel from * <code>DataBuffer</code> <code>db1</code>, whose storage layout is * described by <code>MultiPixelPackedSampleModel</code> * <code>mppsm1</code>, to <code>DataBuffer</code> <code>db2</code>, * whose storage layout is described by * <code>MultiPixelPackedSampleModel</code> <code>mppsm2</code>. * The transfer is generally more efficient than using * <code>getPixel</code> or <code>setPixel</code>. * MultiPixelPackedSampleModel mppsm1, mppsm2; * DataBufferInt db1, db2; * mppsm2.setDataElements(x, y, mppsm1.getDataElements(x, y, null, * db1), db2); * Using <code>getDataElements</code> or <code>setDataElements</code> * to transfer between two <code>DataBuffer/SampleModel</code> pairs * is legitimate if the <code>SampleModels</code> have the same number * of bands, corresponding bands have the same number of * bits per sample, and the TransferTypes are the same. * If <code>obj</code> is not <code>null</code>, it should be a * primitive array of type TransferType. Otherwise, a * <code>ClassCastException</code> is thrown. An * <code>ArrayIndexOutOfBoundsException</code> is thrown if the * coordinates are not in bounds, or if <code>obj</code> is not * <code>null</code> and is not large enough to hold the pixel data. * @param x, y coordinates of the pixel location. * @param obj a primitive array in which to return the pixel data or * <code>null</code>. * @param data the <code>DataBuffer</code> containing the image data. * @return an <code>Object</code> containing data for the specified * pixel. * @exception ClassCastException if <code>obj</code> is not a * primitive array of type TransferType or is not <code>null</code> * @exception ArrayIndexOutOfBoundsException if the coordinates are * not in bounds, or if <code>obj</code> is not <code>null</code> or * not large enough to hold the pixel data * @see #setDataElements(int, int, Object, DataBuffer) */ public Object getDataElements(int x, int y, Object obj, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int type = getTransferType(); int bitnum = dataBitOffset + x * pixelBitStride; int shift = dataElementSize - (bitnum & (dataElementSize - 1)) - pixelBitStride; int element = 0; switch(type) { case DataBuffer.TYPE_BYTE: byte[] bdata; if (obj == null) bdata = new byte[1]; else bdata = (byte[]) obj; element = data.getElem(y * scanlineStride + bitnum / dataElementSize); bdata[0] = (byte) ((element >> shift) & bitMask); obj = (Object) bdata; break; case DataBuffer.TYPE_USHORT: short[] sdata; if (obj == null) sdata = new short[1]; else sdata = (short[]) obj; element = data.getElem(y * scanlineStride + bitnum / dataElementSize); sdata[0] = (short) ((element >> shift) & bitMask); obj = (Object) sdata; break; case DataBuffer.TYPE_INT: int[] idata; if (obj == null) idata = new int[1]; else idata = (int[]) obj; element = data.getElem(y * scanlineStride + bitnum / dataElementSize); idata[0] = (element >> shift) & bitMask; obj = (Object) idata; break; } return obj; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.MultiPixelPackedSampleModel.getPixel(int, int, int, DataBuffer)
/** * Returns the specified single band pixel in the first element * of an <code>int</code> array. * <code>ArrayIndexOutOfBoundsException</code> is thrown if the * coordinates are not in bounds. * @param x, y the coordinates of the pixel location * @param iArray the array containing the pixel to be returned or * <code>null</code> * @param data the <code>DataBuffer</code> where image data is stored * @return an array containing the specified pixel. * @exception ArrayIndexOutOfBoundsException if the coordinates * are not in bounds * @see #setPixel(int, int, int[], DataBuffer) */ public int[] getPixel(int x, int y, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int pixels[]; if (iArray != null) { pixels = iArray; } else { pixels = new int[numBands]; } int bitnum = dataBitOffset + x * pixelBitStride; int element = data.getElem(y * scanlineStride + bitnum / dataElementSize); int shift = dataElementSize - (bitnum & (dataElementSize - 1)) - pixelBitStride; pixels[0] = (element >> shift) & bitMask; return pixels; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.MultiPixelPackedSampleModel.getSample(int, int, int, DataBuffer)
/** * Returns as <code>int</code> the sample in a specified band for the * pixel located at (x, y). An * <code>ArrayIndexOutOfBoundsException</code> is thrown if the * coordinates are not in bounds. * @param x, y the coordinates of the specified pixel * @param b the band to return, which is assumed to be 0 * @param data the <code>DataBuffer</code> containing the image * data * @return the specified band containing the sample of the specified * pixel. * @exception ArrayIndexOutOfBoundException if the specified * coordinates are not in bounds. * @see #setSample(int, int, int, int, DataBuffer) */ public int getSample(int x, int y, int b, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height) || (b != 0)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int bitnum = dataBitOffset + x * pixelBitStride; int element = data.getElem(y * scanlineStride + bitnum / dataElementSize); int shift = dataElementSize - (bitnum & (dataElementSize - 1)) - pixelBitStride; return (element >> shift) & bitMask; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.MultiPixelPackedSampleModel.setDataElements(int, int, Object, DataBuffer)
/** * Sets the data for a single pixel in the specified * <code>DataBuffer</code> from a primitive array of type * TransferType. For a <code>MultiPixelPackedSampleModel</code>, * only the first element of the array holds valid data, * and the type must be the smallest of * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or DataBuffer.TYPE_INT * that can hold a single pixel. * The following code illustrates transferring data for one pixel from * <code>DataBuffer</code> <code>db1</code>, whose storage layout is * described by <code>MultiPixelPackedSampleModel</code> * <code>mppsm1</code>, to <code>DataBuffer</code> <code>db2</code>, * whose storage layout is described by * <code>MultiPixelPackedSampleModel</code> <code>mppsm2</code>. * The transfer is generally more efficient than using * <code>getPixel</code> or <code>setPixel</code>. * MultiPixelPackedSampleModel mppsm1, mppsm2; * DataBufferInt db1, db2; * mppsm2.setDataElements(x, y, mppsm1.getDataElements(x, y, null, * db1), db2); * Using <code>getDataElements</code> or <code>setDataElements</code> to * transfer between two <code>DataBuffer/SampleModel</code> pairs is * legitimate if the <code>SampleModel</code> objects have * the same number of bands, corresponding bands have the same number of * bits per sample, and the TransferTypes are the same. * <code>obj</code> must be a primitive array of type TransferType. * Otherwise, a <code>ClassCastException</code> is thrown. An * <code>ArrayIndexOutOfBoundsException</code> is thrown if the * coordinates are not in bounds, or if <code>obj</code> is not large * enough to hold the pixel data. * @param x, y the coordinates of the pixel location * @param obj a primitive array containing pixel data * @param data the <code>DataBuffer</code> containing the image data * @see #getDataElements(int, int, Object, DataBuffer) */ public void setDataElements(int x, int y, Object obj, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int type = getTransferType(); int bitnum = dataBitOffset + x * pixelBitStride; int index = y * scanlineStride + (bitnum / dataElementSize); int shift = dataElementSize - (bitnum & (dataElementSize - 1)) - pixelBitStride; int element = data.getElem(index); element &= ~(bitMask << shift); switch(type) { case DataBuffer.TYPE_BYTE: byte[] barray = (byte[]) obj; element |= (((int) (barray[0]) & 0xff) & bitMask) << shift; data.setElem(index, element); break; case DataBuffer.TYPE_USHORT: short[] sarray = (short[]) obj; element |= (((int) (sarray[0]) & 0xffff) & bitMask) << shift; data.setElem(index, element); break; case DataBuffer.TYPE_INT: int[] iarray = (int[]) obj; element |= (iarray[0] & bitMask) << shift; data.setElem(index, element); break; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.MultiPixelPackedSampleModel.setPixel(int, int, int[], DataBuffer)
/** * Sets a pixel in the <code>DataBuffer</code> using an * <code>int</code> array for input. * <code>ArrayIndexOutOfBoundsException</code> is thrown if * the coordinates are not in bounds. * @param x, y the coordinates of the pixel location * @param iArray the input pixel in an <code>int</code> array * @param data the <code>DataBuffer</code> containing the image data * @see #getPixel(int, int, int[], DataBuffer) */ public void setPixel(int x, int y, int[] iArray, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int bitnum = dataBitOffset + x * pixelBitStride; int index = y * scanlineStride + (bitnum / dataElementSize); int shift = dataElementSize - (bitnum & (dataElementSize - 1)) - pixelBitStride; int element = data.getElem(index); element &= ~(bitMask << shift); element |= (iArray[0] & bitMask) << shift; data.setElem(index, element); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.MultiPixelPackedSampleModel.setSample(int, int, int, int, DataBuffer)
/** * Sets a sample in the specified band for the pixel located at * (x, y) in the <code>DataBuffer</code> using an * <code>int</code> for input. * An <code>ArrayIndexOutOfBoundsException</code> is thrown if the * coordinates are not in bounds. * @param x, y the coordinates of the specified pixel * @param b the band to return, which is assumed to be 0 * @param s the input sample as an <code>int</code> * @param data the <code>DataBuffer</code> where image data is stored * @exception ArrayIndexOutOfBoundsException if the coordinates are * not in bounds. * @see #getSample(int, int, int, DataBuffer) */ public void setSample(int x, int y, int b, int s, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height) || (b != 0)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int bitnum = dataBitOffset + x * pixelBitStride; int index = y * scanlineStride + (bitnum / dataElementSize); int shift = dataElementSize - (bitnum & (dataElementSize - 1)) - pixelBitStride; int element = data.getElem(index); element &= ~(bitMask << shift); element |= (s & bitMask) << shift; data.setElem(index, element); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.SinglePixelPackedSampleModel.getDataElements(int, int, Object, DataBuffer)
/** * Returns data for a single pixel in a primitive array of type * TransferType. For a SinglePixelPackedSampleModel, the array will * have one element, and the type will be the same as the storage * data type. Generally, obj * should be passed in as null, so that the Object will be created * automatically and will be of the right primitive data type. * The following code illustrates transferring data for one pixel from * DataBuffer <code>db1</code>, whose storage layout is described by * SinglePixelPackedSampleModel <code>sppsm1</code>, to * DataBuffer <code>db2</code>, whose storage layout is described by * SinglePixelPackedSampleModel <code>sppsm2</code>. * The transfer will generally be more efficient than using * getPixel/setPixel. * SinglePixelPackedSampleModel sppsm1, sppsm2; * DataBufferInt db1, db2; * sppsm2.setDataElements(x, y, sppsm1.getDataElements(x, y, null, * db1), db2); * Using getDataElements/setDataElements to transfer between two * DataBuffer/SampleModel pairs is legitimate if the SampleModels have * the same number of bands, corresponding bands have the same number of * bits per sample, and the TransferTypes are the same. * If obj is non-null, it should be a primitive array of type TransferType. * Otherwise, a ClassCastException is thrown. An * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds, or if obj is non-null and is not large enough to hold * the pixel data. * @param x The X coordinate of the pixel location. * @param y The Y coordinate of the pixel location. * @param obj If non-null, a primitive array in which to return * the pixel data. * @param data The DataBuffer containing the image data. * @return the data for the specified pixel. * @see #setDataElements(int, int, Object, DataBuffer) */ public Object getDataElements(int x, int y, Object obj, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int type = getTransferType(); switch(type) { case DataBuffer.TYPE_BYTE: byte[] bdata; if (obj == null) bdata = new byte[1]; else bdata = (byte[]) obj; bdata[0] = (byte) data.getElem(y * scanlineStride + x); obj = (Object) bdata; break; case DataBuffer.TYPE_USHORT: short[] sdata; if (obj == null) sdata = new short[1]; else sdata = (short[]) obj; sdata[0] = (short) data.getElem(y * scanlineStride + x); obj = (Object) sdata; break; case DataBuffer.TYPE_INT: int[] idata; if (obj == null) idata = new int[1]; else idata = (int[]) obj; idata[0] = data.getElem(y * scanlineStride + x); obj = (Object) idata; break; } return obj; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.SinglePixelPackedSampleModel.getPixel(int, int, int, DataBuffer)
/** * Returns all samples in for the specified pixel in an int array. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x The X coordinate of the pixel location. * @param y The Y coordinate of the pixel location. * @param iArray If non-null, returns the samples in this array * @param data The DataBuffer containing the image data. * @return all samples for the specified pixel. * @see #setPixel(int, int, int[], DataBuffer) */ public int[] getPixel(int x, int y, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int pixels[]; if (iArray == null) { pixels = new int[numBands]; } else { pixels = iArray; } int value = data.getElem(y * scanlineStride + x); for (int i = 0; i < numBands; i++) { pixels[i] = (value & bitMasks[i]) >>> bitOffsets[i]; } return pixels; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.SinglePixelPackedSampleModel.getPixels(int, int, int, int, int, DataBuffer)
/** * Returns all samples for the specified rectangle of pixels in * an int array, one sample per array element. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x The X coordinate of the upper left pixel location. * @param y The Y coordinate of the upper left pixel location. * @param w The width of the pixel rectangle. * @param h The height of the pixel rectangle. * @param iArray If non-null, returns the samples in this array. * @param data The DataBuffer containing the image data. * @return all samples for the specified region of pixels. * @see #setPixels(int, int, int, int, int[], DataBuffer) */ public int[] getPixels(int x, int y, int w, int h, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int pixels[]; if (iArray != null) { pixels = iArray; } else { pixels = new int[w * h * numBands]; } int lineOffset = y * scanlineStride + x; int dstOffset = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { int value = data.getElem(lineOffset + j); for (int k = 0; k < numBands; k++) { pixels[dstOffset++] = ((value & bitMasks[k]) >>> bitOffsets[k]); } } lineOffset += scanlineStride; } return pixels; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.SinglePixelPackedSampleModel.getSample(int, int, int, DataBuffer)
/** * Returns as int the sample in a specified band for the pixel * located at (x,y). * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x The X coordinate of the pixel location. * @param y The Y coordinate of the pixel location. * @param b The band to return. * @param data The DataBuffer containing the image data. * @return the sample in a specified band for the specified * pixel. * @see #setSample(int, int, int, int, DataBuffer) */ public int getSample(int x, int y, int b, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int sample = data.getElem(y * scanlineStride + x); return ((sample & bitMasks[b]) >>> bitOffsets[b]); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.SinglePixelPackedSampleModel.getSamples(int, int, int, int, int, int, DataBuffer)
/** * Returns the samples for a specified band for the specified rectangle * of pixels in an int array, one sample per array element. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x The X coordinate of the upper left pixel location. * @param y The Y coordinate of the upper left pixel location. * @param w The width of the pixel rectangle. * @param h The height of the pixel rectangle. * @param b The band to return. * @param iArray If non-null, returns the samples in this array. * @param data The DataBuffer containing the image data. * @return the samples for the specified band for the specified * region of pixels. * @see #setSamples(int, int, int, int, int, int[], DataBuffer) */ public int[] getSamples(int x, int y, int w, int h, int b, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int samples[]; if (iArray != null) { samples = iArray; } else { samples = new int[w * h]; } int lineOffset = y * scanlineStride + x; int dstOffset = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { int value = data.getElem(lineOffset + j); samples[dstOffset++] = ((value & bitMasks[b]) >>> bitOffsets[b]); } lineOffset += scanlineStride; } return samples; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.SinglePixelPackedSampleModel.setDataElements(int, int, Object, DataBuffer)
/** * Sets the data for a single pixel in the specified DataBuffer from a * primitive array of type TransferType. For a * SinglePixelPackedSampleModel, only the first element of the array * will hold valid data, and the type of the array must be the same as * the storage data type of the SinglePixelPackedSampleModel. * The following code illustrates transferring data for one pixel from * DataBuffer <code>db1</code>, whose storage layout is described by * SinglePixelPackedSampleModel <code>sppsm1</code>, * to DataBuffer <code>db2</code>, whose storage layout is described by * SinglePixelPackedSampleModel <code>sppsm2</code>. * The transfer will generally be more efficient than using * getPixel/setPixel. * SinglePixelPackedSampleModel sppsm1, sppsm2; * DataBufferInt db1, db2; * sppsm2.setDataElements(x, y, sppsm1.getDataElements(x, y, null, * db1), db2); * Using getDataElements/setDataElements to transfer between two * DataBuffer/SampleModel pairs is legitimate if the SampleModels have * the same number of bands, corresponding bands have the same number of * bits per sample, and the TransferTypes are the same. * obj must be a primitive array of type TransferType. Otherwise, * a ClassCastException is thrown. An * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds, or if obj is not large enough to hold the pixel data. * @param x The X coordinate of the pixel location. * @param y The Y coordinate of the pixel location. * @param obj A primitive array containing pixel data. * @param data The DataBuffer containing the image data. * @see #getDataElements(int, int, Object, DataBuffer) */ public void setDataElements(int x, int y, Object obj, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int type = getTransferType(); switch(type) { case DataBuffer.TYPE_BYTE: byte[] barray = (byte[]) obj; data.setElem(y * scanlineStride + x, ((int) barray[0]) & 0xff); break; case DataBuffer.TYPE_USHORT: short[] sarray = (short[]) obj; data.setElem(y * scanlineStride + x, ((int) sarray[0]) & 0xffff); break; case DataBuffer.TYPE_INT: int[] iarray = (int[]) obj; data.setElem(y * scanlineStride + x, iarray[0]); break; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.SinglePixelPackedSampleModel.setPixel(int, int, int, DataBuffer)
/** * Sets a pixel in the DataBuffer using an int array of samples for input. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x The X coordinate of the pixel location. * @param y The Y coordinate of the pixel location. * @param iArray The input samples in an int array. * @param data The DataBuffer containing the image data. * @see #getPixel(int, int, int[], DataBuffer) */ public void setPixel(int x, int y, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int lineOffset = y * scanlineStride + x; int value = data.getElem(lineOffset); for (int i = 0; i < numBands; i++) { value &= ~bitMasks[i]; value |= ((iArray[i] << bitOffsets[i]) & bitMasks[i]); } data.setElem(lineOffset, value); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.SinglePixelPackedSampleModel.setPixels(int, int, int, int, int, DataBuffer)
/** * Sets all samples for a rectangle of pixels from an int array containing * one sample per array element. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x The X coordinate of the upper left pixel location. * @param y The Y coordinate of the upper left pixel location. * @param w The width of the pixel rectangle. * @param h The height of the pixel rectangle. * @param iArray The input samples in an int array. * @param data The DataBuffer containing the image data. * @see #getPixels(int, int, int, int, int[], DataBuffer) */ public void setPixels(int x, int y, int w, int h, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int lineOffset = y * scanlineStride + x; int srcOffset = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { int value = data.getElem(lineOffset + j); for (int k = 0; k < numBands; k++) { value &= ~bitMasks[k]; int srcValue = iArray[srcOffset++]; value |= ((srcValue << bitOffsets[k]) & bitMasks[k]); } data.setElem(lineOffset + j, value); } lineOffset += scanlineStride; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.SinglePixelPackedSampleModel.setSample(int, int, int, int, DataBuffer)
/** * Sets a sample in the specified band for the pixel located at (x,y) * in the DataBuffer using an int for input. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x The X coordinate of the pixel location. * @param y The Y coordinate of the pixel location. * @param b The band to set. * @param s The input sample as an int. * @param data The DataBuffer containing the image data. * @see #getSample(int, int, int, DataBuffer) */ public void setSample(int x, int y, int b, int s, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int value = data.getElem(y * scanlineStride + x); value &= ~bitMasks[b]; value |= (s << bitOffsets[b]) & bitMasks[b]; data.setElem(y * scanlineStride + x, value); }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.SinglePixelPackedSampleModel.setSamples(int, int, int, int, int, int, DataBuffer)
/** * Sets the samples in the specified band for the specified rectangle * of pixels from an int array containing one sample per array element. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * @param x The X coordinate of the upper left pixel location. * @param y The Y coordinate of the upper left pixel location. * @param w The width of the pixel rectangle. * @param h The height of the pixel rectangle. * @param b The band to set. * @param iArray The input samples in an int array. * @param data The DataBuffer containing the image data. * @see #getSamples(int, int, int, int, int, int[], DataBuffer) */ public void setSamples(int x, int y, int w, int h, int b, int iArray[], DataBuffer data) { if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int lineOffset = y * scanlineStride + x; int srcOffset = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { int value = data.getElem(lineOffset + j); value &= ~bitMasks[b]; int sample = iArray[srcOffset++]; value |= ((int) sample << bitOffsets[b]) & bitMasks[b]; data.setElem(lineOffset + j, value); } lineOffset += scanlineStride; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.WritableRaster.setDataElements(int, int, Raster)
/** * Sets the data for a rectangle of pixels from an input Raster. * The input Raster must be compatible with this WritableRaster * in that they must have the same number of bands, corresponding bands * must have the same number of bits per sample, the TransferTypes * and NumDataElements must be the same, and the packing used by * the getDataElements/setDataElements must be identical. * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are * not in bounds. * However, explicit bounds checking is not guaranteed. * @param x The X coordinate of the pixel location. * @param y The Y coordinate of the pixel location. * @param inRaster Raster containing data to place at x,y. * @throws NullPointerException if inRaster is null. * @throws ArrayIndexOutOfBoundsException if the coordinates are not * in bounds. */ public void setDataElements(int x, int y, Raster inRaster) { int dstOffX = x + inRaster.getMinX(); int dstOffY = y + inRaster.getMinY(); int width = inRaster.getWidth(); int height = inRaster.getHeight(); if ((dstOffX < this.minX) || (dstOffY < this.minY) || (dstOffX + width > this.minX + this.width) || (dstOffY + height > this.minY + this.height)) { throw new ArrayIndexOutOfBoundsException('Coordinate out of bounds!'); } int srcOffX = inRaster.getMinX(); int srcOffY = inRaster.getMinY(); Object tdata = null; for (int startY = 0; startY < height; startY++) { tdata = inRaster.getDataElements(srcOffX, srcOffY + startY, width, 1, tdata); setDataElements(dstOffX, dstOffY + startY, width, 1, tdata); } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
org.xml.sax.ext.Attributes2Impl.isDeclared(int)
public boolean isDeclared(int index) { if (index < 0 || index >= getLength()) throw new ArrayIndexOutOfBoundsException('No attribute at index: ' + index); return declared[index]; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
org.xml.sax.ext.Attributes2Impl.isSpecified(int)
/** * Returns the current value of an attribute's 'specified' flag. * @param index The attribute index (zero-based). * @return current flag value * @exception java.lang.ArrayIndexOutOfBoundsException When the * supplied index does not identify an attribute. */ public boolean isSpecified(int index) { if (index < 0 || index >= getLength()) throw new ArrayIndexOutOfBoundsException('No attribute at index: ' + index); return specified[index]; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
org.xml.sax.ext.Attributes2Impl.setDeclared(int, boolean)
/** * Assign a value to the 'declared' flag of a specific attribute. * This is normally needed only for attributes of type CDATA, * including attributes whose type is changed to or from CDATA. * @param index The index of the attribute (zero-based). * @param value The desired flag value. * @exception java.lang.ArrayIndexOutOfBoundsException When the * supplied index does not identify an attribute. * @see #setType */ public void setDeclared(int index, boolean value) { if (index < 0 || index >= getLength()) throw new ArrayIndexOutOfBoundsException('No attribute at index: ' + index); declared[index] = value; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
org.xml.sax.ext.Attributes2Impl.setSpecified(int, boolean)
/** * Assign a value to the 'specified' flag of a specific attribute. * This is the only way this flag can be cleared, except clearing * by initialization with the copy constructor. * @param index The index of the attribute (zero-based). * @param value The desired flag value. * @exception java.lang.ArrayIndexOutOfBoundsException When the * supplied index does not identify an attribute. */ public void setSpecified(int index, boolean value) { if (index < 0 || index >= getLength()) throw new ArrayIndexOutOfBoundsException('No attribute at index: ' + index); specified[index] = value; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.Container.getComponent(int)
/** * Gets the nth component in this container. * @param n the index of the component to get. * @return the n<sup>th</sup> component in this container. * @exception ArrayIndexOutOfBoundsException * if the n<sup>th</sup> value does not exist. */ public Component getComponent(int n) { synchronized (getTreeLock()) { if ((n < 0) || (n >= ncomponents)) { throw new ArrayIndexOutOfBoundsException('No such child: ' + n); } return component[n]; } }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.Raster.createBandedRaster(int, int, int, int, Point)
/** * Creates a Raster based on a BandedSampleModel with the * specified data type, width, height, and number of bands. * The upper left corner of the Raster is given by the * location argument. If location is null, (0, 0) will be used. * The dataType parameter should be one of the enumerated values * defined in the DataBuffer class. * The only dataTypes supported currently are TYPE_BYTE, TYPE_USHORT, * and TYPE_INT. * @param dataType the data type for storing samples * @param w the width in pixels of the image data * @param h the height in pixels of the image data * @param bands the number of bands * @param location the upper-left corner of the <code>Raster</code> * @return a WritableRaster object with the specified data type, * width, height and number of bands. * @throws RasterFormatException if <code>w</code> or <code>h</code> * is less than or equal to zero, or computing either * <code>location.x + w</code> or * <code>location.y + h</code> results in integer * overflow * @throws ArrayIndexOutOfBoundsException if <code>bands</code> * is less than 1 */ public static WritableRaster createBandedRaster(int dataType, int w, int h, int bands, Point location) { if (bands < 1) { throw new ArrayIndexOutOfBoundsException('Number of bands (' + bands + ') must' + ' be greater than 0'); } int[] bankIndices = new int[bands]; int[] bandOffsets = new int[bands]; for (int i = 0; i < bands; i++) { bankIndices[i] = i; bandOffsets[i] = 0; } return createBandedRaster(dataType, w, h, w, bankIndices, bandOffsets, location); }
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.common.BogusColorSpace.toCIEXYZ(float[])
public float[] toCIEXYZ(float[] colorvalue) { if (colorvalue.length < getNumComponents()) { throw new ArrayIndexOutOfBoundsException('colorvalue.length < getNumComponents()'); } float[] xyzvalue = new float[3]; System.arraycopy(colorvalue, 0, xyzvalue, 0, Math.min(3, getNumComponents())); return colorvalue; }
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.common.BogusColorSpace.toRGB(float[])
public float[] toRGB(float[] colorvalue) { if (colorvalue.length < getNumComponents()) { throw new ArrayIndexOutOfBoundsException('colorvalue.length < getNumComponents()'); } float[] rgbvalue = new float[3]; System.arraycopy(colorvalue, 0, rgbvalue, 0, Math.min(3, getNumComponents())); return colorvalue; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
javax.swing.tree.DefaultMutableTreeNode.getChildAt(int)
/** * Returns the child at the specified index in this node's child array. * @param index an index into this node's child array * @exception ArrayIndexOutOfBoundsException if <code>index</code> * is out of bounds * @return the TreeNode in this node's child array at the specified index */ public TreeNode getChildAt(int index) { if (children == null) { throw new ArrayIndexOutOfBoundsException('node has no children'); } return (TreeNode) children.elementAt(index); }
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(int, long)
/** * Overwrites or appends a single byte to the cache. * The length of the cache will be extended as needed to hold * the incoming data. * @param b an <code>int</code> whose 8 least significant bits * will be written. * @param pos the cache position at which to begin writing. * @exception IndexOutOfBoundsException if <code>pos</code> is negative. */ public void write(int b, long pos) throws IOException { if (pos < 0) { throw new ArrayIndexOutOfBoundsException('pos < 0'); } if (pos >= length) { pad(pos); length = pos + 1; } byte[] buf = getCacheBlock(pos / BUFFER_LENGTH); int offset = (int) (pos % BUFFER_LENGTH); buf[offset] = (byte) b; }
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.common.BogusColorSpace.fromRGB(float[])
public float[] fromRGB(float[] rgbvalue) { if (rgbvalue.length < 3) { throw new ArrayIndexOutOfBoundsException('rgbvalue.length < 3'); } float[] colorvalue = new float[getNumComponents()]; System.arraycopy(rgbvalue, 0, colorvalue, 0, Math.min(3, colorvalue.length)); return rgbvalue; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ByteLookupTable.lookupPixel(byte[], byte[])
/** * Returns an array of samples of a pixel, translated with the lookup * table. The source and destination array can be the same array. * Array <code>dst</code> is returned. * @param src the source array. * @param dst the destination array. This array must be at least as * long as <code>src</code>. If <code>dst</code> is * <code>null</code>, a new array will be allocated having the * same length as <code>src</code>. * @return the array <code>dst</code>, an <code>int</code> array of * samples. * @exception ArrayIndexOutOfBoundsException if <code>src</code> is * longer than <code>dst</code> or if for any element * <code>i</code> of <code>src</code>, * <code>(src[i]&0xff)-offset</code> is either less than * zero or greater than or equal to the length of the * lookup table for any band. */ public byte[] lookupPixel(byte[] src, byte[] dst) { if (dst == null) { dst = new byte[src.length]; } if (numComponents == 1) { for (int i = 0; i < src.length; i++) { int s = (src[i] & 0xff) - offset; if (s < 0) { throw new ArrayIndexOutOfBoundsException('src[' + i + ']-offset is ' + 'less than zero'); } dst[i] = data[0][s]; } } else { for (int i = 0; i < src.length; i++) { int s = (src[i] & 0xff) - offset; if (s < 0) { throw new ArrayIndexOutOfBoundsException('src[' + i + ']-offset is ' + 'less than zero'); } dst[i] = data[i][s]; } } return dst; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ByteLookupTable.lookupPixel(int[], int[])
/** * Returns an array of samples of a pixel, translated with the lookup * table. The source and destination array can be the same array. * Array <code>dst</code> is returned. * @param src the source array. * @param dst the destination array. This array must be at least as * long as <code>src</code>. If <code>dst</code> is * <code>null</code>, a new array will be allocated having the * same length as <code>src</code>. * @return the array <code>dst</code>, an <code>int</code> array of * samples. * @exception ArrayIndexOutOfBoundsException if <code>src</code> is * longer than <code>dst</code> or if for any element * <code>i</code> of <code>src</code>, * <code>src[i]-offset</code> is either less than zero or * greater than or equal to the length of the lookup table * for any band. */ public int[] lookupPixel(int[] src, int[] dst) { if (dst == null) { dst = new int[src.length]; } if (numComponents == 1) { for (int i = 0; i < src.length; i++) { int s = src[i] - offset; if (s < 0) { throw new ArrayIndexOutOfBoundsException('src[' + i + ']-offset is ' + 'less than zero'); } dst[i] = (int) data[0][s]; } } else { for (int i = 0; i < src.length; i++) { int s = src[i] - offset; if (s < 0) { throw new ArrayIndexOutOfBoundsException('src[' + i + ']-offset is ' + 'less than zero'); } dst[i] = (int) data[i][s]; } } return dst; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ShortLookupTable.lookupPixel(int[], int[])
/** * Returns an array of samples of a pixel, translated with the lookup * table. The source and destination array can be the same array. * Array <code>dst</code> is returned. * @param src the source array. * @param dst the destination array. This array must be at least as * long as <code>src</code>. If <code>dst</code> is * <code>null</code>, a new array will be allocated having the * same length as <code>src</code>. * @return the array <code>dst</code>, an <code>int</code> array of * samples. * @exception ArrayIndexOutOfBoundsException if <code>src</code> is * longer than <code>dst</code> or if for any element * <code>i</code> of <code>src</code>, * <code>(src[i]&0xffff)-offset</code> is either less than * zero or greater than or equal to the length of the * lookup table for any band. */ public int[] lookupPixel(int[] src, int[] dst) { if (dst == null) { dst = new int[src.length]; } if (numComponents == 1) { for (int i = 0; i < src.length; i++) { int s = (src[i] & 0xffff) - offset; if (s < 0) { throw new ArrayIndexOutOfBoundsException('src[' + i + ']-offset is ' + 'less than zero'); } dst[i] = (int) data[0][s]; } } else { for (int i = 0; i < src.length; i++) { int s = (src[i] & 0xffff) - offset; if (s < 0) { throw new ArrayIndexOutOfBoundsException('src[' + i + ']-offset is ' + 'less than zero'); } dst[i] = (int) data[i][s]; } } return dst; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
java.awt.image.ShortLookupTable.lookupPixel(short[], short[])
/** * Returns an array of samples of a pixel, translated with the lookup * table. The source and destination array can be the same array. * Array <code>dst</code> is returned. * @param src the source array. * @param dst the destination array. This array must be at least as * long as <code>src</code>. If <code>dst</code> is * <code>null</code>, a new array will be allocated having the * same length as <code>src</code>. * @return the array <code>dst</code>, an <code>int</code> array of * samples. * @exception ArrayIndexOutOfBoundsException if <code>src</code> is * longer than <code>dst</code> or if for any element * <code>i</code> of <code>src</code>, * <code>(src[i]&0xffff)-offset</code> is either less than * zero or greater than or equal to the length of the * lookup table for any band. */ public short[] lookupPixel(short[] src, short[] dst) { if (dst == null) { dst = new short[src.length]; } if (numComponents == 1) { for (int i = 0; i < src.length; i++) { int s = (src[i] & 0xffff) - offset; if (s < 0) { throw new ArrayIndexOutOfBoundsException('src[' + i + ']-offset is ' + 'less than zero'); } dst[i] = data[0][s]; } } else { for (int i = 0; i < src.length; i++) { int s = (src[i] & 0xffff) - offset; if (s < 0) { throw new ArrayIndexOutOfBoundsException('src[' + i + ']-offset is ' + 'less than zero'); } dst[i] = data[i][s]; } } return dst; }
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.common.BogusColorSpace.fromCIEXYZ(float[])
public float[] fromCIEXYZ(float[] xyzvalue) { if (xyzvalue.length < 3) { throw new ArrayIndexOutOfBoundsException('xyzvalue.length < 3'); } float[] colorvalue = new float[getNumComponents()]; System.arraycopy(xyzvalue, 0, colorvalue, 0, Math.min(3, colorvalue.length)); return xyzvalue; }
Source: "Java SE Downloads: Java SE 6 JDK Source Code", at: http://www.oracle.com/technetwork/java/javase/downloads/index.html
Comments
Post a Comment