[cp-patches] FYI: InputStreamReader/OutputStreamWriter -- another try

Roman Kennke roman.kennke at aicas.com
Tue Mar 27 09:54:43 UTC 2007


Last time my commit has been 'rolled back' by  the HD breakage and
subsequent backup-rollback. Let's try again.

2007-03-27  Roman Kennke  <roman at kennke.org>

	* java/io/InputStreamReader.java
	(BUFFER_SIZE): New constant.
	(bytesCache): Removed.
	(cacheLock): Removed.
	(hasSavedSurrogate): Removed.
	(lastArray): New field. Used for caching CharBuffers.
	(lastBuffer): New field. Used for caching CharBuffers.
	(maxBytesPerChar): Removed.
	(oneChar): New field. Caches a char array for read().
	(savedSurrogate): New field.
	(InputStreamReader): (all constructors) Cleaned up.
	Use initDecoderAndBuffer() method. Check for null parameters.
	Use new EncodingHelper.getDefaultCharset() for fetching the
	default charset.
	(decode): New helper method. Decodes using the NIO decoder or
	using a raw Latin1 decoding.
	(getCharBuffer): New helper method. Implements caching of
	CharBuffers for output arrays.
	(initDecoderAndBuffer): New helper method. Initializes the decoder
	and input buffer.
	(read): Use cached array.
	(read(char[],int,int)): Reworked using a cleaner NIO based
	implementation. This decodes the incoming data in bigger chunks
	rather then calling the decoder for each character.
	(ready): Also check the input buffer.
	(refillInputBuffer): New helper methods. Refills the input buffer
	when it runs out of data.
	* java/io/OutputStreamWriter.java
	(lastArray): Implements caching of the output array buffer.
	(lastBuffer): Implements caching of the output array buffer.
	(oneChar): New field. Caches a char array for write().
	(outputBuffer): Make this a ByteBuffer.
	(OutputStreamWriter): (all constructors) Cleaned up.
	Use initEncoderAndBuffer() method. Check for null parameters.
	Use new EncodingHelper.getDefaultCharset() for fetching the
	default charset.
	(encode): New helper method. Encodes the input buffer to the output
	buffer using either the NIO encoder or a raw Latin1 encoding.
	(encodeChars): New helper method. The encoding loop.
	(flush): Directly use the array of the output buffer.
	(getCharBuffer): New helper method. Implements caching of the
	output buffer.
	(initEncoderAndBuffer): New helper method for initialization.
	(write(char[],int,int)): Reworked to make better use of the NIO
	encoders.
	(write): Use cached array.
	(write(String,int,int)): Don't copy the string but rather wrap it
	and handle it the same as the wrapped char array.
	(writeConvert): Removed.
	* gnu/java/nio/charset/EncodingHelper.java
	(getDefaultCharset): New method. Returns the default charset for
	the case when the file.encoding charset is not valid. This
	always returns an UTF8 codec.

/Roman

-- 
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com   * Tel: +49-721-663 968-0

USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe
Geschäftsführer: Dr. James J. Hunt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-patch
Size: 38633 bytes
Desc: not available
Url : http://developer.classpath.org/pipermail/classpath-patches/attachments/20070327/b5b8650e/patch-0001.bin


More information about the Classpath-patches mailing list