01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Sergey V. Kuksenko
19: * @version $Revision$
20: */package org.apache.harmony.awt.nativebridge;
21:
22: public class Int64Pointer extends VoidPointer {
23:
24: private static final int INT64_SIZE_FACTOR = 8;
25:
26: Int64Pointer(int size, boolean direct) {
27: super (size * INT64_SIZE_FACTOR, direct);
28: }
29:
30: Int64Pointer(VoidPointer p) {
31: super (p);
32: }
33:
34: Int64Pointer(long addr) {
35: super (addr);
36: }
37:
38: Int64Pointer(ByteBase base) {
39: super (base);
40: }
41:
42: /** returns the number of elements in array referenced by this object. If size is unknown returns -1. */
43: @Override
44: public int size() {
45: return byteBase.size() / INT64_SIZE_FACTOR;
46: }
47:
48: /** returns the element at the specified position. */
49: public long get(int index) {
50: return byteBase.getInt64(index * INT64_SIZE_FACTOR);
51: }
52:
53: /** sets the element at the specified position. */
54: public void set(int index, long value) {
55: byteBase.setInt64(index * INT64_SIZE_FACTOR, value);
56: }
57:
58: /**
59: * This method transfers long values into the given destination array.
60: *
61: * @param dst - The array into which values are to be written
62: * @param offset - The offset within the array of the first element to be written;
63: * must be non-negative and no larger than dst.length
64: * @param length - The maximum number of elements to be written to the given array;
65: * must be non-negative and no larger than dst.length - offset
66: */
67: public void get(long[] dst, int offset, int length) {
68: byteBase.getInt64(dst, offset, length);
69: }
70:
71: /**
72: * This method transfers long values from the given destination array.
73: *
74: * @param src - The array from which values are to be read
75: * @param offset - The offset within the array of the first element to be read;
76: * must be non-negative and no larger than dst.length
77: * @param length - The maximum number of elements to be read from the given array;
78: * must be non-negative and no larger than dst.length - offset
79: */
80: public void set(long[] src, int offset, int length) {
81: byteBase.setInt64(src, offset, length);
82: }
83:
84: /**
85: * returns class that represents the pointer to specified index.
86: */
87: public Int64Pointer getElementPointer(int index) {
88: return new Int64Pointer(byteBase.getBytesBaseElementPointer(
89: index * INT64_SIZE_FACTOR, INT64_SIZE_FACTOR));
90: }
91:
92: public void fill(long value, int size) {
93: int this Size = size();
94: for (int i = 0; i < size && i < thisSize; i++) {
95: byteBase.setInt64(i * INT64_SIZE_FACTOR, value);
96: }
97: }
98: }
|