KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > nio > ByteBufferAsCharBufferRL


1 /*
2  * @(#)ByteBufferAs-X-Buffer.java 1.17 04/05/03
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 class ByteBufferAsCharBufferRL // package-private
14
extends ByteBufferAsCharBufferL JavaDoc
15 {
16
17
18
19
20
21
22
23
24     ByteBufferAsCharBufferRL(ByteBuffer JavaDoc bb) { // package-private
25

26
27
28
29
30
31
32
33
34
35
36
37     super(bb);
38
39     }
40
41     ByteBufferAsCharBufferRL(ByteBuffer JavaDoc bb,
42                      int mark, int pos, int lim, int cap,
43                      int off)
44     {
45
46
47
48
49
50     super(bb, mark, pos, lim, cap, off);
51
52     }
53
54     public CharBuffer JavaDoc slice() {
55     int pos = this.position();
56     int lim = this.limit();
57     assert (pos <= lim);
58     int rem = (pos <= lim ? lim - pos : 0);
59     int off = (pos << 1) + offset;
60         assert (off >= 0);
61     return new ByteBufferAsCharBufferRL JavaDoc(bb, -1, 0, rem, rem, off);
62     }
63
64     public CharBuffer JavaDoc duplicate() {
65     return new ByteBufferAsCharBufferRL JavaDoc(bb,
66                             this.markValue(),
67                             this.position(),
68                             this.limit(),
69                             this.capacity(),
70                             offset);
71     }
72
73     public CharBuffer JavaDoc asReadOnlyBuffer() {
74
75
76
77
78
79
80
81
82     return duplicate();
83
84     }
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102     public CharBuffer JavaDoc put(char x) {
103
104
105
106
107     throw new ReadOnlyBufferException JavaDoc();
108
109     }
110
111     public CharBuffer JavaDoc put(int i, char x) {
112
113
114
115
116     throw new ReadOnlyBufferException JavaDoc();
117
118     }
119
120     public CharBuffer JavaDoc compact() {
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137     throw new ReadOnlyBufferException JavaDoc();
138
139     }
140
141     public boolean isDirect() {
142     return bb.isDirect();
143     }
144
145     public boolean isReadOnly() {
146     return true;
147     }
148
149
150
151     public String JavaDoc toString(int start, int end) {
152     if ((end > limit()) || (start > end))
153         throw new IndexOutOfBoundsException JavaDoc();
154     try {
155         int len = end - start;
156         char[] ca = new char[len];
157         CharBuffer JavaDoc cb = CharBuffer.wrap(ca);
158         CharBuffer JavaDoc db = this.duplicate();
159         db.position(start);
160         db.limit(end);
161         cb.put(db);
162         return new String JavaDoc(ca);
163     } catch (StringIndexOutOfBoundsException JavaDoc x) {
164         throw new IndexOutOfBoundsException JavaDoc();
165     }
166     }
167
168
169     // --- Methods to support CharSequence ---
170

171     public CharSequence JavaDoc subSequence(int start, int end) {
172     int pos = position();
173     int lim = limit();
174     assert (pos <= lim);
175     pos = (pos <= lim ? pos : lim);
176     int len = lim - pos;
177
178     if ((start < 0) || (end > len) || (start > end))
179         throw new IndexOutOfBoundsException JavaDoc();
180     int sublen = end - start;
181     int off = offset + ((pos + start) << 1);
182         assert (off >= 0);
183     return new ByteBufferAsCharBufferRL JavaDoc(bb, -1, 0, sublen, sublen, off);
184     }
185
186
187
188
189     public ByteOrder JavaDoc order() {
190
191
192
193
194     return ByteOrder.LITTLE_ENDIAN;
195
196     }
197
198 }
199
Popular Tags