KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > nio > HeapByteBufferR


1 /*
2  * @(#)Heap-X-Buffer.java 1.28 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 // -- This file was mechanically generated: Do not edit! -- //
9

10 package java.nio;
11
12
13 /**
14
15
16
17  * A read-only HeapByteBuffer. This class extends the corresponding
18  * read/write class, overriding the mutation methods to throw a {@link
19  * ReadOnlyBufferException} and overriding the view-buffer methods to return an
20  * instance of this class rather than of the superclass.
21
22  */

23
24 class HeapByteBufferR
25     extends HeapByteBuffer JavaDoc
26 {
27
28     // For speed these fields are actually declared in X-Buffer;
29
// these declarations are here as documentation
30
/*
31
32
33
34
35     */

36
37     HeapByteBufferR(int cap, int lim) { // package-private
38

39
40
41
42
43
44
45     super(cap, lim);
46     this.isReadOnly = true;
47
48     }
49
50     HeapByteBufferR(byte[] buf, int off, int len) { // package-private
51

52
53
54
55
56
57
58     super(buf, off, len);
59     this.isReadOnly = true;
60
61     }
62
63     protected HeapByteBufferR(byte[] buf,
64                    int mark, int pos, int lim, int cap,
65                    int off)
66     {
67
68
69
70
71
72
73
74     super(buf, mark, pos, lim, cap, off);
75     this.isReadOnly = true;
76
77     }
78
79     public ByteBuffer JavaDoc slice() {
80     return new HeapByteBufferR JavaDoc(hb,
81                     -1,
82                     0,
83                     this.remaining(),
84                     this.remaining(),
85                     this.position() + offset);
86     }
87
88     public ByteBuffer JavaDoc duplicate() {
89     return new HeapByteBufferR JavaDoc(hb,
90                     this.markValue(),
91                     this.position(),
92                     this.limit(),
93                     this.capacity(),
94                     offset);
95     }
96
97     public ByteBuffer JavaDoc asReadOnlyBuffer() {
98
99
100
101
102
103
104
105
106     return duplicate();
107
108     }
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139     public boolean isReadOnly() {
140     return true;
141     }
142
143     public ByteBuffer JavaDoc put(byte x) {
144
145
146
147
148     throw new ReadOnlyBufferException JavaDoc();
149
150     }
151
152     public ByteBuffer JavaDoc put(int i, byte x) {
153
154
155
156
157     throw new ReadOnlyBufferException JavaDoc();
158
159     }
160
161     public ByteBuffer JavaDoc put(byte[] src, int offset, int length) {
162
163
164
165
166
167
168
169
170     throw new ReadOnlyBufferException JavaDoc();
171
172     }
173
174     public ByteBuffer JavaDoc put(ByteBuffer JavaDoc src) {
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198     throw new ReadOnlyBufferException JavaDoc();
199
200     }
201
202     public ByteBuffer JavaDoc compact() {
203
204
205
206
207
208
209     throw new ReadOnlyBufferException JavaDoc();
210
211     }
212
213
214
215
216
217     byte _get(int i) { // package-private
218
return hb[i];
219     }
220
221     void _put(int i, byte b) { // package-private
222

223
224
225     throw new ReadOnlyBufferException JavaDoc();
226
227     }
228
229     // char
230

231
232
233
234
235
236
237
238
239
240
241
242
243     public ByteBuffer JavaDoc putChar(char x) {
244
245
246
247
248     throw new ReadOnlyBufferException JavaDoc();
249
250     }
251
252     public ByteBuffer JavaDoc putChar(int i, char x) {
253
254
255
256
257     throw new ReadOnlyBufferException JavaDoc();
258
259     }
260
261     public CharBuffer JavaDoc asCharBuffer() {
262     int size = this.remaining() >> 1;
263     int off = offset + position();
264     return (bigEndian
265         ? (CharBuffer JavaDoc)(new ByteBufferAsCharBufferRB JavaDoc(this,
266                                    -1,
267                                    0,
268                                    size,
269                                    size,
270                                    off))
271         : (CharBuffer JavaDoc)(new ByteBufferAsCharBufferRL JavaDoc(this,
272                                    -1,
273                                    0,
274                                    size,
275                                    size,
276                                    off)));
277     }
278
279
280     // short
281

282
283
284
285
286
287
288
289
290
291
292
293
294     public ByteBuffer JavaDoc putShort(short x) {
295
296
297
298
299     throw new ReadOnlyBufferException JavaDoc();
300
301     }
302
303     public ByteBuffer JavaDoc putShort(int i, short x) {
304
305
306
307
308     throw new ReadOnlyBufferException JavaDoc();
309
310     }
311
312     public ShortBuffer JavaDoc asShortBuffer() {
313     int size = this.remaining() >> 1;
314     int off = offset + position();
315     return (bigEndian
316         ? (ShortBuffer JavaDoc)(new ByteBufferAsShortBufferRB JavaDoc(this,
317                                  -1,
318                                  0,
319                                  size,
320                                  size,
321                                  off))
322         : (ShortBuffer JavaDoc)(new ByteBufferAsShortBufferRL JavaDoc(this,
323                                  -1,
324                                  0,
325                                  size,
326                                  size,
327                                  off)));
328     }
329
330
331     // int
332

333
334
335
336
337
338
339
340
341
342
343
344
345     public ByteBuffer JavaDoc putInt(int x) {
346
347
348
349
350     throw new ReadOnlyBufferException JavaDoc();
351
352     }
353
354     public ByteBuffer JavaDoc putInt(int i, int x) {
355
356
357
358
359     throw new ReadOnlyBufferException JavaDoc();
360
361     }
362
363     public IntBuffer JavaDoc asIntBuffer() {
364     int size = this.remaining() >> 2;
365     int off = offset + position();
366     return (bigEndian
367         ? (IntBuffer JavaDoc)(new ByteBufferAsIntBufferRB JavaDoc(this,
368                                  -1,
369                                  0,
370                                  size,
371                                  size,
372                                  off))
373         : (IntBuffer JavaDoc)(new ByteBufferAsIntBufferRL JavaDoc(this,
374                                  -1,
375                                  0,
376                                  size,
377                                  size,
378                                  off)));
379     }
380
381
382     // long
383

384
385
386
387
388
389
390
391
392
393
394
395
396     public ByteBuffer JavaDoc putLong(long x) {
397
398
399
400
401     throw new ReadOnlyBufferException JavaDoc();
402
403     }
404
405     public ByteBuffer JavaDoc putLong(int i, long x) {
406
407
408
409
410     throw new ReadOnlyBufferException JavaDoc();
411
412     }
413
414     public LongBuffer JavaDoc asLongBuffer() {
415     int size = this.remaining() >> 3;
416     int off = offset + position();
417     return (bigEndian
418         ? (LongBuffer JavaDoc)(new ByteBufferAsLongBufferRB JavaDoc(this,
419                                    -1,
420                                    0,
421                                    size,
422                                    size,
423                                    off))
424         : (LongBuffer JavaDoc)(new ByteBufferAsLongBufferRL JavaDoc(this,
425                                    -1,
426                                    0,
427                                    size,
428                                    size,
429                                    off)));
430     }
431
432
433     // float
434

435
436
437
438
439
440
441
442
443
444
445
446
447     public ByteBuffer JavaDoc putFloat(float x) {
448
449
450
451
452     throw new ReadOnlyBufferException JavaDoc();
453
454     }
455
456     public ByteBuffer JavaDoc putFloat(int i, float x) {
457
458
459
460
461     throw new ReadOnlyBufferException JavaDoc();
462
463     }
464
465     public FloatBuffer JavaDoc asFloatBuffer() {
466     int size = this.remaining() >> 2;
467     int off = offset + position();
468     return (bigEndian
469         ? (FloatBuffer JavaDoc)(new ByteBufferAsFloatBufferRB JavaDoc(this,
470                                  -1,
471                                  0,
472                                  size,
473                                  size,
474                                  off))
475         : (FloatBuffer JavaDoc)(new ByteBufferAsFloatBufferRL JavaDoc(this,
476                                  -1,
477                                  0,
478                                  size,
479                                  size,
480                                  off)));
481     }
482
483
484     // double
485

486
487
488
489
490
491
492
493
494
495
496
497
498     public ByteBuffer JavaDoc putDouble(double x) {
499
500
501
502
503     throw new ReadOnlyBufferException JavaDoc();
504
505     }
506
507     public ByteBuffer JavaDoc putDouble(int i, double x) {
508
509
510
511
512     throw new ReadOnlyBufferException JavaDoc();
513
514     }
515
516     public DoubleBuffer JavaDoc asDoubleBuffer() {
517     int size = this.remaining() >> 3;
518     int off = offset + position();
519     return (bigEndian
520         ? (DoubleBuffer JavaDoc)(new ByteBufferAsDoubleBufferRB JavaDoc(this,
521                                    -1,
522                                    0,
523                                    size,
524                                    size,
525                                    off))
526         : (DoubleBuffer JavaDoc)(new ByteBufferAsDoubleBufferRL JavaDoc(this,
527                                    -1,
528                                    0,
529                                    size,
530                                    size,
531                                    off)));
532     }
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573 }
574
Popular Tags