Lines 68-78
Link Here
|
68 |
char result[]=new char[BUFFER_SIZE]; |
68 |
char result[]=new char[BUFFER_SIZE]; |
69 |
|
69 |
|
70 |
/** Convert a buffer of bytes into a chars |
70 |
/** Convert a buffer of bytes into a chars |
|
|
71 |
* @deprecated |
71 |
*/ |
72 |
*/ |
72 |
public void convert( ByteChunk bb, CharChunk cb ) |
73 |
public void convert( ByteChunk bb, CharChunk cb ) |
73 |
throws IOException |
74 |
throws IOException |
74 |
{ |
75 |
{ |
75 |
convert(bb, cb, cb.getBuffer().length - cb.getEnd()); |
76 |
convert(bb, cb, cb.getLimit() - cb.getEnd()); |
76 |
} |
77 |
} |
77 |
|
78 |
|
78 |
/** Convert a buffer of bytes into a chars |
79 |
/** Convert a buffer of bytes into a chars |
Lines 90-96
Link Here
|
90 |
{ |
91 |
{ |
91 |
try { |
92 |
try { |
92 |
// read from the reader |
93 |
// read from the reader |
93 |
int count = 0; |
|
|
94 |
while( limit > 0 ) { |
94 |
while( limit > 0 ) { |
95 |
int size = limit < BUFFER_SIZE ? limit : BUFFER_SIZE; |
95 |
int size = limit < BUFFER_SIZE ? limit : BUFFER_SIZE; |
96 |
int cnt=conv.read( result, 0, size ); |
96 |
int cnt=conv.read( result, 0, size ); |
Lines 195-208
Link Here
|
195 |
*/ |
195 |
*/ |
196 |
final class ReadConvertor extends InputStreamReader { |
196 |
final class ReadConvertor extends InputStreamReader { |
197 |
|
197 |
|
198 |
// Has a private, internal byte[8192] |
198 |
private IntermediateInputStream iis; |
199 |
|
199 |
|
200 |
/** Create a converter. |
200 |
/** Create a converter. |
201 |
*/ |
201 |
*/ |
202 |
public ReadConvertor( IntermediateInputStream in, String enc ) |
202 |
public ReadConvertor( IntermediateInputStream in, String enc ) |
203 |
throws UnsupportedEncodingException |
203 |
throws UnsupportedEncodingException |
204 |
{ |
204 |
{ |
205 |
super( in, enc ); |
205 |
super( in, enc ); |
|
|
206 |
iis=in; |
206 |
} |
207 |
} |
207 |
|
208 |
|
208 |
/** Overriden - will do nothing but reset internal state. |
209 |
/** Overriden - will do nothing but reset internal state. |
Lines 219-227
Link Here
|
219 |
return super.read( cbuf, off, len ); |
220 |
return super.read( cbuf, off, len ); |
220 |
} |
221 |
} |
221 |
|
222 |
|
222 |
/** Reset the buffer |
223 |
/* |
|
|
224 |
* Reset the buffer |
223 |
*/ |
225 |
*/ |
224 |
public final void recycle() { |
226 |
public final void recycle() { |
|
|
227 |
iis.recycle(); |
228 |
try{ |
229 |
// Must clear super's buffer. |
230 |
while(ready()){ |
231 |
// InputStreamReader#skip(long) will allocate buffer to skip. |
232 |
read(); |
233 |
} |
234 |
}catch(IOException ioe){} |
225 |
} |
235 |
} |
226 |
} |
236 |
} |
227 |
|
237 |
|
Lines 244-264
Link Here
|
244 |
} |
254 |
} |
245 |
|
255 |
|
246 |
public final int read(byte cbuf[], int off, int len) throws IOException { |
256 |
public final int read(byte cbuf[], int off, int len) throws IOException { |
247 |
int nread = bc.substract(cbuf, off, len); |
257 |
if(bc == null){ |
248 |
return nread; |
258 |
return -1; |
|
|
259 |
} |
260 |
return bc.substract(cbuf, off, len); |
249 |
} |
261 |
} |
250 |
|
262 |
|
251 |
public final int read() throws IOException { |
263 |
public final int read() throws IOException { |
|
|
264 |
if(bc == null){ |
265 |
return -1; |
266 |
} |
252 |
return bc.substract(); |
267 |
return bc.substract(); |
253 |
} |
268 |
} |
254 |
|
269 |
|
255 |
public int available() throws IOException { |
270 |
public int available() throws IOException { |
|
|
271 |
if(bc == null){ |
272 |
return 0; |
273 |
} |
256 |
return bc.getLength(); |
274 |
return bc.getLength(); |
257 |
} |
275 |
} |
258 |
|
276 |
|
259 |
|
277 |
|
260 |
// -------------------- Internal methods -------------------- |
278 |
// -------------------- Internal methods -------------------- |
261 |
|
279 |
|
|
|
280 |
void recycle(){ |
281 |
bc = null; |
282 |
} |
262 |
|
283 |
|
263 |
void setByteChunk( ByteChunk mb ) { |
284 |
void setByteChunk( ByteChunk mb ) { |
264 |
bc = mb; |
285 |
bc = mb; |