36 |
exception statement from your version. */ |
exception statement from your version. */ |
37 |
|
|
38 |
package gnu.java.nio; |
package gnu.java.nio; |
39 |
import java.nio.*; |
|
40 |
public final class IntBufferImpl extends java.nio. IntBuffer |
import java.nio.IntBuffer; |
41 |
|
|
42 |
|
public final class IntBufferImpl extends IntBuffer |
43 |
{ |
{ |
44 |
private int array_offset; |
private int array_offset; |
45 |
private boolean ro; |
private boolean ro; |
46 |
|
|
47 |
public IntBufferImpl(int cap, int off, int lim) |
public IntBufferImpl(int cap, int off, int lim) |
48 |
{ |
{ |
49 |
this.backing_buffer = new int[cap]; |
this.backing_buffer = new int[cap]; |
50 |
this.cap = cap; |
this.cap = cap; |
51 |
this.position(off); |
this.position(off); |
52 |
this.limit(lim); |
this.limit(lim); |
53 |
} |
} |
54 |
|
|
55 |
public IntBufferImpl(int[] array, int off, int lim) |
public IntBufferImpl(int[] array, int off, int lim) |
56 |
{ |
{ |
57 |
this.backing_buffer = array; |
this.backing_buffer = array; |
58 |
this.cap = array.length; |
this.cap = array.length; |
59 |
this.position(off); |
this.position(off); |
60 |
this.limit(lim); |
this.limit(lim); |
61 |
} |
} |
62 |
|
|
63 |
public IntBufferImpl(IntBufferImpl copy) |
public IntBufferImpl(IntBufferImpl copy) |
64 |
{ |
{ |
65 |
backing_buffer = copy.backing_buffer; |
backing_buffer = copy.backing_buffer; |
66 |
ro = copy.ro; |
ro = copy.ro; |
67 |
position(copy.position()); |
position(copy.position()); |
68 |
limit(copy.limit()); |
limit(copy.limit()); |
69 |
} |
} |
70 |
void inc_pos(int a) |
|
71 |
{ |
void inc_pos(int a) |
72 |
position(position() + a); |
{ |
73 |
} |
position(position() + a); |
74 |
|
} |
75 |
|
|
76 |
private static native int[] nio_cast(byte[]copy); |
private static native int[] nio_cast(byte[]copy); |
77 |
private static native int[] nio_cast(char[]copy); |
private static native int[] nio_cast(char[]copy); |
78 |
private static native int[] nio_cast(short[]copy); |
private static native int[] nio_cast(short[]copy); |
80 |
private static native int[] nio_cast(int[]copy); |
private static native int[] nio_cast(int[]copy); |
81 |
private static native int[] nio_cast(float[]copy); |
private static native int[] nio_cast(float[]copy); |
82 |
private static native int[] nio_cast(double[]copy); |
private static native int[] nio_cast(double[]copy); |
83 |
|
|
84 |
IntBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(IntBufferImpl b, int index, int limit); private static native void nio_put_Byte(IntBufferImpl b, int index, int limit, byte value); public java.nio. ByteBuffer asByteBuffer() { gnu.java.nio. ByteBufferImpl res = new gnu.java.nio. ByteBufferImpl(backing_buffer); res.limit((limit()*1)/4); return res; } |
IntBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(IntBufferImpl b, int index, int limit); private static native void nio_put_Byte(IntBufferImpl b, int index, int limit, byte value); public java.nio. ByteBuffer asByteBuffer() { gnu.java.nio. ByteBufferImpl res = new gnu.java.nio. ByteBufferImpl(backing_buffer); res.limit((limit()*1)/4); return res; } |
85 |
IntBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(IntBufferImpl b, int index, int limit); private static native void nio_put_Char(IntBufferImpl b, int index, int limit, char value); public java.nio. CharBuffer asCharBuffer() { gnu.java.nio. CharBufferImpl res = new gnu.java.nio. CharBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; } |
IntBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(IntBufferImpl b, int index, int limit); private static native void nio_put_Char(IntBufferImpl b, int index, int limit, char value); public java.nio. CharBuffer asCharBuffer() { gnu.java.nio. CharBufferImpl res = new gnu.java.nio. CharBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; } |
86 |
IntBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(IntBufferImpl b, int index, int limit); private static native void nio_put_Short(IntBufferImpl b, int index, int limit, short value); public java.nio. ShortBuffer asShortBuffer() { gnu.java.nio. ShortBufferImpl res = new gnu.java.nio. ShortBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; } |
IntBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(IntBufferImpl b, int index, int limit); private static native void nio_put_Short(IntBufferImpl b, int index, int limit, short value); public java.nio. ShortBuffer asShortBuffer() { gnu.java.nio. ShortBufferImpl res = new gnu.java.nio. ShortBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; } |
88 |
IntBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(IntBufferImpl b, int index, int limit); private static native void nio_put_Long(IntBufferImpl b, int index, int limit, long value); public java.nio. LongBuffer asLongBuffer() { gnu.java.nio. LongBufferImpl res = new gnu.java.nio. LongBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; } |
IntBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(IntBufferImpl b, int index, int limit); private static native void nio_put_Long(IntBufferImpl b, int index, int limit, long value); public java.nio. LongBuffer asLongBuffer() { gnu.java.nio. LongBufferImpl res = new gnu.java.nio. LongBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; } |
89 |
IntBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(IntBufferImpl b, int index, int limit); private static native void nio_put_Float(IntBufferImpl b, int index, int limit, float value); public java.nio. FloatBuffer asFloatBuffer() { gnu.java.nio. FloatBufferImpl res = new gnu.java.nio. FloatBufferImpl(backing_buffer); res.limit((limit()*4)/4); return res; } |
IntBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(IntBufferImpl b, int index, int limit); private static native void nio_put_Float(IntBufferImpl b, int index, int limit, float value); public java.nio. FloatBuffer asFloatBuffer() { gnu.java.nio. FloatBufferImpl res = new gnu.java.nio. FloatBufferImpl(backing_buffer); res.limit((limit()*4)/4); return res; } |
90 |
IntBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(IntBufferImpl b, int index, int limit); private static native void nio_put_Double(IntBufferImpl b, int index, int limit, double value); public java.nio. DoubleBuffer asDoubleBuffer() { gnu.java.nio. DoubleBufferImpl res = new gnu.java.nio. DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; } |
IntBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(IntBufferImpl b, int index, int limit); private static native void nio_put_Double(IntBufferImpl b, int index, int limit, double value); public java.nio. DoubleBuffer asDoubleBuffer() { gnu.java.nio. DoubleBufferImpl res = new gnu.java.nio. DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; } |
91 |
public boolean isReadOnly() |
|
92 |
{ |
public boolean isReadOnly() |
93 |
return ro; |
{ |
94 |
} |
return ro; |
95 |
public java.nio. IntBuffer slice() |
} |
96 |
{ |
|
97 |
IntBufferImpl A = new IntBufferImpl(this); |
public java.nio. IntBuffer slice() |
98 |
A.array_offset = position(); |
{ |
99 |
return A; |
IntBufferImpl A = new IntBufferImpl(this); |
100 |
} |
A.array_offset = position(); |
101 |
public java.nio. IntBuffer duplicate() |
return A; |
102 |
{ |
} |
103 |
return new IntBufferImpl(this); |
|
104 |
} |
public java.nio. IntBuffer duplicate() |
105 |
public java.nio. IntBuffer asReadOnlyBuffer() |
{ |
106 |
{ |
return new IntBufferImpl(this); |
107 |
IntBufferImpl a = new IntBufferImpl(this); |
} |
108 |
a.ro = true; |
|
109 |
return a; |
public java.nio. IntBuffer asReadOnlyBuffer() |
110 |
} |
{ |
111 |
public java.nio. IntBuffer compact() |
IntBufferImpl a = new IntBufferImpl(this); |
112 |
{ |
a.ro = true; |
113 |
return this; |
return a; |
114 |
} |
} |
115 |
public boolean isDirect() |
|
116 |
{ |
public java.nio. IntBuffer compact() |
117 |
return backing_buffer != null; |
{ |
118 |
} |
return this; |
119 |
|
} |
120 |
|
|
121 |
|
public boolean isDirect() |
122 |
|
{ |
123 |
|
return backing_buffer != null; |
124 |
|
} |
125 |
|
|
126 |
final public int get() |
final public int get() |
127 |
{ |
{ |
128 |
int e = backing_buffer[position()]; |
int e = backing_buffer[position()]; |
129 |
position(position()+1); |
position(position()+1); |
130 |
return e; |
return e; |
131 |
} |
} |
132 |
|
|
133 |
final public java.nio. IntBuffer put(int b) |
final public java.nio. IntBuffer put(int b) |
134 |
{ |
{ |
135 |
backing_buffer[position()] = b; |
backing_buffer[position()] = b; |
136 |
position(position()+1); |
position(position()+1); |
137 |
return this; |
return this; |
138 |
} |
} |
139 |
|
|
140 |
final public int get(int index) |
final public int get(int index) |
141 |
{ |
{ |
142 |
return backing_buffer[index]; |
return backing_buffer[index]; |
143 |
} |
} |
144 |
final public java.nio. IntBuffer put(int index, int b) |
|
145 |
{ |
final public java.nio. IntBuffer put(int index, int b) |
146 |
backing_buffer[index] = b; |
{ |
147 |
return this; |
backing_buffer[index] = b; |
148 |
} |
return this; |
149 |
|
} |
150 |
|
|
151 |
final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public java.nio. IntBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public java.nio. IntBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; }; |
final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public java.nio. IntBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public java.nio. IntBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; }; |
152 |
final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public java.nio. IntBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public java.nio. IntBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; }; |
final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public java.nio. IntBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public java.nio. IntBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; }; |
153 |
final public int getInt() { return get(); } final public java.nio. IntBuffer putInt(int value) { return put(value); } final public int getInt(int index) { return get(index); } final public java.nio. IntBuffer putInt(int index, int value) { return put(index, value); }; |
final public int getInt() { return get(); } final public java.nio. IntBuffer putInt(int value) { return put(value); } final public int getInt(int index) { return get(index); } final public java.nio. IntBuffer putInt(int index, int value) { return put(index, value); }; |