1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
262 * @param size the size of the banks
263 * @param numBanks the number of banks in this
264 * <code>DataBuffer</code>
265 * @param offsets an array containing an offset for each bank.
266 * @throws ArrayIndexOutOfBoundsException if <code>numBanks</code>
267 * does not equal the length of <code>offsets</code>
268 * @since 1.7
269 */
270 DataBuffer(State initialState,
271 int dataType, int size, int numBanks, int offsets[])
272 {
273 if (numBanks != offsets.length) {
274 throw new ArrayIndexOutOfBoundsException("Number of banks" +
275 " does not match number of bank offsets");
276 }
277 this.theTrackable = StateTrackableDelegate.createInstance(initialState);
278 this.dataType = dataType;
279 this.banks = numBanks;
280 this.size = size;
281 this.offset = offsets[0];
282 this.offsets = (int[])offsets.clone();
283 }
284
285 /** Returns the data type of this DataBuffer.
286 * @return the data type of this <code>DataBuffer</code>.
287 */
288 public int getDataType() {
289 return dataType;
290 }
291
292 /** Returns the size (in array elements) of all banks.
293 * @return the size of all banks.
294 */
295 public int getSize() {
296 return size;
297 }
298
299 /** Returns the offset of the default bank in array elements.
300 * @return the offset of the default bank.
301 */
302 public int getOffset() {
303 return offset;
304 }
305
306 /** Returns the offsets (in array elements) of all the banks.
307 * @return the offsets of all banks.
308 */
309 public int[] getOffsets() {
310 return (int[])offsets.clone();
311 }
312
313 /** Returns the number of banks in this DataBuffer.
314 * @return the number of banks.
315 */
316 public int getNumBanks() {
317 return banks;
318 }
319
320 /**
321 * Returns the requested data array element from the first (default) bank
322 * as an integer.
323 * @param i the index of the requested data array element
324 * @return the data array element at the specified index.
325 * @see #setElem(int, int)
326 * @see #setElem(int, int, int)
327 */
328 public int getElem(int i) {
329 return getElem(0,i);
330 }
|
1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
262 * @param size the size of the banks
263 * @param numBanks the number of banks in this
264 * <code>DataBuffer</code>
265 * @param offsets an array containing an offset for each bank.
266 * @throws ArrayIndexOutOfBoundsException if <code>numBanks</code>
267 * does not equal the length of <code>offsets</code>
268 * @since 1.7
269 */
270 DataBuffer(State initialState,
271 int dataType, int size, int numBanks, int offsets[])
272 {
273 if (numBanks != offsets.length) {
274 throw new ArrayIndexOutOfBoundsException("Number of banks" +
275 " does not match number of bank offsets");
276 }
277 this.theTrackable = StateTrackableDelegate.createInstance(initialState);
278 this.dataType = dataType;
279 this.banks = numBanks;
280 this.size = size;
281 this.offset = offsets[0];
282 this.offsets = offsets.clone();
283 }
284
285 /** Returns the data type of this DataBuffer.
286 * @return the data type of this <code>DataBuffer</code>.
287 */
288 public int getDataType() {
289 return dataType;
290 }
291
292 /** Returns the size (in array elements) of all banks.
293 * @return the size of all banks.
294 */
295 public int getSize() {
296 return size;
297 }
298
299 /** Returns the offset of the default bank in array elements.
300 * @return the offset of the default bank.
301 */
302 public int getOffset() {
303 return offset;
304 }
305
306 /** Returns the offsets (in array elements) of all the banks.
307 * @return the offsets of all banks.
308 */
309 public int[] getOffsets() {
310 return offsets.clone();
311 }
312
313 /** Returns the number of banks in this DataBuffer.
314 * @return the number of banks.
315 */
316 public int getNumBanks() {
317 return banks;
318 }
319
320 /**
321 * Returns the requested data array element from the first (default) bank
322 * as an integer.
323 * @param i the index of the requested data array element
324 * @return the data array element at the specified index.
325 * @see #setElem(int, int)
326 * @see #setElem(int, int, int)
327 */
328 public int getElem(int i) {
329 return getElem(0,i);
330 }
|