KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > bytes > TCByteBuffer


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.bytes;
5
6 import com.tc.lang.Recyclable;
7
8
9 /**
10  * @author teck TODO: document me!
11  */

12 public interface TCByteBuffer extends Recyclable {
13
14   ////////////////////
15
// java.nio.Buffer methods
16
////////////////////
17
int capacity();
18
19   TCByteBuffer clear();
20
21   TCByteBuffer flip();
22
23   boolean hasRemaining();
24
25   boolean isReadOnly();
26
27   int limit();
28
29   TCByteBuffer limit(int newLimit);
30
31   // Buffer mark()
32
int position();
33
34   TCByteBuffer position(int newPosition);
35
36   int remaining();
37
38   // Buffer reset()
39
TCByteBuffer rewind();
40
41   ////////////////////
42
// java.nio.ByteBuffer methods
43
////////////////////
44
TCByteBuffer asReadOnlyBuffer();
45
46   boolean isDirect();
47
48   byte[] array();
49
50   int arrayOffset();
51
52   byte get();
53
54   TCByteBuffer get(byte[] dst);
55
56   TCByteBuffer get(byte[] dst, int offset, int length);
57
58   byte get(int index);
59
60   boolean getBoolean();
61
62   boolean getBoolean(int index);
63
64   char getChar();
65
66   char getChar(int index);
67
68   double getDouble();
69
70   double getDouble(int index);
71
72   float getFloat();
73
74   float getFloat(int index);
75
76   int getInt();
77
78   int getInt(int index);
79
80   long getLong();
81
82   long getLong(int index);
83
84   short getShort();
85
86   short getShort(int index);
87
88   TCByteBuffer put(byte[] src);
89
90   TCByteBuffer put(byte[] src, int offset, int length);
91
92   TCByteBuffer put(TCByteBuffer src);
93
94   TCByteBuffer put(byte b);
95
96   TCByteBuffer put(int index, byte b);
97
98   TCByteBuffer putBoolean(boolean b);
99
100   TCByteBuffer putBoolean(int index, boolean b);
101
102   TCByteBuffer putChar(char c);
103
104   TCByteBuffer putChar(int index, char c);
105
106   TCByteBuffer putFloat(float f);
107
108   TCByteBuffer putFloat(int index, float f);
109
110   TCByteBuffer putDouble(double d);
111
112   TCByteBuffer putDouble(int index, double d);
113
114   TCByteBuffer putInt(int i);
115
116   TCByteBuffer putInt(int index, int i);
117
118   TCByteBuffer putLong(long l);
119
120   TCByteBuffer putLong(int index, long l);
121
122   TCByteBuffer putShort(short s);
123
124   TCByteBuffer putShort(int index, short s);
125
126   TCByteBuffer duplicate();
127
128   TCByteBuffer slice();
129
130   boolean hasArray();
131
132   ////////////////////
133
// TC methods
134
////////////////////
135

136   // access to the underlying JDK14 java.nio.ByteBuffer (if available)
137
boolean isNioBuffer();
138
139   Object JavaDoc getNioBuffer(); // return Object on purpose. Client code must cast return value
140

141   // absolute bulk get/put methods. It seems like these methods are missing from the java.nio.ByteBuffer interface
142
TCByteBuffer get(int index, byte[] dst);
143
144   TCByteBuffer get(int index, byte[] dst, int offset, int length);
145
146   TCByteBuffer put(int index, byte[] src);
147
148   TCByteBuffer put(int index, byte[] src, int offset, int length);
149
150   // write unsigned 4 and 2 byte integer values into byte buffers
151
TCByteBuffer putUint(long i);
152
153   TCByteBuffer putUint(int index, long i);
154
155   TCByteBuffer putUshort(int s);
156
157   TCByteBuffer putUshort(int index, int s);
158
159   // get and put unsigned byte values
160
short getUbyte();
161
162   short getUbyte(int index);
163
164   TCByteBuffer putUbyte(short value);
165
166   TCByteBuffer putUbyte(int index, short value);
167
168   // get unsigned 4 and 2 byte unsigned integer values from byte buffers
169
long getUint();
170
171   long getUint(int index);
172
173   int getUshort();
174
175   int getUshort(int index);
176
177   // XXX: add some zeroOut() methods to write byte 0 into ranges of this buffer
178
}
Popular Tags