You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/12/13 17:01:54 UTC

svn commit: r486702 [3/4] - in /harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset: ./ spi/

Modified: harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java?view=diff&rev=486702&r1=486701&r2=486702
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java Wed Dec 13 08:01:53 2006
@@ -89,577 +89,575 @@
  * @see java.nio.charset.CharsetDecoder
  */
 public abstract class CharsetEncoder {
-	/*
-	 * --------------------------------------- Consts
-	 * ---------------------------------------
-	 */
-	/*
-	 * internal status consts
-	 */
-	private static final int INIT = 0;
-
-	private static final int ONGOING = 1;
-
-	private static final int END = 2;
-
-	private static final int FLUSH = 3;
-
-	/*
-	 * --------------------------------------- Instance variables
-	 * ---------------------------------------
-	 */
-	// the Charset which creates this encoder
-	private Charset cs;
-
-	// average bytes per character created by this encoder
-	private float averBytes;
-
-	// maximum bytes per character can be created by this encoder
-	private float maxBytes;
-
-	// replacement byte array
-	private byte[] replace;
-
-	// internal status
-	private int status;
-
-	// action for malformed input
-	private CodingErrorAction malformAction;
-
-	// action for unmapped char input
-	private CodingErrorAction unmapAction;
-
-	// decoder instance for this encoder's charset, used for replacement value
-	// checking
-	private CharsetDecoder decoder;
-
-	/*
-	 * --------------------------------------- Constructors
-	 * ---------------------------------------
-	 */
-
-	/**
-	 * Construct a new <code>CharsetEncoder</code> using given
-	 * <code>Charset</code>, average number and maximum number of bytes
-	 * created by this encoder for one input character.
-	 * 
-	 * @param cs
-	 *            this encoder's <code>Charset</code>, which create this
-	 *            encoder
-	 * @param averageBytesPerChar
-	 *            average number of bytes created by this encoder for one input
-	 *            character, must be positive
-	 * @param maxBytesPerChar
-	 *            maximum number of bytes which can be created by this encoder
-	 *            for one input character, must be positive
-	 * @throws IllegalArgumentException
-	 *             if <code>maxBytesPerChar</code> or
-	 *             <code>averageBytePerChar</code> is negative
-	 */
-	protected CharsetEncoder(Charset cs, float averageBytesPerChar,
-			float maxBytesPerChar) {
-		this(cs, averageBytesPerChar, maxBytesPerChar,
-				new byte[] { (byte) '?' });
-	}
-
-	/**
-	 * Construct a new <code>CharsetEncoder</code> using given
-	 * <code>Charset</code>, replace byte array, average number and maximum
-	 * number of bytes created by this encoder for one input character.
-	 * 
-	 * @param cs
-	 *            the this encoder's <code>Charset</code>, which create this
-	 *            encoder
-	 * @param averageBytesPerChar
-	 *            average number of bytes created by this encoder for single
-	 *            input character, must be positive
-	 * @param maxBytesPerChar
-	 *            maximum number of bytes which can be created by this encoder
-	 *            for single input character, must be positive
-	 * @param replacement
-	 *            the replacement byte array, cannot be null or empty, its
-	 *            length cannot larger than <code>maxBytesPerChar</code>, and
-	 *            must be legal replacement, which can be justified by
-	 *            {@link #isLegalReplacement(byte[]) isLegalReplacement}
-	 * @throws IllegalArgumentException
-	 *             if any parameters are invalid
-	 */
-	protected CharsetEncoder(Charset cs, float averageBytesPerChar,
-			float maxBytesPerChar, byte[] replacement) {
-		if (averageBytesPerChar <= 0 || maxBytesPerChar <= 0) {
+    /*
+     * --------------------------------------- Consts
+     * ---------------------------------------
+     */
+    /*
+     * internal status consts
+     */
+    private static final int INIT = 0;
+
+    private static final int ONGOING = 1;
+
+    private static final int END = 2;
+
+    private static final int FLUSH = 3;
+
+    /*
+     * --------------------------------------- Instance variables
+     * ---------------------------------------
+     */
+    // the Charset which creates this encoder
+    private Charset cs;
+
+    // average bytes per character created by this encoder
+    private float averBytes;
+
+    // maximum bytes per character can be created by this encoder
+    private float maxBytes;
+
+    // replacement byte array
+    private byte[] replace;
+
+    // internal status
+    private int status;
+
+    // action for malformed input
+    private CodingErrorAction malformAction;
+
+    // action for unmapped char input
+    private CodingErrorAction unmapAction;
+
+    // decoder instance for this encoder's charset, used for replacement value
+    // checking
+    private CharsetDecoder decoder;
+
+    /*
+     * --------------------------------------- Constructors
+     * ---------------------------------------
+     */
+
+    /**
+     * Construct a new <code>CharsetEncoder</code> using given
+     * <code>Charset</code>, average number and maximum number of bytes
+     * created by this encoder for one input character.
+     * 
+     * @param cs
+     *            this encoder's <code>Charset</code>, which create this
+     *            encoder
+     * @param averageBytesPerChar
+     *            average number of bytes created by this encoder for one input
+     *            character, must be positive
+     * @param maxBytesPerChar
+     *            maximum number of bytes which can be created by this encoder
+     *            for one input character, must be positive
+     * @throws IllegalArgumentException
+     *             if <code>maxBytesPerChar</code> or
+     *             <code>averageBytePerChar</code> is negative
+     */
+    protected CharsetEncoder(Charset cs, float averageBytesPerChar,
+            float maxBytesPerChar) {
+        this(cs, averageBytesPerChar, maxBytesPerChar,
+                new byte[] { (byte) '?' });
+    }
+
+    /**
+     * Construct a new <code>CharsetEncoder</code> using given
+     * <code>Charset</code>, replace byte array, average number and maximum
+     * number of bytes created by this encoder for one input character.
+     * 
+     * @param cs
+     *            the this encoder's <code>Charset</code>, which create this
+     *            encoder
+     * @param averageBytesPerChar
+     *            average number of bytes created by this encoder for single
+     *            input character, must be positive
+     * @param maxBytesPerChar
+     *            maximum number of bytes which can be created by this encoder
+     *            for single input character, must be positive
+     * @param replacement
+     *            the replacement byte array, cannot be null or empty, its
+     *            length cannot larger than <code>maxBytesPerChar</code>, and
+     *            must be legal replacement, which can be justified by
+     *            {@link #isLegalReplacement(byte[]) isLegalReplacement}
+     * @throws IllegalArgumentException
+     *             if any parameters are invalid
+     */
+    protected CharsetEncoder(Charset cs, float averageBytesPerChar,
+            float maxBytesPerChar, byte[] replacement) {
+        if (averageBytesPerChar <= 0 || maxBytesPerChar <= 0) {
             // niochar.02=Bytes number for one character must be positive.
-			throw new IllegalArgumentException(
-					Messages.getString("niochar.02")); //$NON-NLS-1$
-		}
-		if (averageBytesPerChar > maxBytesPerChar) {
+            throw new IllegalArgumentException(Messages.getString("niochar.02")); //$NON-NLS-1$
+        }
+        if (averageBytesPerChar > maxBytesPerChar) {
             // niochar.03=averageBytesPerChar is greater than maxBytesPerChar.
-			throw new IllegalArgumentException(
-					Messages.getString("niochar.03")); //$NON-NLS-1$
-		}
-		this.cs = cs;
-		averBytes = averageBytesPerChar;
-		maxBytes = maxBytesPerChar;
-		status = INIT;
-		malformAction = CodingErrorAction.REPORT;
-		unmapAction = CodingErrorAction.REPORT;
-		replaceWith(replacement);
-	}
-
-	/*
-	 * --------------------------------------- Methods
-	 * ---------------------------------------
-	 */
-	/**
-	 * get the average number of bytes created by this encoder for single input
-	 * character
-	 * 
-	 * @return the average number of bytes created by this encoder for single
-	 *         input character
-	 */
-	public final float averageBytesPerChar() {
-		return averBytes;
-	}
-
-	/**
-	 * Check if given character can be encoded by this encoder.
-	 * 
-	 * Note that this method can change the internal status of this encoder, so
-	 * it should not be called when another encode process is ongoing, otherwise
-	 * it will throw <code>IllegalStateException</code>.
-	 * 
-	 * This method can be overridden for performance improvement.
-	 * 
-	 * @param c
-	 *            the given encoder
-	 * @return true if given character can be encoded by this encoder
-	 * @throws IllegalStateException
-	 *             if another encode process is ongoing so that current internal
-	 *             status is neither RESET or FLUSH
-	 */
-	public boolean canEncode(char c) {
-		return implCanEncode(CharBuffer.wrap(new char[] { c }));
-	}
-
-	// implementation of canEncode
-	private boolean implCanEncode(CharBuffer cb) {
-		if (status == FLUSH) {
-			status = INIT;
-		}
-		if (status != INIT) {
+            throw new IllegalArgumentException(Messages.getString("niochar.03")); //$NON-NLS-1$
+        }
+        this.cs = cs;
+        averBytes = averageBytesPerChar;
+        maxBytes = maxBytesPerChar;
+        status = INIT;
+        malformAction = CodingErrorAction.REPORT;
+        unmapAction = CodingErrorAction.REPORT;
+        replaceWith(replacement);
+    }
+
+    /*
+     * --------------------------------------- Methods
+     * ---------------------------------------
+     */
+    /**
+     * get the average number of bytes created by this encoder for single input
+     * character
+     * 
+     * @return the average number of bytes created by this encoder for single
+     *         input character
+     */
+    public final float averageBytesPerChar() {
+        return averBytes;
+    }
+
+    /**
+     * Check if given character can be encoded by this encoder.
+     * 
+     * Note that this method can change the internal status of this encoder, so
+     * it should not be called when another encode process is ongoing, otherwise
+     * it will throw <code>IllegalStateException</code>.
+     * 
+     * This method can be overridden for performance improvement.
+     * 
+     * @param c
+     *            the given encoder
+     * @return true if given character can be encoded by this encoder
+     * @throws IllegalStateException
+     *             if another encode process is ongoing so that current internal
+     *             status is neither RESET or FLUSH
+     */
+    public boolean canEncode(char c) {
+        return implCanEncode(CharBuffer.wrap(new char[] { c }));
+    }
+
+    // implementation of canEncode
+    private boolean implCanEncode(CharBuffer cb) {
+        if (status == FLUSH) {
+            status = INIT;
+        }
+        if (status != INIT) {
             // niochar.0B=Another encoding process is ongoing\!
-			throw new IllegalStateException(
-					Messages.getString("niochar.0B"));  //$NON-NLS-1$
-		}
-		CodingErrorAction malformBak = malformAction;
-		CodingErrorAction unmapBak = unmapAction;
-		onMalformedInput(CodingErrorAction.REPORT);
-		onUnmappableCharacter(CodingErrorAction.REPORT);
-		boolean result = true;
-		try {
-			this.encode(cb);
-		} catch (CharacterCodingException e) {
-			result = false;
-		}
-		onMalformedInput(malformBak);
-		onUnmappableCharacter(unmapBak);
-		reset();
-		return result;
-	}
-
-	/**
-	 * Check if given <code>CharSequence</code> can be encoded by this
-	 * encoder.
-	 * 
-	 * Note that this method can change the internal status of this encoder, so
-	 * it should not be called when another encode process is ongoing, otherwise
-	 * it will throw <code>IllegalStateException</code>.
-	 * 
-	 * This method can be overridden for performance improvement.
-	 * 
-	 * @param sequence
-	 *            the given <code>CharSequence</code>
-	 * @return true if given <code>CharSequence</code> can be encoded by this
-	 *         encoder
-	 * @throws IllegalStateException
-	 *             if current internal status is neither RESET or FLUSH
-	 */
-	public boolean canEncode(CharSequence sequence) {
-		CharBuffer cb;
-		if (sequence instanceof CharBuffer) {
-			cb = ((CharBuffer) sequence).duplicate();
-		} else {
-			cb = CharBuffer.wrap(sequence);
-		}
-		return implCanEncode(cb);
-	}
-
-	/**
-	 * Get the <code>Charset</code> which creates this encoder.
-	 * 
-	 * @return the <code>Charset</code> which creates this encoder
-	 */
-	public final Charset charset() {
-		return cs;
-	}
-
-	/**
-	 * This is a facade method for encoding operation.
-	 * <p>
-	 * This method encodes the remaining character sequence of the given
-	 * character buffer into a new byte buffer. This method performs a complete
-	 * encoding operation, resets at first, then encodes, and flushes at last.
-	 * </p>
-	 * <p>
-	 * This method should not be invoked if another encode operation is ongoing.
-	 * </p>
-	 * 
-	 * @param in
-	 *            the input buffer
-	 * @return a new <code>ByteBuffer</code> containing the the bytes produced
-	 *         by this encoding operation. The buffer's limit will be the
-	 *         position of last byte in buffer, and the position will be zero
-	 * @throws IllegalStateException
-	 *             if another encoding operation is ongoing
-	 * @throws MalformedInputException
-	 *             if illegal input character sequence for this charset
-	 *             encountered, and the action for malformed error is
-	 *             {@link CodingErrorAction#REPORT CodingErrorAction.REPORT}
-	 * @throws UnmappableCharacterException
-	 *             if legal but unmappable input character sequence for this
-	 *             charset encountered, and the action for unmappable character
-	 *             error is
-	 *             {@link CodingErrorAction#REPORT CodingErrorAction.REPORT}.
-	 *             Unmappable means the Unicode character sequence at the input
-	 *             buffer's current position cannot be mapped to a equivalent
-	 *             byte sequence.
-	 * @throws CharacterCodingException
-	 *             if other exception happened during the encode operation
-	 */
-	public final ByteBuffer encode(CharBuffer in)
-			throws CharacterCodingException {
-		if (in.remaining() == 0) {
-			return ByteBuffer.allocate(0);
-		}
-		reset();
-		int length = (int) (in.remaining() * averBytes);
-		ByteBuffer output = ByteBuffer.allocate(length);
-		CoderResult result = null;
-		while (true) {
-			result = encode(in, output, false);
+            throw new IllegalStateException(Messages.getString("niochar.0B")); //$NON-NLS-1$
+        }
+        CodingErrorAction malformBak = malformAction;
+        CodingErrorAction unmapBak = unmapAction;
+        onMalformedInput(CodingErrorAction.REPORT);
+        onUnmappableCharacter(CodingErrorAction.REPORT);
+        boolean result = true;
+        try {
+            this.encode(cb);
+        } catch (CharacterCodingException e) {
+            result = false;
+        }
+        onMalformedInput(malformBak);
+        onUnmappableCharacter(unmapBak);
+        reset();
+        return result;
+    }
+
+    /**
+     * Check if given <code>CharSequence</code> can be encoded by this
+     * encoder.
+     * 
+     * Note that this method can change the internal status of this encoder, so
+     * it should not be called when another encode process is ongoing, otherwise
+     * it will throw <code>IllegalStateException</code>.
+     * 
+     * This method can be overridden for performance improvement.
+     * 
+     * @param sequence
+     *            the given <code>CharSequence</code>
+     * @return true if given <code>CharSequence</code> can be encoded by this
+     *         encoder
+     * @throws IllegalStateException
+     *             if current internal status is neither RESET or FLUSH
+     */
+    public boolean canEncode(CharSequence sequence) {
+        CharBuffer cb;
+        if (sequence instanceof CharBuffer) {
+            cb = ((CharBuffer) sequence).duplicate();
+        } else {
+            cb = CharBuffer.wrap(sequence);
+        }
+        return implCanEncode(cb);
+    }
+
+    /**
+     * Get the <code>Charset</code> which creates this encoder.
+     * 
+     * @return the <code>Charset</code> which creates this encoder
+     */
+    public final Charset charset() {
+        return cs;
+    }
+
+    /**
+     * This is a facade method for encoding operation.
+     * <p>
+     * This method encodes the remaining character sequence of the given
+     * character buffer into a new byte buffer. This method performs a complete
+     * encoding operation, resets at first, then encodes, and flushes at last.
+     * </p>
+     * <p>
+     * This method should not be invoked if another encode operation is ongoing.
+     * </p>
+     * 
+     * @param in
+     *            the input buffer
+     * @return a new <code>ByteBuffer</code> containing the the bytes produced
+     *         by this encoding operation. The buffer's limit will be the
+     *         position of last byte in buffer, and the position will be zero
+     * @throws IllegalStateException
+     *             if another encoding operation is ongoing
+     * @throws MalformedInputException
+     *             if illegal input character sequence for this charset
+     *             encountered, and the action for malformed error is
+     *             {@link CodingErrorAction#REPORT CodingErrorAction.REPORT}
+     * @throws UnmappableCharacterException
+     *             if legal but unmappable input character sequence for this
+     *             charset encountered, and the action for unmappable character
+     *             error is
+     *             {@link CodingErrorAction#REPORT CodingErrorAction.REPORT}.
+     *             Unmappable means the Unicode character sequence at the input
+     *             buffer's current position cannot be mapped to a equivalent
+     *             byte sequence.
+     * @throws CharacterCodingException
+     *             if other exception happened during the encode operation
+     */
+    public final ByteBuffer encode(CharBuffer in)
+            throws CharacterCodingException {
+        if (in.remaining() == 0) {
+            return ByteBuffer.allocate(0);
+        }
+        reset();
+        int length = (int) (in.remaining() * averBytes);
+        ByteBuffer output = ByteBuffer.allocate(length);
+        CoderResult result = null;
+        while (true) {
+            result = encode(in, output, false);
             checkCoderResult(result);
-			if (result.isUnderflow()) {
-				break;
-			} else if (result.isOverflow()) {
-				output = allocateMore(output);
-			}
-		}
-		result = encode(in, output, true);
-		checkCoderResult(result);
-
-		while (true) {
-			result = flush(output);
-			checkCoderResult(result);
-			if (result.isOverflow()) {
-				output = allocateMore(output);
-			} else {
-				break;
-			}
-		}
-
-		output.flip();
-		if (result.isMalformed()) {
-			throw new MalformedInputException(result.length());
-		} else if (result.isUnmappable()) {
-			throw new UnmappableCharacterException(result.length());
-		}
-		status = FLUSH;
-		return output;
-	}
-
-	/*
-	 * checks the result whether it needs to throw CharacterCodingException.
-	 */
-	private void checkCoderResult(CoderResult result)
-			throws CharacterCodingException {
-		if (result.isMalformed() && malformAction == CodingErrorAction.REPORT) {
-			throw new MalformedInputException(result.length());
-		} else if (result.isUnmappable()
-				&& unmapAction == CodingErrorAction.REPORT) {
-			throw new UnmappableCharacterException(result.length());
-		}
-	}
-
-	// allocate more spaces to the given ByteBuffer
-	private ByteBuffer allocateMore(ByteBuffer output) {
-		if (output.capacity() == 0) {
-			return ByteBuffer.allocate(1);
-		}
-		ByteBuffer result = ByteBuffer.allocate(output.capacity() * 2);
-		output.flip();
-		result.put(output);
-		return result;
-	}
-
-	/**
-	 * Encodes characters starting at the current position of the given input
-	 * buffer, and writes the equivalent byte sequence into the given output
-	 * buffer from its current position.
-	 * <p>
-	 * The buffers' position will be changed with the reading and writing
-	 * operation, but their limits and marks will be kept intact.
-	 * </p>
-	 * <p>
-	 * A <code>CoderResult</code> instance will be returned according to
-	 * following rules:
-	 * <ul>
-	 * <li>A {@link CoderResult#malformedForLength(int) malformed input} result
-	 * indicates that some malformed input error encountered, and the erroneous
-	 * characters start at the input buffer's position and their number can be
-	 * got by result's {@link CoderResult#length() length}. This kind of result
-	 * can be returned only if the malformed action is
-	 * {@link CodingErrorAction#REPORT CodingErrorAction.REPORT}. </li>
-	 * <li>{@link CoderResult#UNDERFLOW CoderResult.UNDERFLOW} indicates that
-	 * as many characters as possible in the input buffer has been encoded. If
-	 * there is no further input and no characters left in the input buffer then
-	 * this task is complete. If this is not the case then the client should
-	 * call this method again supplying some more input characters.</li>
-	 * <li>{@link CoderResult#OVERFLOW CoderResult.OVERFLOW} indicates that the
-	 * output buffer has been filled, while there are still some characters
-	 * remaining in the input buffer. This method should be invoked again with a
-	 * non-full output buffer </li>
-	 * <li>A {@link CoderResult#unmappableForLength(int) unmappable character}
-	 * result indicates that some unmappable character error was encountered,
-	 * and the erroneous characters start at the input buffer's position and
-	 * their number can be got by result's {@link CoderResult#length() length}.
-	 * This kind of result can be returned only on
-	 * {@link CodingErrorAction#REPORT CodingErrorAction.REPORT}. </li>
-	 * </ul>
-	 * </p>
-	 * <p>
-	 * The <code>endOfInput</code> parameter indicates that if the invoker can
-	 * provider further input. This parameter is true if and only if the
-	 * characters in current input buffer are all inputs for this encoding
-	 * operation. Note that it is common and won't cause error that the invoker
-	 * sets false and then finds no more input available; while it may cause
-	 * error that the invoker always sets true in several consecutive
-	 * invocations so that any remaining input will be treated as malformed
-	 * input.
-	 * </p>
-	 * <p>
-	 * This method invokes
-	 * {@link #encodeLoop(CharBuffer, ByteBuffer) encodeLoop} method to
-	 * implement basic encode logic for specific charset.
-	 * </p>
-	 * 
-	 * @param in
-	 *            the input buffer
-	 * @param out
-	 *            the output buffer
-	 * @param endOfInput
-	 *            true if all the input characters have been provided
-	 * @return a <code>CoderResult</code> instance indicating the result
-	 * @throws IllegalStateException
-	 *             if the encoding operation has already started or no more
-	 *             input needed in this encoding progress.
-	 * @throws CoderMalfunctionError
-	 *             If the {@link #encodeLoop(CharBuffer, ByteBuffer) encodeLoop}
-	 *             method threw an <code>BufferUnderflowException</code> or
-	 *             <code>BufferUnderflowException</code>
-	 */
-	public final CoderResult encode(CharBuffer in, ByteBuffer out,
-			boolean endOfInput) {
-		if ((status == FLUSH) || (!endOfInput && status == END)) {
-			throw new IllegalStateException();
-		}
-
-		CoderResult result;
-    	while(true){
-        	try{
-                    result = encodeLoop(in, out);
-        	} catch(BufferOverflowException e){
-                    throw new CoderMalfunctionError (e);
-        	} catch(BufferUnderflowException e){
-                    throw new CoderMalfunctionError (e);
-        	}
-        	if(result.isUnderflow()) {
-        	        int remaining = in.remaining();
-        		if(endOfInput && remaining > 0) {
-        			result = CoderResult.malformedForLength(remaining);
-        		}else{
-        			status = endOfInput ? END : ONGOING;
-        			return result;
-        		}
-        		
-        	}
-        	if (result.isOverflow()) {
-        		return result;
-        	}
-        	CodingErrorAction action = malformAction;
-        	if(result.isUnmappable()) {
-        		action = unmapAction;
-        	}
-        	// If the action is IGNORE or REPLACE, we should continue
-        	// encoding.
-        	if(action == CodingErrorAction.REPLACE) {
-        		if(out.remaining() < replace.length) {
-        			return CoderResult.OVERFLOW;
-        		}
-        		out.put(replace);
-        	}else{
-        		if(action != CodingErrorAction.IGNORE) 
-				return result;
-        	}
-        	in.position(in.position() + result.length());
-    	}
-	}
-
-	/**
-	 * Encode characters into bytes. This method is called by
-	 * {@link #encode(CharBuffer, ByteBuffer, boolean) encode}.
-	 * 
-	 * This method will implement the essential encoding operation, and it won't
-	 * stop encoding until either all the input characters are read, the output
-	 * buffer is filled, or some exception encountered. And then it will return
-	 * a <code>CoderResult</code> object indicating the result of current
-	 * encoding operation. The rules to construct the <code>CoderResult</code>
-	 * is same as the {@link #encode(CharBuffer, ByteBuffer, boolean) encode}.
-	 * When exception encountered in the encoding operation, most implementation
-	 * of this method will return a relevant result object to
-	 * {@link #encode(CharBuffer, ByteBuffer, boolean) encode} method, and some
-	 * performance optimized implementation may handle the exception and
-	 * implement the error action itself.
-	 * 
-	 * The buffers are scanned from their current positions, and their positions
-	 * will be modified accordingly, while their marks and limits will be
-	 * intact. At most {@link CharBuffer#remaining() in.remaining()} characters
-	 * will be read, and {@link ByteBuffer#remaining() out.remaining()} bytes
-	 * will be written.
-	 * 
-	 * Note that some implementation may pre-scan the input buffer and return
-	 * <code>CoderResult.UNDERFLOW</code> until it receives sufficient input.
-	 * 
-	 * @param in
-	 *            the input buffer
-	 * @param out
-	 *            the output buffer
-	 * @return a <code>CoderResult</code> instance indicating the result
-	 */
-	protected abstract CoderResult encodeLoop(CharBuffer in, ByteBuffer out);
-
-	/**
-	 * Flush this encoder.
-	 * 
-	 * This method will call {@link #implFlush(ByteBuffer) implFlush}. Some
-	 * encoders may need to write some bytes to the output buffer when they have
-	 * read all input characters, subclasses can overridden
-	 * {@link #implFlush(ByteBuffer) implFlush} to perform writing action.
-	 * 
-	 * The maximum number of written bytes won't larger than
-	 * {@link ByteBuffer#remaining() out.remaining()}. If some encoder want to
-	 * write more bytes than output buffer's remaining spaces, then
-	 * <code>CoderResult.OVERFLOW</code> will be returned, and this method
-	 * must be called again with a byte buffer has more spaces. Otherwise this
-	 * method will return <code>CoderResult.UNDERFLOW</code>, which means one
-	 * encoding process has been completed successfully.
-	 * 
-	 * During the flush, the output buffer's position will be changed
-	 * accordingly, while its mark and limit will be intact.
-	 * 
-	 * @param out
-	 *            the given output buffer
-	 * @return <code>CoderResult.UNDERFLOW</code> or
-	 *         <code>CoderResult.OVERFLOW</code>
-	 * @throws IllegalStateException
-	 *             if this encoder hasn't read all input characters during one
-	 *             encoding process, which means neither after calling
-	 *             {@link #encode(CharBuffer) encode(CharBuffer)} nor after
-	 *             calling {@link #encode(CharBuffer, ByteBuffer, boolean) 
-	 *             encode(CharBuffer, ByteBuffer, boolean)} with true value for
-	 *             the last boolean parameter
-	 */
-	public final CoderResult flush(ByteBuffer out) {
-		if (status != END && status != INIT) {
-			throw new IllegalStateException();
-		}
-		CoderResult result = implFlush(out);
-		if (result == CoderResult.UNDERFLOW) {
-			status = FLUSH;
-		}
-		return result;
-	}
-
-	/**
-	 * Flush this encoder. Default implementation does nothing and always return
-	 * <code>CoderResult.UNDERFLOW</code>, and this method can be overridden
-	 * if needed.
-	 * 
-	 * @param out
-	 *            the output buffer
-	 * @return <code>CoderResult.UNDERFLOW</code> or
-	 *         <code>CoderResult.OVERFLOW</code>
-	 */
-	protected CoderResult implFlush(ByteBuffer out) {
-		return CoderResult.UNDERFLOW;
-	}
-
-	/**
-	 * Notify that this encoder's <code>CodingErrorAction</code> specified for
-	 * malformed input error has been changed. Default implementation does
-	 * nothing, and this method can be overridden if needed.
-	 * 
-	 * @param newAction
-	 *            The new action
-	 */
-	protected void implOnMalformedInput(CodingErrorAction newAction) {
-		// default implementation is empty
-	}
-
-	/**
-	 * Notify that this encoder's <code>CodingErrorAction</code> specified for
-	 * unmappable character error has been changed. Default implementation does
-	 * nothing, and this method can be overridden if needed.
-	 * 
-	 * @param newAction
-	 *            The new action
-	 */
-	protected void implOnUnmappableCharacter(CodingErrorAction newAction) {
-		// default implementation is empty
-	}
-
-	/**
-	 * Notify that this encoder's replacement has been changed. Default
-	 * implementation does nothing, and this method can be overridden if needed.
-	 * 
-	 * @param newReplacement
-	 *            the new replacement string
-	 */
-	protected void implReplaceWith(byte[] newReplacement) {
-		// default implementation is empty
-	}
-
-	/**
-	 * Reset this encoder's charset related state. Default implementation does
-	 * nothing, and this method can be overridden if needed.
-	 */
-	protected void implReset() {
-		// default implementation is empty
-	}
-
-	/**
-	 * Check if the given argument is legal as this encoder's replacement byte
-	 * array.
-	 * 
-	 * The given byte array is legal if and only if it can be decode into
-	 * sixteen bits Unicode characters.
-	 * 
-	 * This method can be overridden for performance improvement.
-	 * 
-	 * @param repl
-	 *            the given byte array to be checked
-	 * @return true if the the given argument is legal as this encoder's
-	 *         replacement byte array.
-	 */
-	public boolean isLegalReplacement(byte[] repl) {
+            if (result.isUnderflow()) {
+                break;
+            } else if (result.isOverflow()) {
+                output = allocateMore(output);
+            }
+        }
+        result = encode(in, output, true);
+        checkCoderResult(result);
+
+        while (true) {
+            result = flush(output);
+            checkCoderResult(result);
+            if (result.isOverflow()) {
+                output = allocateMore(output);
+            } else {
+                break;
+            }
+        }
+
+        output.flip();
+        if (result.isMalformed()) {
+            throw new MalformedInputException(result.length());
+        } else if (result.isUnmappable()) {
+            throw new UnmappableCharacterException(result.length());
+        }
+        status = FLUSH;
+        return output;
+    }
+
+    /*
+     * checks the result whether it needs to throw CharacterCodingException.
+     */
+    private void checkCoderResult(CoderResult result)
+            throws CharacterCodingException {
+        if (result.isMalformed() && malformAction == CodingErrorAction.REPORT) {
+            throw new MalformedInputException(result.length());
+        } else if (result.isUnmappable()
+                && unmapAction == CodingErrorAction.REPORT) {
+            throw new UnmappableCharacterException(result.length());
+        }
+    }
+
+    // allocate more spaces to the given ByteBuffer
+    private ByteBuffer allocateMore(ByteBuffer output) {
+        if (output.capacity() == 0) {
+            return ByteBuffer.allocate(1);
+        }
+        ByteBuffer result = ByteBuffer.allocate(output.capacity() * 2);
+        output.flip();
+        result.put(output);
+        return result;
+    }
+
+    /**
+     * Encodes characters starting at the current position of the given input
+     * buffer, and writes the equivalent byte sequence into the given output
+     * buffer from its current position.
+     * <p>
+     * The buffers' position will be changed with the reading and writing
+     * operation, but their limits and marks will be kept intact.
+     * </p>
+     * <p>
+     * A <code>CoderResult</code> instance will be returned according to
+     * following rules:
+     * <ul>
+     * <li>A {@link CoderResult#malformedForLength(int) malformed input} result
+     * indicates that some malformed input error encountered, and the erroneous
+     * characters start at the input buffer's position and their number can be
+     * got by result's {@link CoderResult#length() length}. This kind of result
+     * can be returned only if the malformed action is
+     * {@link CodingErrorAction#REPORT CodingErrorAction.REPORT}. </li>
+     * <li>{@link CoderResult#UNDERFLOW CoderResult.UNDERFLOW} indicates that
+     * as many characters as possible in the input buffer has been encoded. If
+     * there is no further input and no characters left in the input buffer then
+     * this task is complete. If this is not the case then the client should
+     * call this method again supplying some more input characters.</li>
+     * <li>{@link CoderResult#OVERFLOW CoderResult.OVERFLOW} indicates that the
+     * output buffer has been filled, while there are still some characters
+     * remaining in the input buffer. This method should be invoked again with a
+     * non-full output buffer </li>
+     * <li>A {@link CoderResult#unmappableForLength(int) unmappable character}
+     * result indicates that some unmappable character error was encountered,
+     * and the erroneous characters start at the input buffer's position and
+     * their number can be got by result's {@link CoderResult#length() length}.
+     * This kind of result can be returned only on
+     * {@link CodingErrorAction#REPORT CodingErrorAction.REPORT}. </li>
+     * </ul>
+     * </p>
+     * <p>
+     * The <code>endOfInput</code> parameter indicates that if the invoker can
+     * provider further input. This parameter is true if and only if the
+     * characters in current input buffer are all inputs for this encoding
+     * operation. Note that it is common and won't cause error that the invoker
+     * sets false and then finds no more input available; while it may cause
+     * error that the invoker always sets true in several consecutive
+     * invocations so that any remaining input will be treated as malformed
+     * input.
+     * </p>
+     * <p>
+     * This method invokes
+     * {@link #encodeLoop(CharBuffer, ByteBuffer) encodeLoop} method to
+     * implement basic encode logic for specific charset.
+     * </p>
+     * 
+     * @param in
+     *            the input buffer
+     * @param out
+     *            the output buffer
+     * @param endOfInput
+     *            true if all the input characters have been provided
+     * @return a <code>CoderResult</code> instance indicating the result
+     * @throws IllegalStateException
+     *             if the encoding operation has already started or no more
+     *             input needed in this encoding progress.
+     * @throws CoderMalfunctionError
+     *             If the {@link #encodeLoop(CharBuffer, ByteBuffer) encodeLoop}
+     *             method threw an <code>BufferUnderflowException</code> or
+     *             <code>BufferUnderflowException</code>
+     */
+    public final CoderResult encode(CharBuffer in, ByteBuffer out,
+            boolean endOfInput) {
+        if ((status == FLUSH) || (!endOfInput && status == END)) {
+            throw new IllegalStateException();
+        }
+
+        CoderResult result;
+        while (true) {
+            try {
+                result = encodeLoop(in, out);
+            } catch (BufferOverflowException e) {
+                throw new CoderMalfunctionError(e);
+            } catch (BufferUnderflowException e) {
+                throw new CoderMalfunctionError(e);
+            }
+            if (result.isUnderflow()) {
+                int remaining = in.remaining();
+                if (endOfInput && remaining > 0) {
+                    result = CoderResult.malformedForLength(remaining);
+                } else {
+                    status = endOfInput ? END : ONGOING;
+                    return result;
+                }
+
+            }
+            if (result.isOverflow()) {
+                return result;
+            }
+            CodingErrorAction action = malformAction;
+            if (result.isUnmappable()) {
+                action = unmapAction;
+            }
+            // If the action is IGNORE or REPLACE, we should continue
+            // encoding.
+            if (action == CodingErrorAction.REPLACE) {
+                if (out.remaining() < replace.length) {
+                    return CoderResult.OVERFLOW;
+                }
+                out.put(replace);
+            } else {
+                if (action != CodingErrorAction.IGNORE) {
+                    return result;
+                }
+            }
+            in.position(in.position() + result.length());
+        }
+    }
+
+    /**
+     * Encode characters into bytes. This method is called by
+     * {@link #encode(CharBuffer, ByteBuffer, boolean) encode}.
+     * 
+     * This method will implement the essential encoding operation, and it won't
+     * stop encoding until either all the input characters are read, the output
+     * buffer is filled, or some exception encountered. And then it will return
+     * a <code>CoderResult</code> object indicating the result of current
+     * encoding operation. The rules to construct the <code>CoderResult</code>
+     * is same as the {@link #encode(CharBuffer, ByteBuffer, boolean) encode}.
+     * When exception encountered in the encoding operation, most implementation
+     * of this method will return a relevant result object to
+     * {@link #encode(CharBuffer, ByteBuffer, boolean) encode} method, and some
+     * performance optimized implementation may handle the exception and
+     * implement the error action itself.
+     * 
+     * The buffers are scanned from their current positions, and their positions
+     * will be modified accordingly, while their marks and limits will be
+     * intact. At most {@link CharBuffer#remaining() in.remaining()} characters
+     * will be read, and {@link ByteBuffer#remaining() out.remaining()} bytes
+     * will be written.
+     * 
+     * Note that some implementation may pre-scan the input buffer and return
+     * <code>CoderResult.UNDERFLOW</code> until it receives sufficient input.
+     * 
+     * @param in
+     *            the input buffer
+     * @param out
+     *            the output buffer
+     * @return a <code>CoderResult</code> instance indicating the result
+     */
+    protected abstract CoderResult encodeLoop(CharBuffer in, ByteBuffer out);
+
+    /**
+     * Flush this encoder.
+     * 
+     * This method will call {@link #implFlush(ByteBuffer) implFlush}. Some
+     * encoders may need to write some bytes to the output buffer when they have
+     * read all input characters, subclasses can overridden
+     * {@link #implFlush(ByteBuffer) implFlush} to perform writing action.
+     * 
+     * The maximum number of written bytes won't larger than
+     * {@link ByteBuffer#remaining() out.remaining()}. If some encoder want to
+     * write more bytes than output buffer's remaining spaces, then
+     * <code>CoderResult.OVERFLOW</code> will be returned, and this method
+     * must be called again with a byte buffer has more spaces. Otherwise this
+     * method will return <code>CoderResult.UNDERFLOW</code>, which means one
+     * encoding process has been completed successfully.
+     * 
+     * During the flush, the output buffer's position will be changed
+     * accordingly, while its mark and limit will be intact.
+     * 
+     * @param out
+     *            the given output buffer
+     * @return <code>CoderResult.UNDERFLOW</code> or
+     *         <code>CoderResult.OVERFLOW</code>
+     * @throws IllegalStateException
+     *             if this encoder hasn't read all input characters during one
+     *             encoding process, which means neither after calling
+     *             {@link #encode(CharBuffer) encode(CharBuffer)} nor after
+     *             calling {@link #encode(CharBuffer, ByteBuffer, boolean) 
+     *             encode(CharBuffer, ByteBuffer, boolean)} with true value for
+     *             the last boolean parameter
+     */
+    public final CoderResult flush(ByteBuffer out) {
+        if (status != END && status != INIT) {
+            throw new IllegalStateException();
+        }
+        CoderResult result = implFlush(out);
+        if (result == CoderResult.UNDERFLOW) {
+            status = FLUSH;
+        }
+        return result;
+    }
+
+    /**
+     * Flush this encoder. Default implementation does nothing and always return
+     * <code>CoderResult.UNDERFLOW</code>, and this method can be overridden
+     * if needed.
+     * 
+     * @param out
+     *            the output buffer
+     * @return <code>CoderResult.UNDERFLOW</code> or
+     *         <code>CoderResult.OVERFLOW</code>
+     */
+    protected CoderResult implFlush(ByteBuffer out) {
+        return CoderResult.UNDERFLOW;
+    }
+
+    /**
+     * Notify that this encoder's <code>CodingErrorAction</code> specified for
+     * malformed input error has been changed. Default implementation does
+     * nothing, and this method can be overridden if needed.
+     * 
+     * @param newAction
+     *            The new action
+     */
+    protected void implOnMalformedInput(CodingErrorAction newAction) {
+        // default implementation is empty
+    }
+
+    /**
+     * Notify that this encoder's <code>CodingErrorAction</code> specified for
+     * unmappable character error has been changed. Default implementation does
+     * nothing, and this method can be overridden if needed.
+     * 
+     * @param newAction
+     *            The new action
+     */
+    protected void implOnUnmappableCharacter(CodingErrorAction newAction) {
+        // default implementation is empty
+    }
+
+    /**
+     * Notify that this encoder's replacement has been changed. Default
+     * implementation does nothing, and this method can be overridden if needed.
+     * 
+     * @param newReplacement
+     *            the new replacement string
+     */
+    protected void implReplaceWith(byte[] newReplacement) {
+        // default implementation is empty
+    }
+
+    /**
+     * Reset this encoder's charset related state. Default implementation does
+     * nothing, and this method can be overridden if needed.
+     */
+    protected void implReset() {
+        // default implementation is empty
+    }
+
+    /**
+     * Check if the given argument is legal as this encoder's replacement byte
+     * array.
+     * 
+     * The given byte array is legal if and only if it can be decode into
+     * sixteen bits Unicode characters.
+     * 
+     * This method can be overridden for performance improvement.
+     * 
+     * @param repl
+     *            the given byte array to be checked
+     * @return true if the the given argument is legal as this encoder's
+     *         replacement byte array.
+     */
+    public boolean isLegalReplacement(byte[] repl) {
         if (decoder == null) {
             decoder = cs.newDecoder();
         }
@@ -677,139 +675,137 @@
         return !result.isError();
     }
 
-	/**
-	 * Gets this encoder's <code>CodingErrorAction</code> when malformed input
-	 * occurred during encoding process.
-	 * 
-	 * @return this encoder's <code>CodingErrorAction</code> when malformed
-	 *         input occurred during encoding process.
-	 */
-	public CodingErrorAction malformedInputAction() {
-		return malformAction;
-	}
-
-	/**
-	 * Get the maximum number of bytes which can be created by this encoder for
-	 * one input character, must be positive
-	 * 
-	 * @return the maximum number of bytes which can be created by this encoder
-	 *         for one input character, must be positive
-	 */
-	public final float maxBytesPerChar() {
-		return maxBytes;
-	}
-
-	/**
-	 * Set this encoder's action on malformed input error.
-	 * 
-	 * This method will call the
-	 * {@link #implOnMalformedInput(CodingErrorAction) implOnMalformedInput}
-	 * method with the given new action as argument.
-	 * 
-	 * @param newAction
-	 *            the new action on malformed input error
-	 * @return this encoder
-	 * @throws IllegalArgumentException
-	 *             if the given newAction is null
-	 */
-	public final CharsetEncoder onMalformedInput(CodingErrorAction newAction) {
-		if (null == newAction) {
+    /**
+     * Gets this encoder's <code>CodingErrorAction</code> when malformed input
+     * occurred during encoding process.
+     * 
+     * @return this encoder's <code>CodingErrorAction</code> when malformed
+     *         input occurred during encoding process.
+     */
+    public CodingErrorAction malformedInputAction() {
+        return malformAction;
+    }
+
+    /**
+     * Get the maximum number of bytes which can be created by this encoder for
+     * one input character, must be positive
+     * 
+     * @return the maximum number of bytes which can be created by this encoder
+     *         for one input character, must be positive
+     */
+    public final float maxBytesPerChar() {
+        return maxBytes;
+    }
+
+    /**
+     * Set this encoder's action on malformed input error.
+     * 
+     * This method will call the
+     * {@link #implOnMalformedInput(CodingErrorAction) implOnMalformedInput}
+     * method with the given new action as argument.
+     * 
+     * @param newAction
+     *            the new action on malformed input error
+     * @return this encoder
+     * @throws IllegalArgumentException
+     *             if the given newAction is null
+     */
+    public final CharsetEncoder onMalformedInput(CodingErrorAction newAction) {
+        if (null == newAction) {
             // niochar.0C=Action on malformed input error cannot be null\!
-			throw new IllegalArgumentException(
-					Messages.getString("niochar.0C"));  //$NON-NLS-1$
-		}
-		malformAction = newAction;
-		implOnMalformedInput(newAction);
-		return this;
-	}
-
-	/**
-	 * Set this encoder's action on unmappable character error.
-	 * 
-	 * This method will call the
-	 * {@link #implOnUnmappableCharacter(CodingErrorAction) implOnUnmappableCharacter}
-	 * method with the given new action as argument.
-	 * 
-	 * @param newAction
-	 *            the new action on unmappable character error
-	 * @return this encoder
-	 * @throws IllegalArgumentException
-	 *             if the given newAction is null
-	 */
-	public final CharsetEncoder onUnmappableCharacter(
-			CodingErrorAction newAction) {
-		if (null == newAction) {
+            throw new IllegalArgumentException(Messages.getString("niochar.0C")); //$NON-NLS-1$
+        }
+        malformAction = newAction;
+        implOnMalformedInput(newAction);
+        return this;
+    }
+
+    /**
+     * Set this encoder's action on unmappable character error.
+     * 
+     * This method will call the
+     * {@link #implOnUnmappableCharacter(CodingErrorAction) implOnUnmappableCharacter}
+     * method with the given new action as argument.
+     * 
+     * @param newAction
+     *            the new action on unmappable character error
+     * @return this encoder
+     * @throws IllegalArgumentException
+     *             if the given newAction is null
+     */
+    public final CharsetEncoder onUnmappableCharacter(
+            CodingErrorAction newAction) {
+        if (null == newAction) {
             // niochar.0D=Action on unmappable character error cannot be null\!
-			throw new IllegalArgumentException(
-					Messages.getString("niochar.0D"));  //$NON-NLS-1$
-		}
-		unmapAction = newAction;
-		implOnUnmappableCharacter(newAction);
-		return this;
-	}
-
-	/**
-	 * Get the replacement byte array, which is never null or empty, and it is
-	 * legal
-	 * 
-	 * @return the replacement byte array, cannot be null or empty, and it is
-	 *         legal
-	 */
-	public final byte[] replacement() {
-		return replace;
-	}
-
-	/**
-	 * Set new replacement value.
-	 * 
-	 * This method first checks the given replacement's validity, then changes
-	 * the replacement value, and at last calls
-	 * {@link #implReplaceWith(byte[]) implReplaceWith} method with the given
-	 * new replacement as argument.
-	 * 
-	 * @param replacement
-	 *            the replacement byte array, cannot be null or empty, its
-	 *            length cannot larger than <code>maxBytesPerChar</code>, and
-	 *            must be legal replacement, which can be justified by
-	 *            <code>isLegalReplacement(byte[] repl)</code>
-	 * @return this encoder
-	 * @throws IllegalArgumentException
-	 *             if the given replacement cannot satisfy the requirement
-	 *             mentioned above
-	 */
-	public final CharsetEncoder replaceWith(byte[] replacement) {
-		if (null == replacement || 0 == replacement.length
-				|| maxBytes < replacement.length
-				|| !isLegalReplacement(replacement)) {
+            throw new IllegalArgumentException(Messages.getString("niochar.0D")); //$NON-NLS-1$
+        }
+        unmapAction = newAction;
+        implOnUnmappableCharacter(newAction);
+        return this;
+    }
+
+    /**
+     * Get the replacement byte array, which is never null or empty, and it is
+     * legal
+     * 
+     * @return the replacement byte array, cannot be null or empty, and it is
+     *         legal
+     */
+    public final byte[] replacement() {
+        return replace;
+    }
+
+    /**
+     * Set new replacement value.
+     * 
+     * This method first checks the given replacement's validity, then changes
+     * the replacement value, and at last calls
+     * {@link #implReplaceWith(byte[]) implReplaceWith} method with the given
+     * new replacement as argument.
+     * 
+     * @param replacement
+     *            the replacement byte array, cannot be null or empty, its
+     *            length cannot larger than <code>maxBytesPerChar</code>, and
+     *            must be legal replacement, which can be justified by
+     *            <code>isLegalReplacement(byte[] repl)</code>
+     * @return this encoder
+     * @throws IllegalArgumentException
+     *             if the given replacement cannot satisfy the requirement
+     *             mentioned above
+     */
+    public final CharsetEncoder replaceWith(byte[] replacement) {
+        if (null == replacement || 0 == replacement.length
+                || maxBytes < replacement.length
+                || !isLegalReplacement(replacement)) {
             // niochar.0E=Replacement is illegal
-			throw new IllegalArgumentException(Messages.getString("niochar.0E"));  //$NON-NLS-1$
-		}
-		replace = replacement;
-		implReplaceWith(replacement);
-		return this;
-	}
-
-	/**
-	 * Reset this encoder. This method will reset internal status, and then call
-	 * <code>implReset()</code> to reset any status related to specific
-	 * charset.
-	 * 
-	 * @return this encoder
-	 */
-	public final CharsetEncoder reset() {
-		status = INIT;
-		implReset();
-		return this;
-	}
-
-	/**
-	 * Gets this encoder's <code>CodingErrorAction</code> when unmappable
-	 * character occurred during encoding process.
-	 * 
-	 * @return this encoder's <code>CodingErrorAction</code> when unmappable
-	 *         character occurred during encoding process.
-	 */
-	public CodingErrorAction unmappableCharacterAction() {
-		return unmapAction;
-	}
+            throw new IllegalArgumentException(Messages.getString("niochar.0E")); //$NON-NLS-1$
+        }
+        replace = replacement;
+        implReplaceWith(replacement);
+        return this;
+    }
+
+    /**
+     * Reset this encoder. This method will reset internal status, and then call
+     * <code>implReset()</code> to reset any status related to specific
+     * charset.
+     * 
+     * @return this encoder
+     */
+    public final CharsetEncoder reset() {
+        status = INIT;
+        implReset();
+        return this;
+    }
+
+    /**
+     * Gets this encoder's <code>CodingErrorAction</code> when unmappable
+     * character occurred during encoding process.
+     * 
+     * @return this encoder's <code>CodingErrorAction</code> when unmappable
+     *         character occurred during encoding process.
+     */
+    public CodingErrorAction unmappableCharacterAction() {
+        return unmapAction;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CoderMalfunctionError.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CoderMalfunctionError.java?view=diff&rev=486702&r1=486701&r2=486702
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CoderMalfunctionError.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CoderMalfunctionError.java Wed Dec 13 08:01:53 2006
@@ -17,39 +17,24 @@
 
 package java.nio.charset;
 
-
 /**
  * Errors thrown when the encoder/decoder is malfunctioning.
- * 
  */
 public class CoderMalfunctionError extends Error {
 
-	/*
-	 * -------------------------------------------------------------------
-	 * Constants
-	 * -------------------------------------------------------------------
-	 */
-
-	/*
-	 * This constant is used during deserialization to check the J2SE version
-	 * which created the serialized object.
-	 */
-	private static final long serialVersionUID = -1151412348057794301L; // J2SE 1.4.2
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Constructors
-	 * -------------------------------------------------------------------
-	 */
-
-	/**
-	 * Constructs an instance of this error.
-	 * 
-	 * @param ex
-	 *            the original exception thrown by the encoder/decoder
-	 */
-	public CoderMalfunctionError(Exception ex) {
-		super(ex);
-	}
-
+    /*
+     * This constant is used during deserialization to check the J2SE version
+     * which created the serialized object.
+     */
+    private static final long serialVersionUID = -1151412348057794301L;
+
+    /**
+     * Constructs an instance of this error.
+     * 
+     * @param ex
+     *            the original exception thrown by the encoder/decoder
+     */
+    public CoderMalfunctionError(Exception ex) {
+        super(ex);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CoderResult.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CoderResult.java?view=diff&rev=486702&r1=486701&r2=486702
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CoderResult.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CoderResult.java Wed Dec 13 08:01:53 2006
@@ -16,7 +16,6 @@
 
 package java.nio.charset;
 
-
 import java.nio.BufferOverflowException;
 import java.nio.BufferUnderflowException;
 import java.util.WeakHashMap;
@@ -45,278 +44,254 @@
  */
 public class CoderResult {
 
-	/*
-	 * -------------------------------------------------------------------
-	 * Constants
-	 * -------------------------------------------------------------------
-	 */
-
-	// indicating underflow error type
-	private static final int TYPE_UNDERFLOW = 1;
-
-	// indicating overflow error type
-	private static final int TYPE_OVERFLOW = 2;
-
-	// indicating malformed-input error type
-	private static final int TYPE_MALFORMED_INPUT = 3;
-
-	// indicating unmappable character error type
-	private static final int TYPE_UNMAPPABLE_CHAR = 4;
-
-	/**
-	 * Result object indicating that there is insufficient data in the
-	 * encoding/decoding buffer or that additional data is required.
-	 */
-	public static final CoderResult UNDERFLOW = new CoderResult(TYPE_UNDERFLOW,
-			0);
-
-	/**
-	 * Result object used to signify that the out buffer does not have enough
-	 * space available in it to store the result of the encoding/decoding.
-	 */
-	public static final CoderResult OVERFLOW = new CoderResult(TYPE_OVERFLOW, 0);
-
-	/*
-	 * --------------------------------------------------------------------
-	 * Class variables
-	 * --------------------------------------------------------------------
-	 */
-
-	// stores unique result objects for each malformed-input error of a certain
-	// length
-	private static WeakHashMap _malformedErrors = new WeakHashMap();
-
-	// stores unique result objects for each unmappable-character error of a
-	// certain length
-	private static WeakHashMap _unmappableErrors = new WeakHashMap();
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Instance variables
-	 * -------------------------------------------------------------------
-	 */
-
-	// the type this result
-	private final int type;
-
-	// the length of the erroneous input
-	private final int length;
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Constructors
-	 * -------------------------------------------------------------------
-	 */
-
-	/**
-	 * Construct a <code>CoderResult</code> object with its text description.
-	 * 
-	 * @param type
-	 *            the type of this result
-	 * @param length
-	 *            the length of the erroneous input
-	 */
-	private CoderResult(int type, int length) {
-		super();
-		this.type = type;
-		this.length = length;
-	}
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Methods
-	 * -------------------------------------------------------------------
-	 */
-
-	/**
-	 * Gets a <code>CoderResult</code> object indicating a malformed-input
-	 * error.
-	 * 
-	 * @param length
-	 *            the length of the malformed-input
-	 * @return a <code>CoderResult</code> object indicating a malformed-input
-	 *         error
-	 * @throws IllegalArgumentException
-	 *             If <code>length</code> is non-positive.
-	 */
-	public static synchronized CoderResult malformedForLength(int length)
-			throws IllegalArgumentException {
-		if (length > 0) {
-			synchronized (_malformedErrors) {
-				Integer key = new Integer(length);
-				CoderResult r = (CoderResult) _malformedErrors.get(key);
-				if (null == r) {
-					r = new CoderResult(TYPE_MALFORMED_INPUT, length);
-					_malformedErrors.put(key, r);
-				}
-				return r;
-			}
-		}
-        // niochar.08=The length must be positive: {0}.
-		throw new IllegalArgumentException(Messages.getString("niochar.08", length));  //$NON-NLS-1$
-	}
+    // indicating underflow error type
+    private static final int TYPE_UNDERFLOW = 1;
 
-	/**
-	 * Gets a <code>CoderResult</code> object indicating an unmappable
-	 * character error.
-	 * 
-	 * @param length
-	 *            the length of the input unit sequence denoting the unmappable
-	 *            character
-	 * @return a <code>CoderResult</code> object indicating an unmappable
-	 *         character error
-	 * @throws IllegalArgumentException
-	 *             If <code>length</code> is non-positive.
-	 */
-	public static synchronized CoderResult unmappableForLength(int length)
-			throws IllegalArgumentException {
-		if (length > 0) {
-			synchronized (_unmappableErrors) {
-				Integer key = new Integer(length);
-				CoderResult r = (CoderResult) _unmappableErrors.get(key);
-				if (null == r) {
-					r = new CoderResult(TYPE_UNMAPPABLE_CHAR, length);
-					_unmappableErrors.put(key, r);
-				}
-				return r;
-			}
-		}
-        // niochar.08=The length must be positive: {0}.
-		throw new IllegalArgumentException(Messages.getString("niochar.08", length));  //$NON-NLS-1$
-	}
+    // indicating overflow error type
+    private static final int TYPE_OVERFLOW = 2;
 
-	/**
-	 * Answers true if this result is an underflow condition.
-	 * 
-	 * @return true if an underflow, otherwise false
-	 */
-	public boolean isUnderflow() {
-		return this.type == TYPE_UNDERFLOW;
-	}
-
-	/**
-	 * Answers true if this result represents a malformed-input error or an
-	 * unmappable-character error.
-	 * 
-	 * @return true if a malformed-input error or an unmappable-character error,
-	 *         otherwise false
-	 */
-	public boolean isError() {
-		return this.type == TYPE_MALFORMED_INPUT
-				|| this.type == TYPE_UNMAPPABLE_CHAR;
-	}
-
-	/**
-	 * Answers true if this result represents a malformed-input error.
-	 * 
-	 * @return true if a malformed-input error, otherwise false
-	 */
-	public boolean isMalformed() {
-		return this.type == TYPE_MALFORMED_INPUT;
-	}
-
-	/**
-	 * Answers true if this result is an overflow condition.
-	 * 
-	 * @return true if an overflow, otherwise false
-	 */
-	public boolean isOverflow() {
-		return this.type == TYPE_OVERFLOW;
-	}
-
-	/**
-	 * Answers true if this result represents an unmappable-character error.
-	 * 
-	 * @return true if an unmappable-character error, otherwise false
-	 */
-	public boolean isUnmappable() {
-		return this.type == TYPE_UNMAPPABLE_CHAR;
-	}
-
-	/**
-	 * Gets the length of the erroneous input. The length is only meaningful to
-	 * a malformed-input error or an unmappble character error.
-	 * 
-	 * @return the length, as an integer, of this object's erroneous input 
-	 * @throws UnsupportedOperationException
-	 *             If this result is an overflow or underflow.
-	 */
-	public int length() throws UnsupportedOperationException {
-		if (this.type == TYPE_MALFORMED_INPUT
-				|| this.type == TYPE_UNMAPPABLE_CHAR) {
-			return this.length;
-		}
-		// niochar.09=The length of the erroneous input is only meaningful to 
+    // indicating malformed-input error type
+    private static final int TYPE_MALFORMED_INPUT = 3;
+
+    // indicating unmappable character error type
+    private static final int TYPE_UNMAPPABLE_CHAR = 4;
+
+    /**
+     * Result object indicating that there is insufficient data in the
+     * encoding/decoding buffer or that additional data is required.
+     */
+    public static final CoderResult UNDERFLOW = new CoderResult(TYPE_UNDERFLOW,
+            0);
+
+    /**
+     * Result object used to signify that the out buffer does not have enough
+     * space available in it to store the result of the encoding/decoding.
+     */
+    public static final CoderResult OVERFLOW = new CoderResult(TYPE_OVERFLOW, 0);
+
+    /*
+     * Stores unique result objects for each malformed-input error of a certain
+     * length
+     */
+    private static WeakHashMap<Integer, CoderResult> _malformedErrors = new WeakHashMap<Integer, CoderResult>();
+
+    /*
+     * Stores unique result objects for each unmappable-character error of a
+     * certain length
+     */
+    private static WeakHashMap<Integer, CoderResult> _unmappableErrors = new WeakHashMap<Integer, CoderResult>();
+
+    // the type this result
+    private final int type;
+
+    // the length of the erroneous input
+    private final int length;
+
+    /**
+     * Construct a <code>CoderResult</code> object with its text description.
+     * 
+     * @param type
+     *            the type of this result
+     * @param length
+     *            the length of the erroneous input
+     */
+    private CoderResult(int type, int length) {
+        super();
+        this.type = type;
+        this.length = length;
+    }
+
+    /**
+     * Gets a <code>CoderResult</code> object indicating a malformed-input
+     * error.
+     * 
+     * @param length
+     *            the length of the malformed-input
+     * @return a <code>CoderResult</code> object indicating a malformed-input
+     *         error
+     * @throws IllegalArgumentException
+     *             If <code>length</code> is non-positive.
+     */
+    public static synchronized CoderResult malformedForLength(int length)
+            throws IllegalArgumentException {
+        if (length > 0) {
+            Integer key = Integer.valueOf(length);
+            synchronized (_malformedErrors) {
+                CoderResult r = _malformedErrors.get(key);
+                if (null == r) {
+                    r = new CoderResult(TYPE_MALFORMED_INPUT, length);
+                    _malformedErrors.put(key, r);
+                }
+                return r;
+            }
+        }
+        // niochar.08=The length must be positive: {0}.
+        throw new IllegalArgumentException(Messages.getString(
+                "niochar.08", length)); //$NON-NLS-1$
+    }
+
+    /**
+     * Gets a <code>CoderResult</code> object indicating an unmappable
+     * character error.
+     * 
+     * @param length
+     *            the length of the input unit sequence denoting the unmappable
+     *            character
+     * @return a <code>CoderResult</code> object indicating an unmappable
+     *         character error
+     * @throws IllegalArgumentException
+     *             If <code>length</code> is non-positive.
+     */
+    public static synchronized CoderResult unmappableForLength(int length)
+            throws IllegalArgumentException {
+        if (length > 0) {
+            Integer key = Integer.valueOf(length);
+            synchronized (_unmappableErrors) {
+                CoderResult r = _unmappableErrors.get(key);
+                if (null == r) {
+                    r = new CoderResult(TYPE_UNMAPPABLE_CHAR, length);
+                    _unmappableErrors.put(key, r);
+                }
+                return r;
+            }
+        }
+        // niochar.08=The length must be positive: {0}.
+        throw new IllegalArgumentException(Messages.getString(
+                "niochar.08", length)); //$NON-NLS-1$
+    }
+
+    /**
+     * Answers true if this result is an underflow condition.
+     * 
+     * @return true if an underflow, otherwise false
+     */
+    public boolean isUnderflow() {
+        return this.type == TYPE_UNDERFLOW;
+    }
+
+    /**
+     * Answers true if this result represents a malformed-input error or an
+     * unmappable-character error.
+     * 
+     * @return true if a malformed-input error or an unmappable-character error,
+     *         otherwise false
+     */
+    public boolean isError() {
+        return this.type == TYPE_MALFORMED_INPUT
+                || this.type == TYPE_UNMAPPABLE_CHAR;
+    }
+
+    /**
+     * Answers true if this result represents a malformed-input error.
+     * 
+     * @return true if a malformed-input error, otherwise false
+     */
+    public boolean isMalformed() {
+        return this.type == TYPE_MALFORMED_INPUT;
+    }
+
+    /**
+     * Answers true if this result is an overflow condition.
+     * 
+     * @return true if an overflow, otherwise false
+     */
+    public boolean isOverflow() {
+        return this.type == TYPE_OVERFLOW;
+    }
+
+    /**
+     * Answers true if this result represents an unmappable-character error.
+     * 
+     * @return true if an unmappable-character error, otherwise false
+     */
+    public boolean isUnmappable() {
+        return this.type == TYPE_UNMAPPABLE_CHAR;
+    }
+
+    /**
+     * Gets the length of the erroneous input. The length is only meaningful to
+     * a malformed-input error or an unmappble character error.
+     * 
+     * @return the length, as an integer, of this object's erroneous input
+     * @throws UnsupportedOperationException
+     *             If this result is an overflow or underflow.
+     */
+    public int length() throws UnsupportedOperationException {
+        if (this.type == TYPE_MALFORMED_INPUT
+                || this.type == TYPE_UNMAPPABLE_CHAR) {
+            return this.length;
+        }
+        // niochar.09=The length of the erroneous input is only meaningful to
         // a malformed-input error or an unmappble character error
-        throw new UnsupportedOperationException(
-				Messages.getString("niochar.09"));  //$NON-NLS-1$
-	}
-
-	/**
-	 * Throws an exception corresponding to this coder result.
-	 * 
-	 * @throws BufferUnderflowException
-	 *             If an underflow.
-	 * @throws BufferOverflowException
-	 *             If an overflow.
-	 * @throws UnmappableCharacterException
-	 *             If an unmappable-character error.
-	 * @throws MalformedInputException
-	 *             If a malformed-input error.
-	 * @throws CharacterCodingException
-	 *             The default exception.
-	 */
-	public void throwException() throws BufferUnderflowException,
-			BufferOverflowException, UnmappableCharacterException,
-			MalformedInputException, CharacterCodingException {
-		switch (this.type) {
-		case TYPE_UNDERFLOW:
-			throw new BufferUnderflowException();
-		case TYPE_OVERFLOW:
-			throw new BufferOverflowException();
-		case TYPE_UNMAPPABLE_CHAR:
-			throw new UnmappableCharacterException(this.length);
-		case TYPE_MALFORMED_INPUT:
-			throw new MalformedInputException(this.length);
-		default:
-			throw new CharacterCodingException();
-		}
-	}
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Methods overriding parent class Object
-	 * -------------------------------------------------------------------
-	 */
-
-	/**
-	 * Returns a text description of this result.
-	 * 
-	 * @return a text description of this result
-	 */
-	public String toString() {
-		String dsc = null;
-		switch (this.type) {
-		case TYPE_UNDERFLOW:
-			dsc = "UNDERFLOW error"; //$NON-NLS-1$
-			break;
-		case TYPE_OVERFLOW:
-			dsc = "OVERFLOW error"; //$NON-NLS-1$
-			break;
-		case TYPE_UNMAPPABLE_CHAR:
-			dsc = "Unmappable-character error with erroneous input length " //$NON-NLS-1$
-					+ this.length;
-			break;
-		case TYPE_MALFORMED_INPUT:
-			dsc = "Malformed-input error with erroneous input length " //$NON-NLS-1$
-					+ this.length;
-			break;
-		default:
-			dsc = ""; //$NON-NLS-1$
-			break;
-		}
-		return "CoderResult[" + dsc + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+        throw new UnsupportedOperationException(Messages
+                .getString("niochar.09")); //$NON-NLS-1$
+    }
+
+    /**
+     * Throws an exception corresponding to this coder result.
+     * 
+     * @throws BufferUnderflowException
+     *             If an underflow.
+     * @throws BufferOverflowException
+     *             If an overflow.
+     * @throws UnmappableCharacterException
+     *             If an unmappable-character error.
+     * @throws MalformedInputException
+     *             If a malformed-input error.
+     * @throws CharacterCodingException
+     *             The default exception.
+     */
+    public void throwException() throws BufferUnderflowException,
+            BufferOverflowException, UnmappableCharacterException,
+            MalformedInputException, CharacterCodingException {
+        switch (this.type) {
+            case TYPE_UNDERFLOW:
+                throw new BufferUnderflowException();
+            case TYPE_OVERFLOW:
+                throw new BufferOverflowException();
+            case TYPE_UNMAPPABLE_CHAR:
+                throw new UnmappableCharacterException(this.length);
+            case TYPE_MALFORMED_INPUT:
+                throw new MalformedInputException(this.length);
+            default:
+                throw new CharacterCodingException();
+        }
+    }
+
+    /*
+     * -------------------------------------------------------------------
+     * Methods overriding parent class Object
+     * -------------------------------------------------------------------
+     */
+
+    /**
+     * Returns a text description of this result.
+     * 
+     * @return a text description of this result
+     */
+    public String toString() {
+        String dsc = null;
+        switch (this.type) {
+            case TYPE_UNDERFLOW:
+                dsc = "UNDERFLOW error"; //$NON-NLS-1$
+                break;
+            case TYPE_OVERFLOW:
+                dsc = "OVERFLOW error"; //$NON-NLS-1$
+                break;
+            case TYPE_UNMAPPABLE_CHAR:
+                dsc = "Unmappable-character error with erroneous input length " //$NON-NLS-1$
+                        + this.length;
+                break;
+            case TYPE_MALFORMED_INPUT:
+                dsc = "Malformed-input error with erroneous input length " //$NON-NLS-1$
+                        + this.length;
+                break;
+            default:
+                dsc = ""; //$NON-NLS-1$
+                break;
+        }
+        return "CoderResult[" + dsc + "]"; //$NON-NLS-1$ //$NON-NLS-2$
 
-	}
+    }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CodingErrorAction.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CodingErrorAction.java?view=diff&rev=486702&r1=486701&r2=486702
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CodingErrorAction.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CodingErrorAction.java Wed Dec 13 08:01:53 2006
@@ -16,76 +16,49 @@
 
 package java.nio.charset;
 
-
 /**
  * Used to indicate what kind of actions to take in case of encoding/decoding
  * errors. Currently three actions are defined, namely, IGNORE, REPLACE and
  * REPORT.
- * 
  */
 public class CodingErrorAction {
 
-	/*
-	 * -------------------------------------------------------------------
-	 * Constants
-	 * -------------------------------------------------------------------
-	 */
-
-	/**
-	 * Indicating the action to ignore any errors.
-	 */
-	public static final CodingErrorAction IGNORE = new CodingErrorAction(
-			"IGNORE"); //$NON-NLS-1$
-
-	/**
-	 * Indicating the action to fill in the output with a replacement character
-	 * when malformed input or an unmappable character is encountered.
-	 */
-	public static final CodingErrorAction REPLACE = new CodingErrorAction(
-			"REPLACE"); //$NON-NLS-1$
-
-	/**
-	 * Indicating the action to report the encountered error in an appropriate
-	 * manner, for example, throw an exception or return an informative result.
-	 */
-	public static final CodingErrorAction REPORT = new CodingErrorAction(
-			"REPORT"); //$NON-NLS-1$
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Instance variables
-	 * -------------------------------------------------------------------
-	 */
-
-	// the name of this action
-	private String action;
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Constructors
-	 * -------------------------------------------------------------------
-	 */
-
-	/*
-	 * Can't instantiate outside.
-	 */
-	private CodingErrorAction(String action) {
-		this.action = action;
-	}
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Methods overriding parent class Object
-	 * -------------------------------------------------------------------
-	 */
-
-	/**
-	 * Returns a text description of this action indication..
-	 * 
-	 * @return a text description of this action indication.
-	 */
-	public String toString() {
-		return "Action: " + this.action; //$NON-NLS-1$
-	}
-
+    /**
+     * Indicating the action to ignore any errors.
+     */
+    public static final CodingErrorAction IGNORE = new CodingErrorAction(
+            "IGNORE"); //$NON-NLS-1$
+
+    /**
+     * Indicating the action to fill in the output with a replacement character
+     * when malformed input or an unmappable character is encountered.
+     */
+    public static final CodingErrorAction REPLACE = new CodingErrorAction(
+            "REPLACE"); //$NON-NLS-1$
+
+    /**
+     * Indicating the action to report the encountered error in an appropriate
+     * manner, for example, throw an exception or return an informative result.
+     */
+    public static final CodingErrorAction REPORT = new CodingErrorAction(
+            "REPORT"); //$NON-NLS-1$
+
+    // The name of this action
+    private String action;
+
+    /*
+     * Can't instantiate outside.
+     */
+    private CodingErrorAction(String action) {
+        this.action = action;
+    }
+
+    /**
+     * Returns a text description of this action indication..
+     * 
+     * @return a text description of this action indication.
+     */
+    public String toString() {
+        return "Action: " + this.action; //$NON-NLS-1$
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/IllegalCharsetNameException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/IllegalCharsetNameException.java?view=diff&rev=486702&r1=486701&r2=486702
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/IllegalCharsetNameException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/IllegalCharsetNameException.java Wed Dec 13 08:01:53 2006
@@ -19,65 +19,38 @@
 
 import org.apache.harmony.niochar.internal.nls.Messages;
 
-
 /**
  * Thrown when an illegal charset name is encountered.
- * 
  */
 public class IllegalCharsetNameException extends IllegalArgumentException {
 
-	/*
-	 * -------------------------------------------------------------------
-	 * Constants
-	 * -------------------------------------------------------------------
-	 */
-
-	/*
-	 * This constant is used during deserialization to check the J2SE version
-	 * which created the serialized object.
-	 */
-	private static final long serialVersionUID = 1457525358470002989L; // J2SE 1.4.2
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Instance variables
-	 * -------------------------------------------------------------------
-	 */
-
-	// the illegal charset name
-	private String charsetName;
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Constructors
-	 * -------------------------------------------------------------------
-	 */
-
-	/**
-	 * Constructs an instance of this exception with the supplied charset name.
-	 * 
-	 * @param charset
-	 *            the encountered illegal charset name
-	 */
-	public IllegalCharsetNameException(String charset) {
+    /*
+     * This constant is used during deserialization to check the J2SE version
+     * which created the serialized object.
+     */
+    private static final long serialVersionUID = 1457525358470002989L;
+
+    // The illegal charset name
+    private String charsetName;
+
+    /**
+     * Constructs an instance of this exception with the supplied charset name.
+     * 
+     * @param charset
+     *            the encountered illegal charset name
+     */
+    public IllegalCharsetNameException(String charset) {
         // niochar.0F=The illegal charset name is "{0}".
-		super(Messages.getString("niochar.0F", charset));  //$NON-NLS-1$
-		this.charsetName = charset;
-	}
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Methods
-	 * -------------------------------------------------------------------
-	 */
-
-	/**
-	 * Gets the encountered illegal charset name.
-	 * 
-	 * @return the encountered illegal charset name
-	 */
-	public String getCharsetName() {
-		return this.charsetName;
-	}
-
+        super(Messages.getString("niochar.0F", charset)); //$NON-NLS-1$
+        this.charsetName = charset;
+    }
+
+    /**
+     * Gets the encountered illegal charset name.
+     * 
+     * @return the encountered illegal charset name
+     */
+    public String getCharsetName() {
+        return this.charsetName;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/MalformedInputException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/MalformedInputException.java?view=diff&rev=486702&r1=486701&r2=486702
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/MalformedInputException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/MalformedInputException.java Wed Dec 13 08:01:53 2006
@@ -19,80 +19,47 @@
 
 import org.apache.harmony.niochar.internal.nls.Messages;
 
-
 /**
  * Thrown when a malformed input is encountered, for example, a byte sequence is
  * illegal for the given charset.
- * 
  */
 public class MalformedInputException extends CharacterCodingException {
 
-	/*
-	 * -------------------------------------------------------------------
-	 * Constants
-	 * -------------------------------------------------------------------
-	 */
-
-	/*
-	 * This constant is used during deserialization to check the J2SE version
-	 * which created the serialized object.
-	 */
-	private static final long serialVersionUID = -3438823399834806194L; // J2SE 1.4.2
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Instance variables
-	 * -------------------------------------------------------------------
-	 */
-
-	// the length of the malformed input
-	private int inputLength;
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Constructors
-	 * -------------------------------------------------------------------
-	 */
-
-	/**
-	 * Constructs an instance of this exception.
-	 * 
-	 * @param length
-	 *            the length of the malformed input
-	 */
-	public MalformedInputException(int length) {
-		this.inputLength = length;
-	}
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Methods
-	 * -------------------------------------------------------------------
-	 */
-
-	/**
-	 * Gets the length of the malformed input.
-	 * 
-	 * @return the length of the malformed input
-	 */
-	public int getInputLength() {
-		return this.inputLength;
-	}
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Methods overriding parent class Throwable
-	 * -------------------------------------------------------------------
-	 */
-
-	/**
-	 * Gets a message describing this exception.
-	 * 
-	 * @return a message describing this exception
-	 */
-	public String getMessage() {
+    /*
+     * This constant is used during deserialization to check the J2SE version
+     * which created the serialized object.
+     */
+    private static final long serialVersionUID = -3438823399834806194L;
+
+    // the length of the malformed input
+    private int inputLength;
+
+    /**
+     * Constructs an instance of this exception.
+     * 
+     * @param length
+     *            the length of the malformed input
+     */
+    public MalformedInputException(int length) {
+        this.inputLength = length;
+    }
+
+    /**
+     * Gets the length of the malformed input.
+     * 
+     * @return the length of the malformed input
+     */
+    public int getInputLength() {
+        return this.inputLength;
+    }
+
+    /**
+     * Gets a message describing this exception.
+     * 
+     * @return a message describing this exception
+     */
+    public String getMessage() {
         // niochar.05=Malformed input length is {0}.
-		return Messages.getString("niochar.05", this.inputLength);  //$NON-NLS-1$
-	}
-
+        return Messages.getString("niochar.05", this.inputLength); //$NON-NLS-1$
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/UnmappableCharacterException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/UnmappableCharacterException.java?view=diff&rev=486702&r1=486701&r2=486702
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/UnmappableCharacterException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/UnmappableCharacterException.java Wed Dec 13 08:01:53 2006
@@ -19,80 +19,46 @@
 
 import org.apache.harmony.niochar.internal.nls.Messages;
 
-
 /**
  * Thrown when an unmappable character for the given charset is encountered.
- * 
- * 
  */
 public class UnmappableCharacterException extends CharacterCodingException {
 
-	/*
-	 * -------------------------------------------------------------------
-	 * Constants
-	 * -------------------------------------------------------------------
-	 */
-
-	/*
-	 * This constant is used during deserialization to check the J2SE version
-	 * which created the serialized object.
-	 */
-	private static final long serialVersionUID = -7026962371537706123L; // J2SE 1.4.2
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Instance variables
-	 * -------------------------------------------------------------------
-	 */
-
-	// the length of the unmappable character
-	private int inputLength;
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Constructors
-	 * -------------------------------------------------------------------
-	 */
-
-	/**
-	 * Constructs an instance of this exception.
-	 * 
-	 * @param length
-	 *            the length of the unmappable character
-	 */
-	public UnmappableCharacterException(int length) {
-		this.inputLength = length;
-	}
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Methods
-	 * -------------------------------------------------------------------
-	 */
-
-	/**
-	 * Gets the length of the unmappable character.
-	 * 
-	 * @return the length of the unmappable character
-	 */
-	public int getInputLength() {
-		return this.inputLength;
-	}
-
-	/*
-	 * -------------------------------------------------------------------
-	 * Methods overriding parent class Throwable
-	 * -------------------------------------------------------------------
-	 */
-
-	/**
-	 * Gets a message describing this exception.
-	 * 
-	 * @return a message describing this exception
-	 */
-	public String getMessage() {
+    /*
+     * This constant is used during deserialization to check the J2SE version
+     * which created the serialized object.
+     */
+    private static final long serialVersionUID = -7026962371537706123L;
+
+    // The length of the unmappable character
+    private int inputLength;
+
+    /**
+     * Constructs an instance of this exception.
+     * 
+     * @param length
+     *            the length of the unmappable character
+     */
+    public UnmappableCharacterException(int length) {
+        this.inputLength = length;
+    }
+
+    /**
+     * Gets the length of the unmappable character.
+     * 
+     * @return the length of the unmappable character
+     */
+    public int getInputLength() {
+        return this.inputLength;
+    }
+
+    /**
+     * Gets a message describing this exception.
+     * 
+     * @return a message describing this exception
+     */
+    public String getMessage() {
         // niochar.0A=The unmappable character length is {0}.
-		return Messages.getString("niochar.0A", this.inputLength);  //$NON-NLS-1$
-	}
-
+        return Messages.getString("niochar.0A", this.inputLength); //$NON-NLS-1$
+    }
 }