You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/08/18 03:45:39 UTC

svn commit: r432462 [21/21] - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringReader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringReader.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringReader.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringReader.java Thu Aug 17 18:45:35 2006
@@ -1,216 +1,216 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.io;
-
-
-/**
- * StringReader is used as a character input stream on a String.
- * 
- * @see StringWriter
- */
-public class StringReader extends Reader {
-	private String str;
-
-	private int markpos = -1;
-
-	private int pos = 0;
-
-	private int count;
-
-	/**
-	 * Construct a StringReader on the String <code>str</code>. The size of
-	 * the reader is set to the <code>length()</code> of the String and the
-	 * Object to synchronize access through is set to <code>str</code>.
-	 * 
-	 * @param str
-	 *            the String to filter reads on.
-	 */
-	public StringReader(String str) {
-		super(str);
-		this.str = str;
-		this.count = str.length();
-	}
-
-	/**
-	 * This method closes this StringReader. Once it is closed, you can no
-	 * longer read from it. Only the first invocation of this method has any
-	 * effect.
-	 */
-	public void close() {
-		synchronized (lock) {
-			if (isOpen())
-				str = null;
-		}
-	}
-
-	/**
-	 * Answer a boolean indicating whether or not this StringReader is open.
-	 * @return str
-	 */
-	private boolean isOpen() {
-		return str != null;
-	}
-
-	/**
-	 * Set a Mark position in this Reader. The parameter <code>readLimit</code>
-	 * is ignored for StringReaders. Sending reset() will reposition the reader
-	 * back to the marked position provided the mark has not been invalidated.
-	 * 
-	 * @param readLimit
-	 *            ignored for StringReaders.
-	 * 
-	 * @throws IOException
-	 *             If an error occurs attempting mark this StringReader.
-	 */
-	public void mark(int readLimit) throws IOException {
-		if (readLimit >= 0) {
-			synchronized (lock) {
-				if (isOpen())
-					markpos = pos;
-				else
-					throw new IOException(org.apache.harmony.luni.util.Msg
-							.getString("K0083")); //$NON-NLS-1$
-			}
-		} else
-			throw new IllegalArgumentException();
-	}
-
-	/**
-	 * Answers a boolean indicating whether or not this StringReader supports
-	 * mark() and reset(). This method always returns true.
-	 * 
-	 * @return <code>true</code> if mark() and reset() are supported,
-	 *         <code>false</code> otherwise. This implementation always
-	 *         returns <code>true</code>.
-	 */
-	public boolean markSupported() {
-		return true;
-	}
-
-	/**
-	 * Reads a single character from this StringReader and returns the result as
-	 * an int. The 2 higher-order bytes are set to 0. If the end of reader was
-	 * encountered then return -1.
-	 * 
-	 * @return the character read or -1 if end of reader.
-	 * 
-	 * @throws IOException
-	 *             If the StringReader is already closed.
-	 */
-	public int read() throws IOException {
-		synchronized (lock) {
-			if (isOpen()) {
-				if (pos != count) {
-					return str.charAt(pos++);
-				}
-				return -1;
-			}
-			throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.Reader#read(char[], int, int)
-	 */
-	public int read(char buf[], int offset, int len) throws IOException {
-		// avoid int overflow
-		if (0 <= offset && offset <= buf.length && 0 <= len
-				&& len <= buf.length - offset) {
-			synchronized (lock) {
-				if (isOpen()) {
-					if (pos == this.count) {
-						return -1;
-					}
-					int end = pos + len > this.count ? this.count : pos + len;
-					str.getChars(pos, end, buf, offset);
-					int read = end - pos;
-					pos = end;
-					return read;
-				}
-				throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
-			}
-		}
-		throw new ArrayIndexOutOfBoundsException();
-	}
-
-	/**
-	 * Answers a <code>boolean</code> indicating whether or not this
-	 * StringReader is ready to be read without blocking. If the result is
-	 * <code>true</code>, the next <code>read()</code> will not block. If
-	 * the result is <code>false</code> this Reader may or may not block when
-	 * <code>read()</code> is sent. The implementation in StringReader always
-	 * returns <code>true</code> even when it has been closed.
-	 * 
-	 * @return <code>true</code> if the receiver will not block when
-	 *         <code>read()</code> is called, <code>false</code> if unknown
-	 *         or blocking will occur.
-	 * 
-	 * @throws IOException
-	 *             If an IO error occurs.
-	 */
-	public boolean ready() throws IOException {
-		synchronized (lock) {
-			if (isOpen())
-				return true;
-			throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
-		}
-	}
-
-	/**
-	 * Reset this StringReader's position to the last <code>mark()</code>
-	 * location. Invocations of <code>read()/skip()</code> will occur from
-	 * this new location. If this Reader was not marked, the StringReader is
-	 * reset to the beginning of the String.
-	 * 
-	 * @throws IOException
-	 *             If this StringReader has already been closed.
-	 */
-	public void reset() throws IOException {
-		synchronized (lock) {
-			if (isOpen())
-				pos = markpos != -1 ? markpos : 0;
-			else
-				throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.Reader#skip(long)
-	 */
-	public long skip(long ns) throws IOException {
-		synchronized (lock) {
-			if (isOpen()) {
-				if (ns <= 0) {
-					return 0;
-				}
-				long skipped = 0;
-				if (ns < this.count - pos) {
-					pos = pos + (int) ns;
-					skipped = ns;
-				} else {
-					skipped = this.count - pos;
-					pos = this.count;
-				}
-				return skipped;
-			}
-			throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
-		}
-	}
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+
+/**
+ * StringReader is used as a character input stream on a String.
+ * 
+ * @see StringWriter
+ */
+public class StringReader extends Reader {
+	private String str;
+
+	private int markpos = -1;
+
+	private int pos = 0;
+
+	private int count;
+
+	/**
+	 * Construct a StringReader on the String <code>str</code>. The size of
+	 * the reader is set to the <code>length()</code> of the String and the
+	 * Object to synchronize access through is set to <code>str</code>.
+	 * 
+	 * @param str
+	 *            the String to filter reads on.
+	 */
+	public StringReader(String str) {
+		super(str);
+		this.str = str;
+		this.count = str.length();
+	}
+
+	/**
+	 * This method closes this StringReader. Once it is closed, you can no
+	 * longer read from it. Only the first invocation of this method has any
+	 * effect.
+	 */
+	public void close() {
+		synchronized (lock) {
+			if (isOpen())
+				str = null;
+		}
+	}
+
+	/**
+	 * Answer a boolean indicating whether or not this StringReader is open.
+	 * @return str
+	 */
+	private boolean isOpen() {
+		return str != null;
+	}
+
+	/**
+	 * Set a Mark position in this Reader. The parameter <code>readLimit</code>
+	 * is ignored for StringReaders. Sending reset() will reposition the reader
+	 * back to the marked position provided the mark has not been invalidated.
+	 * 
+	 * @param readLimit
+	 *            ignored for StringReaders.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting mark this StringReader.
+	 */
+	public void mark(int readLimit) throws IOException {
+		if (readLimit >= 0) {
+			synchronized (lock) {
+				if (isOpen())
+					markpos = pos;
+				else
+					throw new IOException(org.apache.harmony.luni.util.Msg
+							.getString("K0083")); //$NON-NLS-1$
+			}
+		} else
+			throw new IllegalArgumentException();
+	}
+
+	/**
+	 * Answers a boolean indicating whether or not this StringReader supports
+	 * mark() and reset(). This method always returns true.
+	 * 
+	 * @return <code>true</code> if mark() and reset() are supported,
+	 *         <code>false</code> otherwise. This implementation always
+	 *         returns <code>true</code>.
+	 */
+	public boolean markSupported() {
+		return true;
+	}
+
+	/**
+	 * Reads a single character from this StringReader and returns the result as
+	 * an int. The 2 higher-order bytes are set to 0. If the end of reader was
+	 * encountered then return -1.
+	 * 
+	 * @return the character read or -1 if end of reader.
+	 * 
+	 * @throws IOException
+	 *             If the StringReader is already closed.
+	 */
+	public int read() throws IOException {
+		synchronized (lock) {
+			if (isOpen()) {
+				if (pos != count) {
+					return str.charAt(pos++);
+				}
+				return -1;
+			}
+			throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.io.Reader#read(char[], int, int)
+	 */
+	public int read(char buf[], int offset, int len) throws IOException {
+		// avoid int overflow
+		if (0 <= offset && offset <= buf.length && 0 <= len
+				&& len <= buf.length - offset) {
+			synchronized (lock) {
+				if (isOpen()) {
+					if (pos == this.count) {
+						return -1;
+					}
+					int end = pos + len > this.count ? this.count : pos + len;
+					str.getChars(pos, end, buf, offset);
+					int read = end - pos;
+					pos = end;
+					return read;
+				}
+				throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
+			}
+		}
+		throw new ArrayIndexOutOfBoundsException();
+	}
+
+	/**
+	 * Answers a <code>boolean</code> indicating whether or not this
+	 * StringReader is ready to be read without blocking. If the result is
+	 * <code>true</code>, the next <code>read()</code> will not block. If
+	 * the result is <code>false</code> this Reader may or may not block when
+	 * <code>read()</code> is sent. The implementation in StringReader always
+	 * returns <code>true</code> even when it has been closed.
+	 * 
+	 * @return <code>true</code> if the receiver will not block when
+	 *         <code>read()</code> is called, <code>false</code> if unknown
+	 *         or blocking will occur.
+	 * 
+	 * @throws IOException
+	 *             If an IO error occurs.
+	 */
+	public boolean ready() throws IOException {
+		synchronized (lock) {
+			if (isOpen())
+				return true;
+			throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
+		}
+	}
+
+	/**
+	 * Reset this StringReader's position to the last <code>mark()</code>
+	 * location. Invocations of <code>read()/skip()</code> will occur from
+	 * this new location. If this Reader was not marked, the StringReader is
+	 * reset to the beginning of the String.
+	 * 
+	 * @throws IOException
+	 *             If this StringReader has already been closed.
+	 */
+	public void reset() throws IOException {
+		synchronized (lock) {
+			if (isOpen())
+				pos = markpos != -1 ? markpos : 0;
+			else
+				throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.io.Reader#skip(long)
+	 */
+	public long skip(long ns) throws IOException {
+		synchronized (lock) {
+			if (isOpen()) {
+				if (ns <= 0) {
+					return 0;
+				}
+				long skipped = 0;
+				if (ns < this.count - pos) {
+					pos = pos + (int) ns;
+					skipped = ns;
+				} else {
+					skipped = this.count - pos;
+					pos = this.count;
+				}
+				return skipped;
+			}
+			throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
+		}
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java Thu Aug 17 18:45:35 2006
@@ -1,244 +1,244 @@
-/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.io;
-
-
-/**
- * StringWriter is an class for writing Character Streams to a StringBuffer. The
- * characters written can then be returned as a String. This is used for
- * capturing output sent to a Writer by substituting a StringWriter.
- * 
- * @see StringReader
- */
-public class StringWriter extends Writer {
-	private StringBuffer buf;
-
-	/**
-	 * Constructs a new StringWriter which has a StringBuffer allocated with the
-	 * default size of 16 characters. The StringBuffer is also the
-	 * <code>lock</code> used to synchronize access to this Writer.
-	 */
-	public StringWriter() {
-		super();
-		buf = new StringBuffer(16);
-		lock = buf;
-	}
-
-	/**
-	 * Constructs a new StringWriter which has a StringBuffer allocated with the
-	 * size of <code>initialSize</code> characters. The StringBuffer is also
-	 * the <code>lock</code> used to synchronize access to this Writer.
-	 * 
-	 * @param initialSize
-	 *            the intial number of characters
-	 */
-	public StringWriter(int initialSize) {
-		if (initialSize >= 0) {
-			buf = new StringBuffer(initialSize);
-			lock = buf;
-		} else
-			throw new IllegalArgumentException();
-	}
-
-	/**
-	 * Close this Writer. This is the concrete implementation required. This
-	 * particular implementation does nothing.
-	 * 
-	 * @throws IOException
-	 *             If an IO error occurs closing this StringWriter.
-	 */
-	public void close() throws IOException {
-		/*empty*/
-	}
-
-	/**
-	 * Flush this Writer. This is the concrete implementation required. This
-	 * particular implementation does nothing.
-	 */
-	public void flush() {
-		/*empty*/
-	}
-
-	/**
-	 * Answer the contents of this StringWriter as a StringBuffer. Any changes
-	 * made to the StringBuffer by the receiver or the caller are reflected in
-	 * this StringWriter.
-	 * 
-	 * @return this StringWriters local StringBuffer.
-	 */
-	public StringBuffer getBuffer() {
-		synchronized (lock) {
-			return buf;
-		}
-	}
-
-	/**
-	 * Answer the contents of this StringWriter as a String. Any changes made to
-	 * the StringBuffer by the receiver after returning will not be reflected in
-	 * the String returned to the caller.
-	 * 
-	 * @return this StringWriters current contents as a String.
-	 */
-	public String toString() {
-		synchronized (lock) {
-			return buf.toString();
-		}
-	}
-
-	/**
-	 * Writes <code>count</code> characters starting at <code>offset</code>
-	 * in <code>cbuf</code> to this StringWriter.
-	 * 
-	 * @param cbuf
-	 *            the non-null array containing characters to write.
-	 * @param offset
-	 *            offset in buf to retrieve characters
-	 * @param count
-	 *            maximum number of characters to write
-	 * 
-	 * @throws ArrayIndexOutOfBoundsException
-	 *             If offset or count are outside of bounds.
-	 */
-	public void write(char[] cbuf, int offset, int count) {
-		// avoid int overflow
-		if (0 <= offset && offset <= cbuf.length && 0 <= count
-				&& count <= cbuf.length - offset) {
-			synchronized (lock) {
-				this.buf.append(cbuf, offset, count);
-			}
-		} else {
-			throw new IndexOutOfBoundsException();
-		}
-	}
-
-	/**
-	 * Writes the specified character <code>oneChar</code> to this
-	 * StringWriter. This implementation writes the low order two bytes to the
-	 * Stream.
-	 * 
-	 * @param oneChar
-	 *            The character to write
-	 * 
-	 */
-	public void write(int oneChar) {
-		synchronized (lock) {
-			buf.append((char) oneChar);
-		}
-	}
-
-	/**
-	 * Writes the characters from the String <code>str</code> to this
-	 * StringWriter.
-	 * 
-	 * @param str
-	 *            the non-null String containing the characters to write.
-	 * 
-	 */
-	public void write(String str) {
-		synchronized (lock) {
-			buf.append(str);
-		}
-	}
-
-	/**
-	 * Writes <code>count</code> number of characters starting at
-	 * <code>offset</code> from the String <code>str</code> to this
-	 * StringWriter.
-	 * 
-	 * @param str
-	 *            the non-null String containing the characters to write.
-	 * @param offset
-	 *            the starting point to retrieve characters.
-	 * @param count
-	 *            the number of characters to retrieve and write.
-	 * 
-	 * @throws ArrayIndexOutOfBoundsException
-	 *             If offset or count are outside of bounds.
-	 */
-	public void write(String str, int offset, int count) {
-		String sub = str.substring(offset, offset + count);
-		synchronized (lock) {
-			buf.append(sub);
-		}
-	}
-	
-	/**
-	 * Append a char <code>c</code>to the StringWriter. The
-	 * StringWriter.append(<code>c</code>) works the same way as
-	 * StringWriter.write(<code>c</code>).
-	 * 
-	 * @override Writer.append
-	 * @param c
-	 *            The character appended to the StringWriter.
-	 * @return The StringWriter.
-	 */
-	public StringWriter append(char c) {
-		write(c);
-		return this;
-	}
-
-	/**
-	 * Append a CharSequence <code>csq</code> to the StringWriter. The
-	 * StringWriter.append(<code>csq</code>) works the same way as
-	 * StringWriter.write(<code>csq</code>.toString()). If <code>csq</code>
-	 * is null, then "null" will be substituted for <code>csq</code>.
-	 * 
-	 * @override Writer.append
-	 * @param csq
-	 *            The CharSequence appended to the StringWriter.
-	 * @return The StringWriter
-	 */
-	public StringWriter append(CharSequence csq) {
-		if (null == csq) {
-			append(TOKEN_NULL, 0, TOKEN_NULL.length());
-		} else {
-			append(csq, 0, csq.length());
-		}
-		return this;
-	}
-
-	/**
-	 * Append a subsequence of a CharSequence <code>csq</code> to the
-	 * StringWriter. The first char and the last char of the subsequnce is
-	 * specified by the parameter <code>start</code> and <code>end</code>.
-	 * The StringWriter.append(<code>csq</code>) works the same way as
-	 * StringWriter.write(<code>csq</code>.subSequence(<code>start</code>,<code>end</code>).toString).If
-	 * <code>csq</code> is null, then "null" will be substituted for
-	 * <code>csq</code>.
-	 * 
-	 * @override Writer.append
-	 * @param csq
-	 *            The CharSequence appended to the StringWriter.
-	 * @param start
-	 *            The index of the first char in the CharSequence appended to
-	 *            the StringWriter.
-	 * @param end
-	 *            The index of the char after the last one in the CharSequence
-	 *            appended to the StringWriter.
-	 * @return The StringWriter.
-	 * @throws IndexOutOfBoundsException
-	 *             If start is less than end, end is greater than the length of
-	 *             the CharSequence, or start or end is negative.
-	 */
-	public StringWriter append(CharSequence csq, int start, int end) {
-		if (null == csq) {
-			csq = TOKEN_NULL;
-		}
-		String output = csq.subSequence(start, end).toString();
-		write(output, 0, output.length());
-		return this;
-	}
-}
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+
+/**
+ * StringWriter is an class for writing Character Streams to a StringBuffer. The
+ * characters written can then be returned as a String. This is used for
+ * capturing output sent to a Writer by substituting a StringWriter.
+ * 
+ * @see StringReader
+ */
+public class StringWriter extends Writer {
+	private StringBuffer buf;
+
+	/**
+	 * Constructs a new StringWriter which has a StringBuffer allocated with the
+	 * default size of 16 characters. The StringBuffer is also the
+	 * <code>lock</code> used to synchronize access to this Writer.
+	 */
+	public StringWriter() {
+		super();
+		buf = new StringBuffer(16);
+		lock = buf;
+	}
+
+	/**
+	 * Constructs a new StringWriter which has a StringBuffer allocated with the
+	 * size of <code>initialSize</code> characters. The StringBuffer is also
+	 * the <code>lock</code> used to synchronize access to this Writer.
+	 * 
+	 * @param initialSize
+	 *            the intial number of characters
+	 */
+	public StringWriter(int initialSize) {
+		if (initialSize >= 0) {
+			buf = new StringBuffer(initialSize);
+			lock = buf;
+		} else
+			throw new IllegalArgumentException();
+	}
+
+	/**
+	 * Close this Writer. This is the concrete implementation required. This
+	 * particular implementation does nothing.
+	 * 
+	 * @throws IOException
+	 *             If an IO error occurs closing this StringWriter.
+	 */
+	public void close() throws IOException {
+		/*empty*/
+	}
+
+	/**
+	 * Flush this Writer. This is the concrete implementation required. This
+	 * particular implementation does nothing.
+	 */
+	public void flush() {
+		/*empty*/
+	}
+
+	/**
+	 * Answer the contents of this StringWriter as a StringBuffer. Any changes
+	 * made to the StringBuffer by the receiver or the caller are reflected in
+	 * this StringWriter.
+	 * 
+	 * @return this StringWriters local StringBuffer.
+	 */
+	public StringBuffer getBuffer() {
+		synchronized (lock) {
+			return buf;
+		}
+	}
+
+	/**
+	 * Answer the contents of this StringWriter as a String. Any changes made to
+	 * the StringBuffer by the receiver after returning will not be reflected in
+	 * the String returned to the caller.
+	 * 
+	 * @return this StringWriters current contents as a String.
+	 */
+	public String toString() {
+		synchronized (lock) {
+			return buf.toString();
+		}
+	}
+
+	/**
+	 * Writes <code>count</code> characters starting at <code>offset</code>
+	 * in <code>cbuf</code> to this StringWriter.
+	 * 
+	 * @param cbuf
+	 *            the non-null array containing characters to write.
+	 * @param offset
+	 *            offset in buf to retrieve characters
+	 * @param count
+	 *            maximum number of characters to write
+	 * 
+	 * @throws ArrayIndexOutOfBoundsException
+	 *             If offset or count are outside of bounds.
+	 */
+	public void write(char[] cbuf, int offset, int count) {
+		// avoid int overflow
+		if (0 <= offset && offset <= cbuf.length && 0 <= count
+				&& count <= cbuf.length - offset) {
+			synchronized (lock) {
+				this.buf.append(cbuf, offset, count);
+			}
+		} else {
+			throw new IndexOutOfBoundsException();
+		}
+	}
+
+	/**
+	 * Writes the specified character <code>oneChar</code> to this
+	 * StringWriter. This implementation writes the low order two bytes to the
+	 * Stream.
+	 * 
+	 * @param oneChar
+	 *            The character to write
+	 * 
+	 */
+	public void write(int oneChar) {
+		synchronized (lock) {
+			buf.append((char) oneChar);
+		}
+	}
+
+	/**
+	 * Writes the characters from the String <code>str</code> to this
+	 * StringWriter.
+	 * 
+	 * @param str
+	 *            the non-null String containing the characters to write.
+	 * 
+	 */
+	public void write(String str) {
+		synchronized (lock) {
+			buf.append(str);
+		}
+	}
+
+	/**
+	 * Writes <code>count</code> number of characters starting at
+	 * <code>offset</code> from the String <code>str</code> to this
+	 * StringWriter.
+	 * 
+	 * @param str
+	 *            the non-null String containing the characters to write.
+	 * @param offset
+	 *            the starting point to retrieve characters.
+	 * @param count
+	 *            the number of characters to retrieve and write.
+	 * 
+	 * @throws ArrayIndexOutOfBoundsException
+	 *             If offset or count are outside of bounds.
+	 */
+	public void write(String str, int offset, int count) {
+		String sub = str.substring(offset, offset + count);
+		synchronized (lock) {
+			buf.append(sub);
+		}
+	}
+	
+	/**
+	 * Append a char <code>c</code>to the StringWriter. The
+	 * StringWriter.append(<code>c</code>) works the same way as
+	 * StringWriter.write(<code>c</code>).
+	 * 
+	 * @override Writer.append
+	 * @param c
+	 *            The character appended to the StringWriter.
+	 * @return The StringWriter.
+	 */
+	public StringWriter append(char c) {
+		write(c);
+		return this;
+	}
+
+	/**
+	 * Append a CharSequence <code>csq</code> to the StringWriter. The
+	 * StringWriter.append(<code>csq</code>) works the same way as
+	 * StringWriter.write(<code>csq</code>.toString()). If <code>csq</code>
+	 * is null, then "null" will be substituted for <code>csq</code>.
+	 * 
+	 * @override Writer.append
+	 * @param csq
+	 *            The CharSequence appended to the StringWriter.
+	 * @return The StringWriter
+	 */
+	public StringWriter append(CharSequence csq) {
+		if (null == csq) {
+			append(TOKEN_NULL, 0, TOKEN_NULL.length());
+		} else {
+			append(csq, 0, csq.length());
+		}
+		return this;
+	}
+
+	/**
+	 * Append a subsequence of a CharSequence <code>csq</code> to the
+	 * StringWriter. The first char and the last char of the subsequnce is
+	 * specified by the parameter <code>start</code> and <code>end</code>.
+	 * The StringWriter.append(<code>csq</code>) works the same way as
+	 * StringWriter.write(<code>csq</code>.subSequence(<code>start</code>,<code>end</code>).toString).If
+	 * <code>csq</code> is null, then "null" will be substituted for
+	 * <code>csq</code>.
+	 * 
+	 * @override Writer.append
+	 * @param csq
+	 *            The CharSequence appended to the StringWriter.
+	 * @param start
+	 *            The index of the first char in the CharSequence appended to
+	 *            the StringWriter.
+	 * @param end
+	 *            The index of the char after the last one in the CharSequence
+	 *            appended to the StringWriter.
+	 * @return The StringWriter.
+	 * @throws IndexOutOfBoundsException
+	 *             If start is less than end, end is greater than the length of
+	 *             the CharSequence, or start or end is negative.
+	 */
+	public StringWriter append(CharSequence csq, int start, int end) {
+		if (null == csq) {
+			csq = TOKEN_NULL;
+		}
+		String output = csq.subSequence(start, end).toString();
+		write(output, 0, output.length());
+		return this;
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SyncFailedException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SyncFailedException.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SyncFailedException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SyncFailedException.java Thu Aug 17 18:45:35 2006
@@ -1,40 +1,40 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.io;
-
-
-/**
- * This IO exception is thrown when the method <code>sync()</code> in
- * FileDescriptor failed to complete.
- * 
- * @see FileDescriptor#sync()
- */
-public class SyncFailedException extends IOException {
-
-    private static final long serialVersionUID = -2353342684412443330L;
-    
-	/**
-	 * Constructs a new instance of this class with its walkback and message
-	 * filled in.
-	 * 
-	 * @param detailMessage
-	 *            the detail message for the exception.
-	 */
-	public SyncFailedException(String detailMessage) {
-		super(detailMessage);
-	}
-
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+
+/**
+ * This IO exception is thrown when the method <code>sync()</code> in
+ * FileDescriptor failed to complete.
+ * 
+ * @see FileDescriptor#sync()
+ */
+public class SyncFailedException extends IOException {
+
+    private static final long serialVersionUID = -2353342684412443330L;
+    
+	/**
+	 * Constructs a new instance of this class with its walkback and message
+	 * filled in.
+	 * 
+	 * @param detailMessage
+	 *            the detail message for the exception.
+	 */
+	public SyncFailedException(String detailMessage) {
+		super(detailMessage);
+	}
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SyncFailedException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/UTFDataFormatException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/UTFDataFormatException.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/UTFDataFormatException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/UTFDataFormatException.java Thu Aug 17 18:45:35 2006
@@ -1,47 +1,47 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.io;
-
-
-/**
- * This IO exception is thrown when a program attempts to read a UTF-8 String
- * and the encoding is incorrect.
- * 
- * @see DataInputStream#readUTF()
- */
-public class UTFDataFormatException extends IOException {
-
-    private static final long serialVersionUID = 420743449228280612L;
-    
-	/**
-	 * Constructs a new instance of this class with its walkback filled in.
-	 */
-	public UTFDataFormatException() {
-		super();
-	}
-
-	/**
-	 * Constructs a new instance of this class with its walkback and message
-	 * filled in.
-	 * 
-	 * @param detailMessage
-	 *            the detail message for the exception.
-	 */
-	public UTFDataFormatException(String detailMessage) {
-		super(detailMessage);
-	}
-
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+
+/**
+ * This IO exception is thrown when a program attempts to read a UTF-8 String
+ * and the encoding is incorrect.
+ * 
+ * @see DataInputStream#readUTF()
+ */
+public class UTFDataFormatException extends IOException {
+
+    private static final long serialVersionUID = 420743449228280612L;
+    
+	/**
+	 * Constructs a new instance of this class with its walkback filled in.
+	 */
+	public UTFDataFormatException() {
+		super();
+	}
+
+	/**
+	 * Constructs a new instance of this class with its walkback and message
+	 * filled in.
+	 * 
+	 * @param detailMessage
+	 *            the detail message for the exception.
+	 */
+	public UTFDataFormatException(String detailMessage) {
+		super(detailMessage);
+	}
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/UTFDataFormatException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/UnsupportedEncodingException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/UnsupportedEncodingException.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/UnsupportedEncodingException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/UnsupportedEncodingException.java Thu Aug 17 18:45:35 2006
@@ -1,45 +1,45 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.io;
-
-/**
- * This IO exception is thrown when a program asks for a particular character
- * converter and it is not available.
- * 
- */
-public class UnsupportedEncodingException extends IOException {
-
-    private static final long serialVersionUID = -4274276298326136670L;
-    
-	/**
-	 * Constructs a new instance of this class with its walkback filled in.
-	 */
-	public UnsupportedEncodingException() {
-		super();
-	}
-
-	/**
-	 * Constructs a new instance of this class with its walkback and message
-	 * filled in.
-	 * 
-	 * @param detailMessage
-	 *            the detail message for the exception.
-	 */
-	public UnsupportedEncodingException(String detailMessage) {
-		super(detailMessage);
-	}
-
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+/**
+ * This IO exception is thrown when a program asks for a particular character
+ * converter and it is not available.
+ * 
+ */
+public class UnsupportedEncodingException extends IOException {
+
+    private static final long serialVersionUID = -4274276298326136670L;
+    
+	/**
+	 * Constructs a new instance of this class with its walkback filled in.
+	 */
+	public UnsupportedEncodingException() {
+		super();
+	}
+
+	/**
+	 * Constructs a new instance of this class with its walkback and message
+	 * filled in.
+	 * 
+	 * @param detailMessage
+	 *            the detail message for the exception.
+	 */
+	public UnsupportedEncodingException(String detailMessage) {
+		super(detailMessage);
+	}
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/UnsupportedEncodingException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/WriteAbortedException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/WriteAbortedException.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/WriteAbortedException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/WriteAbortedException.java Thu Aug 17 18:45:35 2006
@@ -1,78 +1,78 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.io;
-
-
-/**
- * This type of exception is thrown by readObject() when it detects an exception
- * marker in the input stream. This marker indicates that when the object was
- * being serialized, an exception happened and this marker was inserted instead
- * of the original object. It is a way to "propagate" an exception from the code
- * that attempted to write the object to the code that is attempting to read the
- * object.
- * 
- * @see ObjectInputStream#readObject()
- */
-public class WriteAbortedException extends ObjectStreamException {
-
-	private static final long serialVersionUID = -3326426625597282442L;
-
-	/**
-	 * The exception that was caused when writeObject() was attempting to
-	 * serialize the object
-	 */
-	public Exception detail;
-
-	/**
-	 * Constructs a new instance of this class with its walkback, message and
-	 * the exception which caused the underlying problem when serializing the
-	 * object filled in.
-	 * 
-	 * @param detailMessage
-	 *            the detail message for the exception.
-	 * @param rootCause
-	 *            exception that caused the problem when serializing the object.
-	 */
-	public WriteAbortedException(String detailMessage, Exception rootCause) {
-		super(detailMessage);
-		detail = rootCause;
-		initCause(rootCause);
-	}
-
-	/**
-	 * Answers the extra information message which was provided when the
-	 * throwable was created. If no message was provided at creation time, then
-	 * answer null.
-	 * 
-	 * @return the receiver's message.
-	 */
-	public String getMessage() {
-		String msg = super.getMessage();
-		if (detail != null) {
-			msg = msg + "; " + detail.toString(); //$NON-NLS-1$
-		}
-		return msg;
-	}
-
-	/**
-	 * Answers the cause of this Throwable, or null if there is no cause.
-	 * 
-	 * @return the receiver's cause.
-	 */
-	public Throwable getCause() {
-		return detail;
-	}
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+
+/**
+ * This type of exception is thrown by readObject() when it detects an exception
+ * marker in the input stream. This marker indicates that when the object was
+ * being serialized, an exception happened and this marker was inserted instead
+ * of the original object. It is a way to "propagate" an exception from the code
+ * that attempted to write the object to the code that is attempting to read the
+ * object.
+ * 
+ * @see ObjectInputStream#readObject()
+ */
+public class WriteAbortedException extends ObjectStreamException {
+
+	private static final long serialVersionUID = -3326426625597282442L;
+
+	/**
+	 * The exception that was caused when writeObject() was attempting to
+	 * serialize the object
+	 */
+	public Exception detail;
+
+	/**
+	 * Constructs a new instance of this class with its walkback, message and
+	 * the exception which caused the underlying problem when serializing the
+	 * object filled in.
+	 * 
+	 * @param detailMessage
+	 *            the detail message for the exception.
+	 * @param rootCause
+	 *            exception that caused the problem when serializing the object.
+	 */
+	public WriteAbortedException(String detailMessage, Exception rootCause) {
+		super(detailMessage);
+		detail = rootCause;
+		initCause(rootCause);
+	}
+
+	/**
+	 * Answers the extra information message which was provided when the
+	 * throwable was created. If no message was provided at creation time, then
+	 * answer null.
+	 * 
+	 * @return the receiver's message.
+	 */
+	public String getMessage() {
+		String msg = super.getMessage();
+		if (detail != null) {
+			msg = msg + "; " + detail.toString(); //$NON-NLS-1$
+		}
+		return msg;
+	}
+
+	/**
+	 * Answers the cause of this Throwable, or null if there is no cause.
+	 * 
+	 * @return the receiver's cause.
+	 */
+	public Throwable getCause() {
+		return detail;
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/WriteAbortedException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java Thu Aug 17 18:45:35 2006
@@ -1,241 +1,241 @@
-/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.io;
-
-/**
- * Writer is an Abstract class for writing Character Streams. Subclasses of
- * writer must implement the methods <code>write(char[], int, int)</code>,
- * <code>close()</code> and <code>flush()</code>.
- * 
- * @see Reader
- */
-public abstract class Writer implements Appendable, Closeable, Flushable {
-
-    static final String TOKEN_NULL = "null"; //$NON-NLS-1$
-
-    /** The object used to synchronize access to the writer. */
-    protected Object lock;
-
-    /**
-     * Constructs a new character stream Writer using <code>this</code> as the
-     * Object to synchronize critical regions around.
-     * 
-     */
-    protected Writer() {
-        super();
-        lock = this;
-    }
-
-    /**
-     * Constructs a new character stream Writer using <code>lock</code> as the
-     * Object to synchronize critical regions around.
-     * 
-     * @param lock
-     *            the Object to synchronize critical regions around.
-     */
-    protected Writer(Object lock) {
-        if (lock != null) {
-            this.lock = lock;
-        } else {
-            throw new NullPointerException();
-        }
-    }
-
-    /**
-     * Close this Writer. This must be implemented by any concrete subclasses.
-     * The implementation should free any resources associated with the Writer.
-     * 
-     * @throws IOException
-     *             If an error occurs attempting to close this Writer.
-     */
-    public abstract void close() throws IOException;
-
-    /**
-     * Flush this Writer. This must be implemented by any concrete subclasses.
-     * The implementation should ensure all buffered characters are written out.
-     * 
-     * @throws IOException
-     *             If an error occurs attempting to flush this Writer.
-     */
-    public abstract void flush() throws IOException;
-
-    /**
-     * Writes the entire character buffer <code>buf</code> to this Writer.
-     * 
-     * @param buf
-     *            the non-null array containing characters to write.
-     * 
-     * @throws IOException
-     *             If this Writer has already been closed or some other
-     *             IOException occurs.
-     */
-    public void write(char buf[]) throws IOException {
-        write(buf, 0, buf.length);
-    }
-
-    /**
-     * Writes <code>count</code> characters starting at <code>offset<code> in
-     * <code>buf</code> to this Writer.  This abstract method must be implemented
-     * by concrete subclasses.
-     *
-     * @param 		buf			the non-null array containing characters to write.
-     * @param 		offset 		offset in buf to retrieve characters
-     * @param 		count 		maximum number of characters to write
-     *
-     * @throws 		IOException 					If this Writer has already been closed or some other IOException occurs.
-     * @throws		ArrayIndexOutOfBoundsException 	If offset or count are outside of bounds.
-     */
-    public abstract void write(char buf[], int offset, int count)
-            throws IOException;
-
-    /**
-     * Writes the specified character <code>oneChar</code> to this Writer.
-     * This implementation writes the low order two bytes of
-     * <code>oneChar</code> to the Stream.
-     * 
-     * @param oneChar
-     *            The character to write
-     * 
-     * @throws IOException
-     *             If this Writer has already been closed or some other
-     *             IOException occurs.
-     */
-    public void write(int oneChar) throws IOException {
-        synchronized (lock) {
-            char oneCharArray[] = new char[1];
-            oneCharArray[0] = (char) oneChar;
-            write(oneCharArray);
-        }
-    }
-
-    /**
-     * Writes the characters from the String <code>str</code> to this Writer.
-     * 
-     * @param str
-     *            the non-null String containing the characters to write.
-     * 
-     * @throws IOException
-     *             If this Writer has already been closed or some other
-     *             IOException occurs.
-     */
-    public void write(String str) throws IOException {
-        char buf[] = new char[str.length()];
-        str.getChars(0, buf.length, buf, 0);
-        synchronized (lock) {
-            write(buf);
-        }
-    }
-
-    /**
-     * Writes <code>count</code> number of characters starting at
-     * <code>offset</code> from the String <code>str</code> to this Writer.
-     * 
-     * @param str
-     *            the non-null String containing the characters to write.
-     * @param offset
-     *            the starting point to retrieve characters.
-     * @param count
-     *            the number of characters to retrieve and write.
-     * 
-     * @throws IOException
-     *             If this Writer has already been closed or some other
-     *             IOException occurs.
-     * @throws ArrayIndexOutOfBoundsException
-     *             If offset or count are outside of bounds.
-     */
-    public void write(String str, int offset, int count) throws IOException {
-        if (count >= 0) { // other cases tested by getChars()
-            char buf[] = new char[count];
-            str.getChars(offset, offset + count, buf, 0);
-
-            synchronized (lock) {
-                write(buf);
-            }
-        } else {
-            throw new StringIndexOutOfBoundsException();
-        }
-    }
-
-    /**
-     * Append a char <code>c</code>to the Writer. The Writer.append(<code>c</code>)
-     * works the same as Writer.write(<code>c</code>).
-     * 
-     * @param c
-     *            The character appended to the Writer.
-     * @return The Writer.
-     * @throws IOException
-     *             If any IOException raises during the procedure.
-     */
-    public Writer append(char c) throws IOException {
-        write(c);
-        return this;
-    }
-
-    /**
-     * Append a CharSequence <code>csq</code> to the Writer. The
-     * Writer.append(<code>csq</code>) works the same way as Writer.write(<code>csq</code>.toString()).
-     * If <code>csq</code> is null, then "null" will be substituted for
-     * <code>csq</code>.
-     * 
-     * @param csq
-     *            The CharSequence appended to the Writer.
-     * @return The Writer.
-     * @throws IOException
-     *             If any IOException raises during the procedure.
-     */
-    public Writer append(CharSequence csq) throws IOException {
-        if (null == csq) {
-            write(TOKEN_NULL);
-        } else {
-            write(csq.toString());
-        }
-        return this;
-    }
-
-    /**
-     * Append a subsequence of a CharSequence <code>csq</code> to the Writer.
-     * The first char and the last char of the subsequnce is specified by the
-     * parameter <code>start</code> and <code>end</code>. The
-     * Writer.append(<code>csq</code>) works the same way as Writer.write (<code>csq</code>csq.subSequence(<code>start</code>,<code>end</code>).toString).
-     * If <code>csq</code> is null, then "null" will be substituted for
-     * <code>csq</code>.
-     * 
-     * @param csq
-     *            The CharSequence appended to the Writaer.
-     * @param start
-     *            The index of the first char in the CharSequence appended to
-     *            the Writer.
-     * @param end
-     *            The index of the char after the last one in the CharSequence
-     *            appended to the Writer.
-     * @return The Writer.
-     * @throws IndexOutOfBoundsException
-     *             If start is less than end, end is greater than the length of
-     *             the CharSequence, or start or end is negative.
-     * @throws IOException
-     *             If any IOException raises during the procedure.
-     */
-    public Writer append(CharSequence csq, int start, int end)
-            throws IOException {
-        if (null == csq) {
-            write(TOKEN_NULL.substring(start, end));
-        } else {
-            write(csq.subSequence(start, end).toString());
-        }
-        return this;
-    }
-
-}
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+/**
+ * Writer is an Abstract class for writing Character Streams. Subclasses of
+ * writer must implement the methods <code>write(char[], int, int)</code>,
+ * <code>close()</code> and <code>flush()</code>.
+ * 
+ * @see Reader
+ */
+public abstract class Writer implements Appendable, Closeable, Flushable {
+
+    static final String TOKEN_NULL = "null"; //$NON-NLS-1$
+
+    /** The object used to synchronize access to the writer. */
+    protected Object lock;
+
+    /**
+     * Constructs a new character stream Writer using <code>this</code> as the
+     * Object to synchronize critical regions around.
+     * 
+     */
+    protected Writer() {
+        super();
+        lock = this;
+    }
+
+    /**
+     * Constructs a new character stream Writer using <code>lock</code> as the
+     * Object to synchronize critical regions around.
+     * 
+     * @param lock
+     *            the Object to synchronize critical regions around.
+     */
+    protected Writer(Object lock) {
+        if (lock != null) {
+            this.lock = lock;
+        } else {
+            throw new NullPointerException();
+        }
+    }
+
+    /**
+     * Close this Writer. This must be implemented by any concrete subclasses.
+     * The implementation should free any resources associated with the Writer.
+     * 
+     * @throws IOException
+     *             If an error occurs attempting to close this Writer.
+     */
+    public abstract void close() throws IOException;
+
+    /**
+     * Flush this Writer. This must be implemented by any concrete subclasses.
+     * The implementation should ensure all buffered characters are written out.
+     * 
+     * @throws IOException
+     *             If an error occurs attempting to flush this Writer.
+     */
+    public abstract void flush() throws IOException;
+
+    /**
+     * Writes the entire character buffer <code>buf</code> to this Writer.
+     * 
+     * @param buf
+     *            the non-null array containing characters to write.
+     * 
+     * @throws IOException
+     *             If this Writer has already been closed or some other
+     *             IOException occurs.
+     */
+    public void write(char buf[]) throws IOException {
+        write(buf, 0, buf.length);
+    }
+
+    /**
+     * Writes <code>count</code> characters starting at <code>offset<code> in
+     * <code>buf</code> to this Writer.  This abstract method must be implemented
+     * by concrete subclasses.
+     *
+     * @param 		buf			the non-null array containing characters to write.
+     * @param 		offset 		offset in buf to retrieve characters
+     * @param 		count 		maximum number of characters to write
+     *
+     * @throws 		IOException 					If this Writer has already been closed or some other IOException occurs.
+     * @throws		ArrayIndexOutOfBoundsException 	If offset or count are outside of bounds.
+     */
+    public abstract void write(char buf[], int offset, int count)
+            throws IOException;
+
+    /**
+     * Writes the specified character <code>oneChar</code> to this Writer.
+     * This implementation writes the low order two bytes of
+     * <code>oneChar</code> to the Stream.
+     * 
+     * @param oneChar
+     *            The character to write
+     * 
+     * @throws IOException
+     *             If this Writer has already been closed or some other
+     *             IOException occurs.
+     */
+    public void write(int oneChar) throws IOException {
+        synchronized (lock) {
+            char oneCharArray[] = new char[1];
+            oneCharArray[0] = (char) oneChar;
+            write(oneCharArray);
+        }
+    }
+
+    /**
+     * Writes the characters from the String <code>str</code> to this Writer.
+     * 
+     * @param str
+     *            the non-null String containing the characters to write.
+     * 
+     * @throws IOException
+     *             If this Writer has already been closed or some other
+     *             IOException occurs.
+     */
+    public void write(String str) throws IOException {
+        char buf[] = new char[str.length()];
+        str.getChars(0, buf.length, buf, 0);
+        synchronized (lock) {
+            write(buf);
+        }
+    }
+
+    /**
+     * Writes <code>count</code> number of characters starting at
+     * <code>offset</code> from the String <code>str</code> to this Writer.
+     * 
+     * @param str
+     *            the non-null String containing the characters to write.
+     * @param offset
+     *            the starting point to retrieve characters.
+     * @param count
+     *            the number of characters to retrieve and write.
+     * 
+     * @throws IOException
+     *             If this Writer has already been closed or some other
+     *             IOException occurs.
+     * @throws ArrayIndexOutOfBoundsException
+     *             If offset or count are outside of bounds.
+     */
+    public void write(String str, int offset, int count) throws IOException {
+        if (count >= 0) { // other cases tested by getChars()
+            char buf[] = new char[count];
+            str.getChars(offset, offset + count, buf, 0);
+
+            synchronized (lock) {
+                write(buf);
+            }
+        } else {
+            throw new StringIndexOutOfBoundsException();
+        }
+    }
+
+    /**
+     * Append a char <code>c</code>to the Writer. The Writer.append(<code>c</code>)
+     * works the same as Writer.write(<code>c</code>).
+     * 
+     * @param c
+     *            The character appended to the Writer.
+     * @return The Writer.
+     * @throws IOException
+     *             If any IOException raises during the procedure.
+     */
+    public Writer append(char c) throws IOException {
+        write(c);
+        return this;
+    }
+
+    /**
+     * Append a CharSequence <code>csq</code> to the Writer. The
+     * Writer.append(<code>csq</code>) works the same way as Writer.write(<code>csq</code>.toString()).
+     * If <code>csq</code> is null, then "null" will be substituted for
+     * <code>csq</code>.
+     * 
+     * @param csq
+     *            The CharSequence appended to the Writer.
+     * @return The Writer.
+     * @throws IOException
+     *             If any IOException raises during the procedure.
+     */
+    public Writer append(CharSequence csq) throws IOException {
+        if (null == csq) {
+            write(TOKEN_NULL);
+        } else {
+            write(csq.toString());
+        }
+        return this;
+    }
+
+    /**
+     * Append a subsequence of a CharSequence <code>csq</code> to the Writer.
+     * The first char and the last char of the subsequnce is specified by the
+     * parameter <code>start</code> and <code>end</code>. The
+     * Writer.append(<code>csq</code>) works the same way as Writer.write (<code>csq</code>csq.subSequence(<code>start</code>,<code>end</code>).toString).
+     * If <code>csq</code> is null, then "null" will be substituted for
+     * <code>csq</code>.
+     * 
+     * @param csq
+     *            The CharSequence appended to the Writaer.
+     * @param start
+     *            The index of the first char in the CharSequence appended to
+     *            the Writer.
+     * @param end
+     *            The index of the char after the last one in the CharSequence
+     *            appended to the Writer.
+     * @return The Writer.
+     * @throws IndexOutOfBoundsException
+     *             If start is less than end, end is greater than the length of
+     *             the CharSequence, or start or end is negative.
+     * @throws IOException
+     *             If any IOException raises during the procedure.
+     */
+    public Writer append(CharSequence csq, int start, int end)
+            throws IOException {
+        if (null == csq) {
+            write(TOKEN_NULL.substring(start, end));
+        } else {
+            write(csq.subSequence(start, end).toString());
+        }
+        return this;
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java
------------------------------------------------------------------------------
    svn:eol-style = native