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 2007/01/04 18:47:05 UTC

svn commit: r492652 [9/13] - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java Thu Jan  4 09:47:01 2007
@@ -28,317 +28,318 @@
  * 
  * @see ObjectOutputStream#writeFields()
  * @see ObjectInputStream#readFields()
- * 
  */
 public class ObjectStreamField implements Comparable<Object> {
 
-	// Declared name of the field
-	private String name;
+    // Declared name of the field
+    private String name;
 
-	// Declared type of the field
-	private Object type;
+    // Declared type of the field
+    private Object type;
 
-	// offset of this field in the object
-	int offset;
+    // offset of this field in the object
+    int offset;
 
-	// Cached version of intern'ed type String
-	private String typeString;
+    // Cached version of intern'ed type String
+    private String typeString;
+
+    private boolean unshared;
 
-	private boolean unshared;
-    
     private boolean isDeserialized;
 
-	/**
-	 * Constructs an ObjectStreamField with the given name and the given type
-	 * 
-	 * @param name
-	 *            a String, the name of the field
-	 * @param cl
-	 *            A Class object representing the type of the field
-	 */
-	public ObjectStreamField(String name, Class<?> cl) {
-		if (name == null || cl == null) {
-			throw new NullPointerException();
-		}
-		this.name = name;
-		this.type = new WeakReference<Class<?>>(cl);
-	}
-
-	/**
-	 * Constructs an ObjectStreamField with the given name and the given type
-	 * 
-	 * @param name
-	 *            a String, the name of the field
-	 * @param cl
-	 *            A Class object representing the type of the field
-	 * @param unshared
-	 *            write and read the field unshared
-	 */
-	public ObjectStreamField(String name, Class<?> cl, boolean unshared) {
-		if (name == null || cl == null) {
-			throw new NullPointerException();
-		}
-		this.name = name;
-		this.type = (cl.getClassLoader() == null) ? cl
-				: new WeakReference<Class<?>>(cl);
-		this.unshared = unshared;
-	}
-
-	/**
-	 * Constructs an ObjectStreamField with the given name and the given type.
-	 * The type may be null.
-	 * 
-	 * @param signature
-	 *            A String representing the type of the field
-	 * @param name
-	 *            a String, the name of the field, or null
-	 */
-	ObjectStreamField(String signature, String name) {
-		if (name == null) {
-			throw new NullPointerException();
-		}
-		this.name = name;
-		this.typeString = signature.replace('.', '/');
+    /**
+     * Constructs an ObjectStreamField with the given name and the given type
+     * 
+     * @param name
+     *            a String, the name of the field
+     * @param cl
+     *            A Class object representing the type of the field
+     */
+    public ObjectStreamField(String name, Class<?> cl) {
+        if (name == null || cl == null) {
+            throw new NullPointerException();
+        }
+        this.name = name;
+        this.type = new WeakReference<Class<?>>(cl);
+    }
+
+    /**
+     * Constructs an ObjectStreamField with the given name and the given type
+     * 
+     * @param name
+     *            a String, the name of the field
+     * @param cl
+     *            A Class object representing the type of the field
+     * @param unshared
+     *            write and read the field unshared
+     */
+    public ObjectStreamField(String name, Class<?> cl, boolean unshared) {
+        if (name == null || cl == null) {
+            throw new NullPointerException();
+        }
+        this.name = name;
+        this.type = (cl.getClassLoader() == null) ? cl
+                : new WeakReference<Class<?>>(cl);
+        this.unshared = unshared;
+    }
+
+    /**
+     * Constructs an ObjectStreamField with the given name and the given type.
+     * The type may be null.
+     * 
+     * @param signature
+     *            A String representing the type of the field
+     * @param name
+     *            a String, the name of the field, or null
+     */
+    ObjectStreamField(String signature, String name) {
+        if (name == null) {
+            throw new NullPointerException();
+        }
+        this.name = name;
+        this.typeString = signature.replace('.', '/');
         this.isDeserialized = true;
-	}
+    }
+
+    /**
+     * Comparing the receiver to the parameter, according to the Comparable
+     * interface.
+     * 
+     * @param o
+     *            The object to compare against
+     * 
+     * @return -1 if the receiver is "smaller" than the parameter. 0 if the
+     *         receiver is "equal" to the parameter. 1 if the receiver is
+     *         "greater" than the parameter.
+     */
+    public int compareTo(Object o) {
+        ObjectStreamField f = (ObjectStreamField) o;
+        boolean thisPrimitive = this.isPrimitive();
+        boolean fPrimitive = f.isPrimitive();
+
+        // If one is primitive and the other isn't, we have enough info to
+        // compare
+        if (thisPrimitive != fPrimitive) {
+            return thisPrimitive ? -1 : 1;
+        }
 
-	/**
-	 * Comparing the receiver to the parameter, according to the Comparable
-	 * interface.
-	 * 
-	 * @param o
-	 *            The object to compare against
-	 * 
-	 * @return -1 if the receiver is "smaller" than the parameter. 0 if the
-	 *         receiver is "equal" to the parameter. 1 if the receiver is
-	 *         "greater" than the parameter.
-	 */
-	public int compareTo(Object o) {
-		ObjectStreamField f = (ObjectStreamField) o;
-		boolean thisPrimitive = this.isPrimitive();
-		boolean fPrimitive = f.isPrimitive();
-
-		// If one is primitive and the other isn't, we have enough info to
-		// compare
-		if (thisPrimitive != fPrimitive) {
-			return thisPrimitive ? -1 : 1;
-		}
-
-		// Either both primitives or both not primitives. Compare based on name.
-		return this.getName().compareTo(f.getName());
-	}
-    
-    
+        // Either both primitives or both not primitives. Compare based on name.
+        return this.getName().compareTo(f.getName());
+    }
+
+    @Override
     public boolean equals(Object arg0) {
         return compareTo(arg0) == 0;
     }
-    
+
+    @Override
     public int hashCode() {
         return getName().hashCode();
     }
 
-	/**
-	 * Return the name of the field the receiver represents
-	 * 
-	 * @return a String, the name of the field
-	 */
-	public String getName() {
-		return name;
-	}
-
-	/**
-	 * Return the offset of this field in the object
-	 * 
-	 * @return an int, the offset
-	 */
-	public int getOffset() {
-		return offset;
-	}
-
-	/**
-	 * Return the type of the field the receiver represents,
-     * this is an internal method
-	 * 
-	 * @return A Class object representing the type of the field
-	 */
-	private Class<?> getTypeInternal() {
-		if (type instanceof WeakReference) {
-			return (Class<?>)((WeakReference<?>) type).get();
-		}
-		return (Class<?>) type;
-	}
-    
+    /**
+     * Return the name of the field the receiver represents
+     * 
+     * @return a String, the name of the field
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Return the offset of this field in the object
+     * 
+     * @return an int, the offset
+     */
+    public int getOffset() {
+        return offset;
+    }
+
+    /**
+     * Return the type of the field the receiver represents, this is an internal
+     * method
+     * 
+     * @return A Class object representing the type of the field
+     */
+    private Class<?> getTypeInternal() {
+        if (type instanceof WeakReference) {
+            return (Class<?>) ((WeakReference<?>) type).get();
+        }
+        return (Class<?>) type;
+    }
+
     /**
      * Return the type of the field the receiver represents
      * 
      * @return A Class object representing the type of the field
      */
     public Class<?> getType() {
-    	Class<?> cl = getTypeInternal();
+        Class<?> cl = getTypeInternal();
         if (isDeserialized && !cl.isPrimitive()) {
             return Object.class;
         }
         return cl;
     }
 
-	/**
-	 * Return the type code that corresponds to the class the receiver
-	 * represents
-	 * 
-	 * @return A char, the typecode of the class
-	 */
-	public char getTypeCode() {
-		Class<?> t = getTypeInternal();
-		if (t == Integer.TYPE) {
-			return 'I';
-		}
-		if (t == Byte.TYPE) {
-			return 'B';
-		}
-		if (t == Character.TYPE) {
-			return 'C';
-		}
-		if (t == Short.TYPE) {
-			return 'S';
-		}
-		if (t == Boolean.TYPE) {
-			return 'Z';
-		}
-		if (t == Long.TYPE) {
-			return 'J';
-		}
-		if (t == Float.TYPE) {
-			return 'F';
-		}
-		if (t == Double.TYPE) {
-			return 'D';
-		}
-		if (t.isArray()) {
-			return '[';
-		}
-		return 'L';
-	}
-
-	/**
-	 * Return the type signature used by the VM to represent the type for this
-	 * field.
-	 * 
-	 * @return A String, the signature for the class of this field.
-	 */
-	public String getTypeString() {
-		if (isPrimitive()) {
-			return null;
-		}
-		if (typeString == null) {
-			Class<?> t = getTypeInternal();
-			String typeName = t.getName().replace('.', '/');
-			String str = (t.isArray()) ? typeName : ("L" + typeName + ';'); //$NON-NLS-1$
-			typeString = str.intern();
-		}
-		return typeString;
-	}
-
-	/**
-	 * Return a boolean indicating whether the class of this field is a
-	 * primitive type or not
-	 * 
-	 * @return true if the type of this field is a primitive type false if the
-	 *         type of this field is a regular class.
-	 */
-	public boolean isPrimitive() {
-		Class<?> t = getTypeInternal();
-		return t != null && t.isPrimitive();
-	}
-
-	/**
-	 * Set the offset this field represents in the object
-	 * 
-	 * @param newValue
-	 *            an int, the offset
-	 */
-	protected void setOffset(int newValue) {
-		this.offset = newValue;
-	}
-
-	/**
-	 * Answers a string containing a concise, human-readable description of the
-	 * receiver.
-	 * 
-	 * @return a printable representation for the receiver.
-	 */
-	@Override
+    /**
+     * Return the type code that corresponds to the class the receiver
+     * represents
+     * 
+     * @return A char, the typecode of the class
+     */
+    public char getTypeCode() {
+        Class<?> t = getTypeInternal();
+        if (t == Integer.TYPE) {
+            return 'I';
+        }
+        if (t == Byte.TYPE) {
+            return 'B';
+        }
+        if (t == Character.TYPE) {
+            return 'C';
+        }
+        if (t == Short.TYPE) {
+            return 'S';
+        }
+        if (t == Boolean.TYPE) {
+            return 'Z';
+        }
+        if (t == Long.TYPE) {
+            return 'J';
+        }
+        if (t == Float.TYPE) {
+            return 'F';
+        }
+        if (t == Double.TYPE) {
+            return 'D';
+        }
+        if (t.isArray()) {
+            return '[';
+        }
+        return 'L';
+    }
+
+    /**
+     * Return the type signature used by the VM to represent the type for this
+     * field.
+     * 
+     * @return A String, the signature for the class of this field.
+     */
+    public String getTypeString() {
+        if (isPrimitive()) {
+            return null;
+        }
+        if (typeString == null) {
+            Class<?> t = getTypeInternal();
+            String typeName = t.getName().replace('.', '/');
+            String str = (t.isArray()) ? typeName : ("L" + typeName + ';'); //$NON-NLS-1$
+            typeString = str.intern();
+        }
+        return typeString;
+    }
+
+    /**
+     * Return a boolean indicating whether the class of this field is a
+     * primitive type or not
+     * 
+     * @return true if the type of this field is a primitive type false if the
+     *         type of this field is a regular class.
+     */
+    public boolean isPrimitive() {
+        Class<?> t = getTypeInternal();
+        return t != null && t.isPrimitive();
+    }
+
+    /**
+     * Set the offset this field represents in the object
+     * 
+     * @param newValue
+     *            an int, the offset
+     */
+    protected void setOffset(int newValue) {
+        this.offset = newValue;
+    }
+
+    /**
+     * Answers a string containing a concise, human-readable description of the
+     * receiver.
+     * 
+     * @return a printable representation for the receiver.
+     */
+    @Override
     public String toString() {
-		return this.getClass().getName() + '(' + getName() + ':' + getTypeInternal()
-				+ ')';
-	}
-
-	/**
-	 * Sorts the fields for dumping. Primitive types come first, then regular
-	 * types.
-	 * 
-	 * @param fields
-	 *            ObjectStreamField[] fields to be sorted
-	 */
-	static void sortFields(ObjectStreamField[] fields) {
-		// Sort if necessary
-		if (fields.length > 1) {
-			Comparator<ObjectStreamField> fieldDescComparator = new Comparator<ObjectStreamField>() {
-				public int compare(ObjectStreamField f1, ObjectStreamField f2) {
-					return f1.compareTo(f2);
-				}
-			};
-			Arrays.sort(fields, fieldDescComparator);
-		}
-	}
-
-	void resolve(ClassLoader loader) {
-		if (typeString.length() == 1) {
-			switch (typeString.charAt(0)) {
-			case 'I':
-				type = Integer.TYPE;
-				return;
-			case 'B':
-				type = Byte.TYPE;
-				return;
-			case 'C':
-				type = Character.TYPE;
-				return;
-			case 'S':
-				type = Short.TYPE;
-				return;
-			case 'Z':
-				type = Boolean.TYPE;
-				return;
-			case 'J':
-				type = Long.TYPE;
-				return;
-			case 'F':
-				type = Float.TYPE;
-				return;
-			case 'D':
-				type = Double.TYPE;
-				return;
-			}
-		}
-		String className = typeString.replace('/', '.');
-		if (className.charAt(0) == 'L') {
-			// remove L and ;
-			className = className.substring(1, className.length() - 1);
-		}
-		try {
-			Class<?> cl = Class.forName(className, false, loader);
-			type = (cl.getClassLoader() == null) ? cl : new WeakReference<Class<?>>(cl);
-		} catch (ClassNotFoundException e) {
-			// Ignored
-		}
-	}
-
-	/**
-	 * Answers whether this serialized field is unshared.
-	 * 
-	 * @return true if the field is unshared, false otherwise.
-	 */
-	public boolean isUnshared() {
-		return unshared;
-	}
+        return this.getClass().getName() + '(' + getName() + ':'
+                + getTypeInternal() + ')';
+    }
+
+    /**
+     * Sorts the fields for dumping. Primitive types come first, then regular
+     * types.
+     * 
+     * @param fields
+     *            ObjectStreamField[] fields to be sorted
+     */
+    static void sortFields(ObjectStreamField[] fields) {
+        // Sort if necessary
+        if (fields.length > 1) {
+            Comparator<ObjectStreamField> fieldDescComparator = new Comparator<ObjectStreamField>() {
+                public int compare(ObjectStreamField f1, ObjectStreamField f2) {
+                    return f1.compareTo(f2);
+                }
+            };
+            Arrays.sort(fields, fieldDescComparator);
+        }
+    }
+
+    void resolve(ClassLoader loader) {
+        if (typeString.length() == 1) {
+            switch (typeString.charAt(0)) {
+                case 'I':
+                    type = Integer.TYPE;
+                    return;
+                case 'B':
+                    type = Byte.TYPE;
+                    return;
+                case 'C':
+                    type = Character.TYPE;
+                    return;
+                case 'S':
+                    type = Short.TYPE;
+                    return;
+                case 'Z':
+                    type = Boolean.TYPE;
+                    return;
+                case 'J':
+                    type = Long.TYPE;
+                    return;
+                case 'F':
+                    type = Float.TYPE;
+                    return;
+                case 'D':
+                    type = Double.TYPE;
+                    return;
+            }
+        }
+        String className = typeString.replace('/', '.');
+        if (className.charAt(0) == 'L') {
+            // remove L and ;
+            className = className.substring(1, className.length() - 1);
+        }
+        try {
+            Class<?> cl = Class.forName(className, false, loader);
+            type = (cl.getClassLoader() == null) ? cl
+                    : new WeakReference<Class<?>>(cl);
+        } catch (ClassNotFoundException e) {
+            // Ignored
+        }
+    }
+
+    /**
+     * Answers whether this serialized field is unshared.
+     * 
+     * @return true if the field is unshared, false otherwise.
+     */
+    public boolean isUnshared() {
+        return unshared;
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OptionalDataException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OptionalDataException.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OptionalDataException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OptionalDataException.java Thu Jan  4 09:47:01 2007
@@ -16,6 +16,7 @@
  */
 
 package java.io;
+
 /**
  * When readObject() encounters primitive types (int, char, etc) instead of an
  * object instance in the input stream, this type of exception will be thrown.
@@ -26,34 +27,33 @@
  */
 public class OptionalDataException extends ObjectStreamException {
 
-	private static final long serialVersionUID = -8011121865681257820L;
-
-	/**
-	 * If true it means there is no more primitive data available.
-	 */
-	public boolean eof;
-
-	/**
-	 * Number of bytes of primitive data (int, char, long, etc).
-	 */
-	public int length;
-
-	/**
-	 * Constructs a new instance of this class with its walkback filled in.
-	 */
-	OptionalDataException() {
-		super();
-	}
-
-	/**
-	 * Constructs a new instance of this class with its walkback and message
-	 * filled in.
-	 * 
-	 * @param detailMessage
-	 *            String The detail message for the exception.
-	 */
-	OptionalDataException(String detailMessage) {
-		super(detailMessage);
-	}
+    private static final long serialVersionUID = -8011121865681257820L;
 
+    /**
+     * If true it means there is no more primitive data available.
+     */
+    public boolean eof;
+
+    /**
+     * Number of bytes of primitive data (int, char, long, etc).
+     */
+    public int length;
+
+    /**
+     * Constructs a new instance of this class with its walkback filled in.
+     */
+    OptionalDataException() {
+        super();
+    }
+
+    /**
+     * Constructs a new instance of this class with its walkback and message
+     * filled in.
+     * 
+     * @param detailMessage
+     *            String The detail message for the exception.
+     */
+    OptionalDataException(String detailMessage) {
+        super(detailMessage);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java Thu Jan  4 09:47:01 2007
@@ -17,6 +17,7 @@
 
 package java.io;
 
+import org.apache.harmony.luni.util.Msg;
 
 /**
  * OutputStream is an abstract class for all byte output streams. It provides
@@ -24,97 +25,89 @@
  * 
  * @see InputStream
  */
+public abstract class OutputStream implements Closeable, Flushable {
 
-public abstract class OutputStream implements Closeable,Flushable{
-	/**
-	 * This constructor does nothing interesting. Provided for signature
-	 * compatibility.
-	 * 
-	 */
-
-	public OutputStream() {
-		/*empty*/
-	}
-
-	/**
-	 * Close this OutputStream. Concrete implementations of this class should
-	 * free any resources during close. This implementation does nothing.
-	 * 
-	 * @throws IOException
-	 *             If an error occurs attempting to close this OutputStream.
-	 */
-
-	public void close() throws IOException {
-		/*empty*/
-	}
-
-	/**
-	 * Flush this OutputStream. Concrete implementations of this class should
-	 * ensure any pending writes to the underlying stream are written out when
-	 * this method is envoked. This implementation does nothing.
-	 * 
-	 * @throws IOException
-	 *             If an error occurs attempting to flush this OutputStream.
-	 */
-
-	public void flush() throws IOException {
-		/*empty */
-	}
-
-	/**
-	 * Writes the entire contents of the byte array <code>buffer</code> to
-	 * this OutputStream.
-	 * 
-	 * @param buffer
-	 *            the buffer to be written
-	 * 
-	 * @throws IOException
-	 *             If an error occurs attempting to write to this OutputStream.
-	 */
-
-	public void write(byte buffer[]) throws IOException {
-		write(buffer, 0, buffer.length);
-	}
-
-	/**
-	 * Writes <code>count</code> <code>bytes</code> from the byte array
-	 * <code>buffer</code> starting at <code>offset</code> to this
-	 * OutputStream.
-	 * 
-	 * @param buffer
-	 *            the buffer to be written
-	 * @param offset
-	 *            offset in buffer to get bytes
-	 * @param count
-	 *            number of bytes in buffer to write
-	 * 
-	 * @throws IOException
-	 *             If an error occurs attempting to write to this OutputStream.
-	 * @throws IndexOutOfBoundsException
-	 *             If offset or count are outside of bounds.
-	 */
-
-	public void write(byte buffer[], int offset, int count) throws IOException {
-		// avoid int overflow, check null buffer
-		if (offset <= buffer.length && 0 <= offset && 0 <= count
-				&& count <= buffer.length - offset) {
-			for (int i = offset; i < offset + count; i++)
-				write(buffer[i]);
-		} else
-			throw new IndexOutOfBoundsException(org.apache.harmony.luni.util.Msg
-					.getString("K002f")); //$NON-NLS-1$
-	}
-
-	/**
-	 * Writes the specified byte <code>oneByte</code> to this OutputStream.
-	 * Only the low order byte of <code>oneByte</code> is written.
-	 * 
-	 * @param oneByte
-	 *            the byte to be written
-	 * 
-	 * @throws IOException
-	 *             If an error occurs attempting to write to this OutputStream.
-	 */
-
-	public abstract void write(int oneByte) throws IOException;
+    /**
+     * Default constructor.
+     */
+    public OutputStream() {
+        super();
+    }
+
+    /**
+     * Close this OutputStream. Concrete implementations of this class should
+     * free any resources during close. This implementation does nothing.
+     * 
+     * @throws IOException
+     *             If an error occurs attempting to close this OutputStream.
+     */
+    public void close() throws IOException {
+        /* empty */
+    }
+
+    /**
+     * Flush this OutputStream. Concrete implementations of this class should
+     * ensure any pending writes to the underlying stream are written out when
+     * this method is envoked. This implementation does nothing.
+     * 
+     * @throws IOException
+     *             If an error occurs attempting to flush this OutputStream.
+     */
+    public void flush() throws IOException {
+        /* empty */
+    }
+
+    /**
+     * Writes the entire contents of the byte array <code>buffer</code> to
+     * this OutputStream.
+     * 
+     * @param buffer
+     *            the buffer to be written
+     * 
+     * @throws IOException
+     *             If an error occurs attempting to write to this OutputStream.
+     */
+    public void write(byte buffer[]) throws IOException {
+        write(buffer, 0, buffer.length);
+    }
+
+    /**
+     * Writes <code>count</code> <code>bytes</code> from the byte array
+     * <code>buffer</code> starting at <code>offset</code> to this
+     * OutputStream.
+     * 
+     * @param buffer
+     *            the buffer to be written
+     * @param offset
+     *            offset in buffer to get bytes
+     * @param count
+     *            number of bytes in buffer to write
+     * 
+     * @throws IOException
+     *             If an error occurs attempting to write to this OutputStream.
+     * @throws IndexOutOfBoundsException
+     *             If offset or count are outside of bounds.
+     */
+    public void write(byte buffer[], int offset, int count) throws IOException {
+        // avoid int overflow, check null buffer
+        if (offset < 0 || offset > buffer.length || count < 0
+                || count > buffer.length - offset) {
+            throw new IndexOutOfBoundsException(Msg.getString("K002f")); //$NON-NLS-1$
+        }
+        for (int i = offset; i < offset + count; i++) {
+            write(buffer[i]);
+        }
+    }
+
+    /**
+     * Writes the specified byte <code>oneByte</code> to this OutputStream.
+     * Only the low order byte of <code>oneByte</code> is written.
+     * 
+     * @param oneByte
+     *            the byte to be written
+     * 
+     * @throws IOException
+     *             If an error occurs attempting to write to this OutputStream.
+     */
+    public abstract void write(int oneByte) throws IOException;
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java Thu Jan  4 09:47:01 2007
@@ -15,8 +15,7 @@
  *  limitations under the License.
  */
 
-package java.io; 
-
+package java.io;
 
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
@@ -26,6 +25,7 @@
 import java.nio.charset.CodingErrorAction;
 import java.security.AccessController;
 
+import org.apache.harmony.luni.util.Msg;
 import org.apache.harmony.luni.util.PriviAction;
 
 /**
@@ -35,283 +35,279 @@
  * ISO8859_1 (ISO-Latin-1) but can be changed by calling the constructor which
  * takes an encoding.
  * 
- * 
  * @see InputStreamReader
  */
 
 public class OutputStreamWriter extends Writer {
-	private OutputStream out;
 
-	private CharsetEncoder encoder;
+    private OutputStream out;
+
+    private CharsetEncoder encoder;
 
-	private ByteBuffer bytes = ByteBuffer.allocate(8192);
+    private ByteBuffer bytes = ByteBuffer.allocate(8192);
 
-	/**
-	 * Constructs a new OutputStreamWriter using <code>out</code> as the
-	 * OutputStream to write converted characters to. The default character
-	 * encoding is used (see class description).
-	 * 
-	 * @param out
-	 *            the non-null OutputStream to write converted bytes to.
-	 */
-
-	public OutputStreamWriter(OutputStream out) {
-		super(out);
-		this.out = out;
-		String encoding = AccessController
+    /**
+     * Constructs a new OutputStreamWriter using <code>out</code> as the
+     * OutputStream to write converted characters to. The default character
+     * encoding is used (see class description).
+     * 
+     * @param out
+     *            the non-null OutputStream to write converted bytes to.
+     */
+    public OutputStreamWriter(OutputStream out) {
+        super(out);
+        this.out = out;
+        String encoding = AccessController
                 .doPrivileged(new PriviAction<String>(
                         "file.encoding", "ISO8859_1")); //$NON-NLS-1$ //$NON-NLS-2$
-		encoder = Charset.forName(encoding).newEncoder();
-		encoder.onMalformedInput(CodingErrorAction.REPLACE);
-		encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
-	}
-
-	/**
-	 * Constructs a new OutputStreamWriter using <code>out</code> as the
-	 * OutputStream to write converted characters to and <code>enc</code> as
-	 * the character encoding. If the encoding cannot be found, an
-	 * UnsupportedEncodingException error is thrown.
-	 * 
-	 * @param out
-	 *            the non-null OutputStream to write converted bytes to.
-	 * @param enc
-	 *            the non-null String describing the desired character encoding.
-	 * 
-	 * @throws UnsupportedEncodingException
-	 *             if the encoding cannot be found.
-	 */
-
-	public OutputStreamWriter(OutputStream out, final String enc)
-			throws UnsupportedEncodingException {
-		super(out);
-        if(enc == null) {
+        encoder = Charset.forName(encoding).newEncoder();
+        encoder.onMalformedInput(CodingErrorAction.REPLACE);
+        encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+    }
+
+    /**
+     * Constructs a new OutputStreamWriter using <code>out</code> as the
+     * OutputStream to write converted characters to and <code>enc</code> as
+     * the character encoding. If the encoding cannot be found, an
+     * UnsupportedEncodingException error is thrown.
+     * 
+     * @param out
+     *            the non-null OutputStream to write converted bytes to.
+     * @param enc
+     *            the non-null String describing the desired character encoding.
+     * 
+     * @throws UnsupportedEncodingException
+     *             if the encoding cannot be found.
+     */
+    public OutputStreamWriter(OutputStream out, final String enc)
+            throws UnsupportedEncodingException {
+        super(out);
+        if (enc == null) {
             throw new NullPointerException();
         }
-		this.out = out;
-		try {
-			encoder = Charset.forName(enc).newEncoder();
-		} catch (Exception e) {
-			throw new UnsupportedEncodingException(enc);
-		}
-		encoder.onMalformedInput(CodingErrorAction.REPLACE);
-		encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
-	}
-
-	/**
-	 * Constructs a new OutputStreamWriter using <code>out</code> as the
-	 * OutputStream to write converted characters to and <code>cs</code> as
-	 * the character encoding.
-	 * 
-	 * 
-	 * @param out
-	 *            the non-null OutputStream to write converted bytes to.
-	 * @param cs
-	 *            the non-null Charset which specify the character encoding.
-	 */
-	public OutputStreamWriter(OutputStream out, Charset cs) {
-		super(out);
-		this.out = out;
-		encoder = cs.newEncoder();
-		encoder.onMalformedInput(CodingErrorAction.REPLACE);
-		encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
-	}
-
-	/**
-	 * Constructs a new OutputStreamWriter using <code>out</code> as the
-	 * OutputStream to write converted characters to and <code>enc</code> as
-	 * the character encoding.
-	 * 
-	 * 
-	 * @param out
-	 *            the non-null OutputStream to write converted bytes to.
-	 * @param enc
-	 *            the non-null CharsetEncoder which used to character encoding.
-	 */
-	public OutputStreamWriter(OutputStream out, CharsetEncoder enc) {
-		super(out);
-		enc.charset();
-		this.out = out;
-		encoder = enc;
-	}
-
-	/**
-	 * Close this OutputStreamWriter. This implementation first flushes the
-	 * buffer and the target OutputStream. The OutputStream is then closed and
-	 * the resources for the buffer and converter are freed.
-	 * <p>
-	 * Only the first invocation of this method has any effect. Subsequent calls
-	 * do no work.
-	 * 
-	 * @throws IOException
-	 *             If an error occurs attempting to close this
-	 *             OutputStreamWriter.
-	 */
-	@Override
+        this.out = out;
+        try {
+            encoder = Charset.forName(enc).newEncoder();
+        } catch (Exception e) {
+            throw new UnsupportedEncodingException(enc);
+        }
+        encoder.onMalformedInput(CodingErrorAction.REPLACE);
+        encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+    }
+
+    /**
+     * Constructs a new OutputStreamWriter using <code>out</code> as the
+     * OutputStream to write converted characters to and <code>cs</code> as
+     * the character encoding.
+     * 
+     * 
+     * @param out
+     *            the non-null OutputStream to write converted bytes to.
+     * @param cs
+     *            the non-null Charset which specify the character encoding.
+     */
+    public OutputStreamWriter(OutputStream out, Charset cs) {
+        super(out);
+        this.out = out;
+        encoder = cs.newEncoder();
+        encoder.onMalformedInput(CodingErrorAction.REPLACE);
+        encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+    }
+
+    /**
+     * Constructs a new OutputStreamWriter using <code>out</code> as the
+     * OutputStream to write converted characters to and <code>enc</code> as
+     * the character encoding.
+     * 
+     * @param out
+     *            the non-null OutputStream to write converted bytes to.
+     * @param enc
+     *            the non-null CharsetEncoder which used to character encoding.
+     */
+    public OutputStreamWriter(OutputStream out, CharsetEncoder enc) {
+        super(out);
+        enc.charset();
+        this.out = out;
+        encoder = enc;
+    }
+
+    /**
+     * Close this OutputStreamWriter. This implementation first flushes the
+     * buffer and the target OutputStream. The OutputStream is then closed and
+     * the resources for the buffer and converter are freed.
+     * <p>
+     * Only the first invocation of this method has any effect. Subsequent calls
+     * do no work.
+     * 
+     * @throws IOException
+     *             If an error occurs attempting to close this
+     *             OutputStreamWriter.
+     */
+    @Override
     public void close() throws IOException {
-		synchronized (lock) {
-			if (encoder != null) {
-				encoder.flush(bytes);
-				flush();
-				out.flush();
-				out.close();
-				encoder = null;
-				bytes = null;
-			}
-		}
-	}
-
-	/**
-	 * Flush this OutputStreamWriter. This implementation ensures all buffered
-	 * bytes are written to the target OutputStream. After writing the bytes,
-	 * the target OutputStream is then flushed.
-	 * 
-	 * @throws IOException
-	 *             If an error occurs attempting to flush this
-	 *             OutputStreamWriter.
-	 */
+        synchronized (lock) {
+            if (encoder != null) {
+                encoder.flush(bytes);
+                flush();
+                out.flush();
+                out.close();
+                encoder = null;
+                bytes = null;
+            }
+        }
+    }
 
-	@Override
+    /**
+     * Flush this OutputStreamWriter. This implementation ensures all buffered
+     * bytes are written to the target OutputStream. After writing the bytes,
+     * the target OutputStream is then flushed.
+     * 
+     * @throws IOException
+     *             If an error occurs attempting to flush this
+     *             OutputStreamWriter.
+     */
+    @Override
     public void flush() throws IOException {
-		synchronized (lock) {
-			checkStatus();
-			int position;
-			if ((position = bytes.position()) > 0) {
-				bytes.flip();
-				out.write(bytes.array(), 0, position);
-				bytes.clear();
-			}
-			out.flush();
-		}
-	}
-
-	private void checkStatus() throws IOException {
-		if (encoder == null) {
-			throw new IOException("This writer has been closed!"); //$NON-NLS-1$
-		}
-	}
-
-	/**
-	 * Answer the String which identifies the encoding used to convert
-	 * characters to bytes. The value <code>null</code> is returned if this
-	 * Writer has been closed.
-	 * 
-	 * @return the String describing the converter or null if this Writer is
-	 *         closed.
-	 */
-
-	public String getEncoding() {
-		if (encoder == null) {
-			return null;
-		}
-		return InputStreamReader.HistoricalNamesUtil.getHistoricalName(encoder
-				.charset().name());
-	}
-
-	/**
-	 * Writes <code>count</code> characters starting at <code>offset</code>
-	 * in <code>buf</code> to this Writer. The characters are immediately
-	 * converted to bytes by the character converter and stored in a local
-	 * buffer. If the buffer becomes full as a result of this write, this Writer
-	 * is flushed.
-	 * 
-	 * @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 OutputStreamWriter has already been closed or some
-	 *             other IOException occurs.
-	 * @throws IndexOutOfBoundsException
-	 *             If offset or count is outside of bounds.
-	 */
-	@Override
+        synchronized (lock) {
+            checkStatus();
+            int position;
+            if ((position = bytes.position()) > 0) {
+                bytes.flip();
+                out.write(bytes.array(), 0, position);
+                bytes.clear();
+            }
+            out.flush();
+        }
+    }
+
+    private void checkStatus() throws IOException {
+        if (encoder == null) {
+            // K005d=Writer is closed.
+            throw new IOException(Msg.getString("K005d")); //$NON-NLS-1$
+        }
+    }
+
+    /**
+     * Answer the String which identifies the encoding used to convert
+     * characters to bytes. The value <code>null</code> is returned if this
+     * Writer has been closed.
+     * 
+     * @return the String describing the converter or null if this Writer is
+     *         closed.
+     */
+
+    public String getEncoding() {
+        if (encoder == null) {
+            return null;
+        }
+        return InputStreamReader.HistoricalNamesUtil.getHistoricalName(encoder
+                .charset().name());
+    }
+
+    /**
+     * Writes <code>count</code> characters starting at <code>offset</code>
+     * in <code>buf</code> to this Writer. The characters are immediately
+     * converted to bytes by the character converter and stored in a local
+     * buffer. If the buffer becomes full as a result of this write, this Writer
+     * is flushed.
+     * 
+     * @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 OutputStreamWriter has already been closed or some
+     *             other IOException occurs.
+     * @throws IndexOutOfBoundsException
+     *             If offset or count is outside of bounds.
+     */
+    @Override
     public void write(char[] buf, int offset, int count) throws IOException {
-		synchronized (lock) {
-			checkStatus();
-			if (offset < 0 || offset > buf.length - count || count < 0) {
-				throw new IndexOutOfBoundsException();
-			}
-			CharBuffer chars = CharBuffer.wrap(buf, offset, count);
-			convert(chars);
-		}
-	}
-
-	private void convert(CharBuffer chars) throws IOException {
-		CoderResult result = encoder.encode(chars, bytes, true);
-		while (true) {
-			if (result.isError()) {
-				throw new IOException(result.toString());
-			} else if (result.isOverflow()) {
-				//flush the output buffer
-				flush();
-				result = encoder.encode(chars, bytes, true);
-				continue;
-			}
-			break;
-		}
-	}
-
-	/**
-	 * Writes out the character <code>oneChar</code> to this Writer. The
-	 * low-order 2 bytes are immediately converted to bytes by the character
-	 * converter and stored in a local buffer. If the buffer becomes full as a
-	 * result of this write, this Writer is flushed.
-	 * 
-	 * @param oneChar
-	 *            the character to write
-	 * 
-	 * @throws IOException
-	 *             If this OutputStreamWriter has already been closed or some
-	 *             other IOException occurs.
-	 */
-	@Override
+        synchronized (lock) {
+            checkStatus();
+            if (offset < 0 || offset > buf.length - count || count < 0) {
+                throw new IndexOutOfBoundsException();
+            }
+            CharBuffer chars = CharBuffer.wrap(buf, offset, count);
+            convert(chars);
+        }
+    }
+
+    private void convert(CharBuffer chars) throws IOException {
+        CoderResult result = encoder.encode(chars, bytes, true);
+        while (true) {
+            if (result.isError()) {
+                throw new IOException(result.toString());
+            } else if (result.isOverflow()) {
+                // flush the output buffer
+                flush();
+                result = encoder.encode(chars, bytes, true);
+                continue;
+            }
+            break;
+        }
+    }
+
+    /**
+     * Writes out the character <code>oneChar</code> to this Writer. The
+     * low-order 2 bytes are immediately converted to bytes by the character
+     * converter and stored in a local buffer. If the buffer becomes full as a
+     * result of this write, this Writer is flushed.
+     * 
+     * @param oneChar
+     *            the character to write
+     * 
+     * @throws IOException
+     *             If this OutputStreamWriter has already been closed or some
+     *             other IOException occurs.
+     */
+    @Override
     public void write(int oneChar) throws IOException {
-		synchronized (lock) {
-			checkStatus();
-			CharBuffer chars = CharBuffer.wrap(new char[] { (char) oneChar });
-			convert(chars);
-		}
-	}
-
-	/**
-	 * Writes <code>count</code> characters starting at <code>offset</code>
-	 * in <code>str</code> to this Writer. The characters are immediately
-	 * converted to bytes by the character converter and stored in a local
-	 * buffer. If the buffer becomes full as a result of this write, this Writer
-	 * is flushed.
-	 * 
-	 * @param str
-	 *            the non-null String containing characters to write.
-	 * @param offset
-	 *            offset in str to retrieve characters
-	 * @param count
-	 *            maximum number of characters to write
-	 * 
-	 * @throws IOException
-	 *             If this OutputStreamWriter has already been closed or some
-	 *             other IOException occurs.
-	 * @throws IndexOutOfBoundsException    
-	 *             If count is negative    
-	 * @throws StringIndexOutOfBoundsException
-	 *             If offset is negative or offset + count is outside of bounds
-	 */
-	@Override
+        synchronized (lock) {
+            checkStatus();
+            CharBuffer chars = CharBuffer.wrap(new char[] { (char) oneChar });
+            convert(chars);
+        }
+    }
+
+    /**
+     * Writes <code>count</code> characters starting at <code>offset</code>
+     * in <code>str</code> to this Writer. The characters are immediately
+     * converted to bytes by the character converter and stored in a local
+     * buffer. If the buffer becomes full as a result of this write, this Writer
+     * is flushed.
+     * 
+     * @param str
+     *            the non-null String containing characters to write.
+     * @param offset
+     *            offset in str to retrieve characters
+     * @param count
+     *            maximum number of characters to write
+     * 
+     * @throws IOException
+     *             If this OutputStreamWriter has already been closed or some
+     *             other IOException occurs.
+     * @throws IndexOutOfBoundsException
+     *             If count is negative
+     * @throws StringIndexOutOfBoundsException
+     *             If offset is negative or offset + count is outside of bounds
+     */
+    @Override
     public void write(String str, int offset, int count) throws IOException {
-		synchronized (lock) {
-			// avoid int overflow
-			if (count < 0) {
-				throw new IndexOutOfBoundsException();
-			}
-			if (offset > str.length() - count || offset < 0) {
-				throw new StringIndexOutOfBoundsException();
-			}
-			checkStatus();
-			CharBuffer chars = CharBuffer.wrap(str, offset, count + offset);
-			convert(chars);
-		}
-	}
+        synchronized (lock) {
+            // avoid int overflow
+            if (count < 0) {
+                throw new IndexOutOfBoundsException();
+            }
+            if (offset > str.length() - count || offset < 0) {
+                throw new StringIndexOutOfBoundsException();
+            }
+            checkStatus();
+            CharBuffer chars = CharBuffer.wrap(str, offset, count + offset);
+            convert(chars);
+        }
+    }
 }
-

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java Thu Jan  4 09:47:01 2007
@@ -17,6 +17,7 @@
 
 package java.io;
 
+import org.apache.harmony.luni.util.Msg;
 
 /**
  * PipedInputStream is a class which receives information on a communications
@@ -26,333 +27,332 @@
  * @see PipedOutputStream
  */
 public class PipedInputStream extends InputStream {
-	private Thread lastReader, lastWriter;
 
-	private boolean isClosed = false;
+    private Thread lastReader, lastWriter;
 
-	/**
-	 * The circular buffer through which data is passed.
-	 */
-	protected byte buffer[];
-
-	/**
-	 * The index in <code>buffer</code> where the next byte will be written.
-	 */
-	protected int in = -1;
-
-	/**
-	 * The index in <code>buffer</code> where the next byte will be read.
-	 */
-	protected int out = 0;
-
-	/**
-	 * The size of the default pipe in bytes
-	 */
-	protected static final int PIPE_SIZE = 1024;
-
-	/**
-	 * Indicates if this pipe is connected
-	 */
-	boolean isConnected = false;
-
-	/**
-	 * Constructs a new unconnected PipedInputStream. The resulting Stream must
-	 * be connected to a PipedOutputStream before data may be read from it.
-	 * 
-	 */
-	public PipedInputStream() {
-		/*empty*/
-	}
-
-	/**
-	 * Constructs a new PipedInputStream connected to the PipedOutputStream
-	 * <code>out</code>. Any data written to the output stream can be read
-	 * from the this input stream.
-	 * 
-	 * @param out
-	 *            the PipedOutputStream to connect to.
-	 * 
-	 * @throws IOException
-	 *             if this or <code>out</code> are already connected.
-	 */
-	public PipedInputStream(PipedOutputStream out) throws IOException {
-		connect(out);
-	}
-
-	/**
-	 * Answers a int representing the number of bytes that are available before
-	 * this PipedInputStream will block. This method returns the number of bytes
-	 * written to the pipe but not read yet up to the size of the pipe.
-	 * 
-	 * @return int the number of bytes available before blocking.
-	 * 
-	 * @throws IOException
-	 *             If an error occurs in this stream.
-	 */
-	@Override
+    private boolean isClosed = false;
+
+    /**
+     * The circular buffer through which data is passed.
+     */
+    protected byte buffer[];
+
+    /**
+     * The index in <code>buffer</code> where the next byte will be written.
+     */
+    protected int in = -1;
+
+    /**
+     * The index in <code>buffer</code> where the next byte will be read.
+     */
+    protected int out = 0;
+
+    /**
+     * The size of the default pipe in bytes
+     */
+    protected static final int PIPE_SIZE = 1024;
+
+    /**
+     * Indicates if this pipe is connected
+     */
+    boolean isConnected = false;
+
+    /**
+     * Constructs a new unconnected PipedInputStream. The resulting Stream must
+     * be connected to a PipedOutputStream before data may be read from it.
+     * 
+     */
+    public PipedInputStream() {
+        /* empty */
+    }
+
+    /**
+     * Constructs a new PipedInputStream connected to the PipedOutputStream
+     * <code>out</code>. Any data written to the output stream can be read
+     * from the this input stream.
+     * 
+     * @param out
+     *            the PipedOutputStream to connect to.
+     * 
+     * @throws IOException
+     *             if this or <code>out</code> are already connected.
+     */
+    public PipedInputStream(PipedOutputStream out) throws IOException {
+        connect(out);
+    }
+
+    /**
+     * Answers a int representing the number of bytes that are available before
+     * this PipedInputStream will block. This method returns the number of bytes
+     * written to the pipe but not read yet up to the size of the pipe.
+     * 
+     * @return int the number of bytes available before blocking.
+     * 
+     * @throws IOException
+     *             If an error occurs in this stream.
+     */
+    @Override
     public synchronized int available() throws IOException {
-		if (buffer == null || in == -1) {
+        if (buffer == null || in == -1) {
             return 0;
         }
-		return in <= out ? buffer.length - out + in : in - out;
-	}
+        return in <= out ? buffer.length - out + in : in - out;
+    }
 
-	/**
-	 * Close this PipedInputStream. This implementation releases the buffer used
-	 * for the pipe and notifies all threads waiting to read or write.
-	 * 
-	 * @throws IOException
-	 *             If an error occurs attempting to close this stream.
-	 */
-	@Override
+    /**
+     * Close this PipedInputStream. This implementation releases the buffer used
+     * for the pipe and notifies all threads waiting to read or write.
+     * 
+     * @throws IOException
+     *             If an error occurs attempting to close this stream.
+     */
+    @Override
     public void close() throws IOException {
-		synchronized (this) {
-			/* No exception thrown if already closed */
-			if (buffer != null) {
-				/* Release buffer to indicate closed. */
-				buffer = null;
-			}
-		}
-	}
-
-	/**
-	 * Connects this PipedInputStream to a PipedOutputStream. Any data written
-	 * to the OutputStream becomes readable in this InputStream.
-	 * 
-	 * @param src
-	 *            the source PipedOutputStream.
-	 * 
-	 * @throws IOException
-	 *             If either stream is already connected.
-	 */
-	public void connect(PipedOutputStream src) throws IOException {
-		src.connect(this);
-	}
-
-	/**
-	 * Reads a single byte from this PipedInputStream and returns the result as
-	 * an int. The low-order byte is returned or -1 of the end of stream was
-	 * encountered. If there is no data in the pipe, this method blocks until
-	 * there is data available. Separate threads should be used for the reader
-	 * of the PipedInputStream and the PipedOutputStream. There may be
-	 * undesirable results if more than one Thread interacts a input or output
-	 * pipe.
-	 * 
-	 * @return int The byte read or -1 if end of stream.
-	 * 
-	 * @throws IOException
-	 *             If the stream is already closed or another IOException
-	 *             occurs.
-	 */
-	@Override
+        synchronized (this) {
+            /* No exception thrown if already closed */
+            if (buffer != null) {
+                /* Release buffer to indicate closed. */
+                buffer = null;
+            }
+        }
+    }
+
+    /**
+     * Connects this PipedInputStream to a PipedOutputStream. Any data written
+     * to the OutputStream becomes readable in this InputStream.
+     * 
+     * @param src
+     *            the source PipedOutputStream.
+     * 
+     * @throws IOException
+     *             If either stream is already connected.
+     */
+    public void connect(PipedOutputStream src) throws IOException {
+        src.connect(this);
+    }
+
+    /**
+     * Reads a single byte from this PipedInputStream and returns the result as
+     * an int. The low-order byte is returned or -1 of the end of stream was
+     * encountered. If there is no data in the pipe, this method blocks until
+     * there is data available. Separate threads should be used for the reader
+     * of the PipedInputStream and the PipedOutputStream. There may be
+     * undesirable results if more than one Thread interacts a input or output
+     * pipe.
+     * 
+     * @return int The byte read or -1 if end of stream.
+     * 
+     * @throws IOException
+     *             If the stream is already closed or another IOException
+     *             occurs.
+     */
+    @Override
     public synchronized int read() throws IOException {
-		if (isConnected) {
-			if (buffer != null) {
-				/**
-				 * Set the last thread to be reading on this PipedInputStream.
-				 * If lastReader dies while someone is waiting to write an
-				 * IOException of "Pipe broken" will be thrown in receive()
-				 */
-				lastReader = Thread.currentThread();
-				try {
-					boolean first = true;
-					while (in == -1) {
-						// Are we at end of stream?
-						if (isClosed) {
-                            return -1;
-                        }
-						if (!first && lastWriter != null
-								&& !lastWriter.isAlive()) {
-                            throw new IOException(org.apache.harmony.luni.util.Msg
-									.getString("K0076")); //$NON-NLS-1$
-                        }
-						first = false;
-						// Notify callers of receive()
-						notifyAll();
-						wait(1000);
-					}
-				} catch (InterruptedException e) {
-					throw new InterruptedIOException();
-				}
-
-				byte result = buffer[out++];
-				if (out == buffer.length) {
-                    out = 0;
+        if (!isConnected) {
+            throw new IOException(Msg.getString("K0074")); //$NON-NLS-1$
+        }
+        if (buffer == null) {
+            throw new IOException(Msg.getString("K0075")); //$NON-NLS-1$
+        }
+        /**
+         * Set the last thread to be reading on this PipedInputStream. If
+         * lastReader dies while someone is waiting to write an IOException of
+         * "Pipe broken" will be thrown in receive()
+         */
+        lastReader = Thread.currentThread();
+        try {
+            boolean first = true;
+            while (in == -1) {
+                // Are we at end of stream?
+                if (isClosed) {
+                    return -1;
                 }
-				if (out == in) {
-					// empty buffer
-					in = -1;
-					out = 0;
-				}
-				return result & 0xff;
-			}
-			throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0075")); //$NON-NLS-1$
-		}
-		throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0074")); //$NON-NLS-1$
-	}
-
-	/**
-	 * Reads at most <code>count</code> bytes from this PipedInputStream and
-	 * stores them in byte array <code>buffer</code> starting at
-	 * <code>offset</code>. Answer the number of bytes actually read or -1 if
-	 * no bytes were read and end of stream was encountered. Separate threads
-	 * should be used for the reader of the PipedInputStream and the
-	 * PipedOutputStream. There may be undesirable results if more than one
-	 * Thread interacts a input or output pipe.
-	 * 
-	 * @param bytes
-	 *            the byte array in which to store the read bytes.
-	 * @param offset
-	 *            the offset in <code>buffer</code> to store the read bytes.
-	 * @param count
-	 *            the maximum number of bytes to store in <code>buffer</code>.
-	 * @return the number of bytes actually read or -1 if end of stream.
-	 * 
-	 * @throws IOException
-	 *             If the stream is already closed or another IOException
-	 *             occurs.
-	 */
-	@Override
-    public synchronized int read(byte[] bytes, int offset, int count)
-			throws IOException {
-		if (bytes != null && 0 <= offset && offset <= bytes.length
-				&& 0 <= count && count <= bytes.length - offset) {
-			if (count == 0) {
-                return 0;
+                if (!first && lastWriter != null && !lastWriter.isAlive()) {
+                    throw new IOException(Msg.getString("K0076")); //$NON-NLS-1$
+                }
+                first = false;
+                // Notify callers of receive()
+                notifyAll();
+                wait(1000);
             }
-			if (isConnected && buffer != null) {
-				/**
-				 * Set the last thread to be reading on this PipedInputStream.
-				 * If lastReader dies while someone is waiting to write an
-				 * IOException of "Pipe broken" will be thrown in receive()
-				 */
-				lastReader = Thread.currentThread();
-				try {
-					boolean first = true;
-					while (in == -1) {
-						// Are we at end of stream?
-						if (isClosed) {
-                            return -1;
-                        }
-						if (!first && lastWriter != null
-								&& !lastWriter.isAlive()) {
-                            throw new IOException(org.apache.harmony.luni.util.Msg
-									.getString("K0076")); //$NON-NLS-1$
-                        }
-						first = false;
-						// Notify callers of receive()
-						notifyAll();
-						wait(1000);
-					}
-				} catch (InterruptedException e) {
-					throw new InterruptedIOException();
-				}
-
-				int copyLength = 0;
-				/* Copy bytes from out to end of buffer first */
-				if (out >= in) {
-					copyLength = count > (buffer.length - out) ? buffer.length
-							- out : count;
-					System.arraycopy(buffer, out, bytes, offset, copyLength);
-					out += copyLength;
-					if (out == buffer.length) {
-                        out = 0;
-                    }
-					if (out == in) {
-						// empty buffer
-						in = -1;
-						out = 0;
-					}
-				}
-
-				/*
-				 * Did the read fully succeed in the previous copy or is the
-				 * buffer empty?
-				 */
-				if (copyLength == count || in == -1) {
-                    return copyLength;
+        } catch (InterruptedException e) {
+            throw new InterruptedIOException();
+        }
+
+        byte result = buffer[out++];
+        if (out == buffer.length) {
+            out = 0;
+        }
+        if (out == in) {
+            // empty buffer
+            in = -1;
+            out = 0;
+        }
+        return result & 0xff;
+    }
+
+    /**
+     * Reads at most <code>count</code> bytes from this PipedInputStream and
+     * stores them in byte array <code>buffer</code> starting at
+     * <code>offset</code>. Answer the number of bytes actually read or -1 if
+     * no bytes were read and end of stream was encountered. Separate threads
+     * should be used for the reader of the PipedInputStream and the
+     * PipedOutputStream. There may be undesirable results if more than one
+     * Thread interacts a input or output pipe.
+     * 
+     * @param bytes
+     *            the byte array in which to store the read bytes.
+     * @param offset
+     *            the offset in <code>buffer</code> to store the read bytes.
+     * @param count
+     *            the maximum number of bytes to store in <code>buffer</code>.
+     * @return the number of bytes actually read or -1 if end of stream.
+     * 
+     * @throws IOException
+     *             If the stream is already closed or another IOException
+     *             occurs.
+     */
+    @Override
+    public synchronized int read(byte[] bytes, int offset, int count)
+            throws IOException {
+        if (bytes == null) {
+            throw new NullPointerException();
+        }
+
+        if (offset < 0 || offset > bytes.length || count < 0
+                || count > bytes.length - offset) {
+            throw new IndexOutOfBoundsException();
+        }
+
+        if (count == 0) {
+            return 0;
+        }
+
+        if (!isConnected) {
+            throw new IOException(Msg.getString("K0074")); //$NON-NLS-1$
+        }
+
+        if (buffer == null) {
+            throw new IOException(Msg.getString("K0075")); //$NON-NLS-1$
+        }
+
+        /**
+         * Set the last thread to be reading on this PipedInputStream. If
+         * lastReader dies while someone is waiting to write an IOException of
+         * "Pipe broken" will be thrown in receive()
+         */
+        lastReader = Thread.currentThread();
+        try {
+            boolean first = true;
+            while (in == -1) {
+                // Are we at end of stream?
+                if (isClosed) {
+                    return -1;
+                }
+                if (!first && lastWriter != null && !lastWriter.isAlive()) {
+                    throw new IOException(Msg.getString("K0076")); //$NON-NLS-1$
                 }
+                first = false;
+                // Notify callers of receive()
+                notifyAll();
+                wait(1000);
+            }
+        } catch (InterruptedException e) {
+            throw new InterruptedIOException();
+        }
+
+        int copyLength = 0;
+        /* Copy bytes from out to end of buffer first */
+        if (out >= in) {
+            copyLength = count > (buffer.length - out) ? buffer.length - out
+                    : count;
+            System.arraycopy(buffer, out, bytes, offset, copyLength);
+            out += copyLength;
+            if (out == buffer.length) {
+                out = 0;
+            }
+            if (out == in) {
+                // empty buffer
+                in = -1;
+                out = 0;
+            }
+        }
+
+        /*
+         * Did the read fully succeed in the previous copy or is the buffer
+         * empty?
+         */
+        if (copyLength == count || in == -1) {
+            return copyLength;
+        }
+
+        int bytesCopied = copyLength;
+        /* Copy bytes from 0 to the number of available bytes */
+        copyLength = in - out > (count - bytesCopied) ? count - bytesCopied
+                : in - out;
+        System.arraycopy(buffer, out, bytes, offset + bytesCopied, copyLength);
+        out += copyLength;
+        if (out == in) {
+            // empty buffer
+            in = -1;
+            out = 0;
+        }
+        return bytesCopied + copyLength;
+    }
 
-				int bytesCopied = copyLength;
-				/* Copy bytes from 0 to the number of available bytes */
-				copyLength = in - out > (count - bytesCopied) ? count
-						- bytesCopied : in - out;
-				System.arraycopy(buffer, out, bytes, offset + bytesCopied,
-						copyLength);
-				out += copyLength;
-				if (out == in) {
-					// empty buffer
-					in = -1;
-					out = 0;
-				}
-				return bytesCopied + copyLength;
-			}
-			if (!isConnected) {
-				throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0074")); //$NON-NLS-1$
-			}
-			throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0075")); //$NON-NLS-1$
-		}
-		if (bytes == null) {
-			throw new NullPointerException();
-		}
-		throw new IndexOutOfBoundsException();
-	}
-
-	/**
-	 * Receives a byte and stores it into the PipedInputStream. This called by
-	 * PipedOutputStream.write() when writes occur. The lowest-order byte is
-	 * stored at index <code>in</code> in the <code>buffer</code>.
-	 * <P>
-	 * If the buffer is full and the thread sending #receive is interrupted, the
-	 * InterruptedIOException will be thrown.
-	 * 
-	 * @param oneByte
-	 *            the byte to store into the pipe.
-	 * 
-	 * @throws IOException
-	 *             If the stream is already closed or another IOException
-	 *             occurs.
-	 */
-	protected synchronized void receive(int oneByte) throws IOException {
-		if (buffer == null || isClosed) {
-		    throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0078")); //$NON-NLS-1$
-        }
-        if (lastReader != null && !lastReader.isAlive()){
-            throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0076")); //$NON-NLS-1$
-        }
-		/**
-		 * Set the last thread to be writing on this PipedInputStream. If
-		 * lastWriter dies while someone is waiting to read an IOException
-		 * of "Pipe broken" will be thrown in read()
-		 */
-		lastWriter = Thread.currentThread();
-		try {
-			while (buffer != null && out == in) {
-				notifyAll();
-				wait(1000);
-				if (lastReader != null && !lastReader.isAlive()) {
-                    throw new IOException(org.apache.harmony.luni.util.Msg
-							.getString("K0076")); //$NON-NLS-1$
+    /**
+     * Receives a byte and stores it into the PipedInputStream. This called by
+     * PipedOutputStream.write() when writes occur. The lowest-order byte is
+     * stored at index <code>in</code> in the <code>buffer</code>.
+     * <P>
+     * If the buffer is full and the thread sending #receive is interrupted, the
+     * InterruptedIOException will be thrown.
+     * 
+     * @param oneByte
+     *            the byte to store into the pipe.
+     * 
+     * @throws IOException
+     *             If the stream is already closed or another IOException
+     *             occurs.
+     */
+    protected synchronized void receive(int oneByte) throws IOException {
+        if (buffer == null || isClosed) {
+            throw new IOException(Msg.getString("K0078")); //$NON-NLS-1$
+        }
+        if (lastReader != null && !lastReader.isAlive()) {
+            throw new IOException(Msg.getString("K0076")); //$NON-NLS-1$
+        }
+        /**
+         * Set the last thread to be writing on this PipedInputStream. If
+         * lastWriter dies while someone is waiting to read an IOException of
+         * "Pipe broken" will be thrown in read()
+         */
+        lastWriter = Thread.currentThread();
+        try {
+            while (buffer != null && out == in) {
+                notifyAll();
+                wait(1000);
+                if (lastReader != null && !lastReader.isAlive()) {
+                    throw new IOException(Msg.getString("K0076")); //$NON-NLS-1$
                 }
-			}
-		} catch (InterruptedException e) {
-			throw new InterruptedIOException();
-		}
-		if (buffer != null) {
-			if (in == -1) {
+            }
+        } catch (InterruptedException e) {
+            throw new InterruptedIOException();
+        }
+        if (buffer != null) {
+            if (in == -1) {
                 in = 0;
             }
-			buffer[in++] = (byte) oneByte;
-			if (in == buffer.length) {
+            buffer[in++] = (byte) oneByte;
+            if (in == buffer.length) {
                 in = 0;
             }
-			return;
-		}
-	}
-
-	synchronized void done() {
-		isClosed = true;
-		notifyAll();
-	}
+            return;
+        }
+    }
 
+    synchronized void done() {
+        isClosed = true;
+        notifyAll();
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedOutputStream.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedOutputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedOutputStream.java Thu Jan  4 09:47:01 2007
@@ -68,7 +68,8 @@
      */
     @Override
     public void close() throws IOException {
-        if (dest != null) { // Is the pipe connected?
+        // Is the pipe connected?
+        if (dest != null) {
             dest.done();
             dest = null;
         }
@@ -88,19 +89,17 @@
         if (null == stream) {
             throw new NullPointerException();
         }
-        if (this.dest == null) {
-            synchronized (stream) {
-                if (!stream.isConnected) {
-                    stream.buffer = new byte[PipedInputStream.PIPE_SIZE];
-                    stream.isConnected = true;
-                    this.dest = stream;
-                } else {
-                    throw new IOException(Msg.getString("K007a")); //$NON-NLS-1$
-                }
-            }
-        } else {
+        if (this.dest != null) {
             throw new IOException(Msg.getString("K0079")); //$NON-NLS-1$
         }
+        synchronized (stream) {
+            if (stream.isConnected) {
+                throw new IOException(Msg.getString("K007a")); //$NON-NLS-1$
+            }
+            stream.buffer = new byte[PipedInputStream.PIPE_SIZE];
+            stream.isConnected = true;
+            this.dest = stream;
+        }
     }
 
     /**
@@ -178,10 +177,9 @@
      */
     @Override
     public void write(int oneByte) throws IOException {
-        if (dest != null) {
-            dest.receive(oneByte);
-        } else {
+        if (dest == null) {
             throw new IOException(Msg.getString("K007b")); //$NON-NLS-1$
         }
+        dest.receive(oneByte);
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedReader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedReader.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedReader.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedReader.java Thu Jan  4 09:47:01 2007
@@ -19,168 +19,166 @@
 
 import org.apache.harmony.luni.util.Msg;
 
-
 /**
  * PipedReader is a class which receives information on a communications pipe.
  * When two threads want to pass data back and forth, one creates a piped writer
  * and the other creates a piped reader.
- * 
  */
 public class PipedReader extends Reader {
-	private Thread lastReader;
-    
+
+    private Thread lastReader;
+
     private Thread lastWriter;
 
-	private boolean isClosed;
+    private boolean isClosed;
+
+    /**
+     * The circular buffer through which data is passed.
+     */
+    private char data[];
+
+    /**
+     * The index in <code>buffer</code> where the next character will be
+     * written.
+     */
+    private int in = -1;
+
+    /**
+     * The index in <code>buffer</code> where the next character will be read.
+     */
+    private int out;
+
+    /**
+     * The size of the default pipe in characters
+     */
+    private static final int PIPE_SIZE = 1024;
+
+    /**
+     * Indicates if this pipe is connected
+     */
+    private boolean isConnected;
+
+    /**
+     * Constructs a new unconnected PipedReader. The resulting Reader must be
+     * connected to a PipedWriter before data may be read from it.
+     */
+    public PipedReader() {
+        data = new char[PIPE_SIZE];
+    }
+
+    /**
+     * Constructs a new PipedReader connected to the PipedWriter
+     * <code>out</code>. Any data written to the writer can be read from the
+     * this reader.
+     * 
+     * @param out
+     *            the PipedWriter to connect to.
+     * 
+     * @throws IOException
+     *             if this or <code>out</code> are already connected.
+     */
+    public PipedReader(PipedWriter out) throws IOException {
+        this();
+        connect(out);
+    }
 
-	/**
-	 * The circular buffer through which data is passed.
-	 */
-	private char data[];
-
-	/**
-	 * The index in <code>buffer</code> where the next character will be
-	 * written.
-	 */
-	private int in = -1;
-
-	/**
-	 * The index in <code>buffer</code> where the next character will be read.
-	 */
-	private int out;
-
-	/**
-	 * The size of the default pipe in characters
-	 */
-	private static final int PIPE_SIZE = 1024;
-
-	/**
-	 * Indicates if this pipe is connected
-	 */
-	private boolean isConnected;
-
-	/**
-	 * Constructs a new unconnected PipedReader. The resulting Reader must be
-	 * connected to a PipedWriter before data may be read from it.
-	 */
-	public PipedReader() {
-		data = new char[PIPE_SIZE];
-	}
-
-	/**
-	 * Constructs a new PipedReader connected to the PipedWriter
-	 * <code>out</code>. Any data written to the writer can be read from the
-	 * this reader.
-	 * 
-	 * @param out
-	 *            the PipedWriter to connect to.
-	 * 
-	 * @throws IOException
-	 *             if this or <code>out</code> are already connected.
-	 */
-	public PipedReader(PipedWriter out) throws IOException {
-		this();
-		connect(out);
-	}
-
-	/**
-	 * Close this PipedReader. This implementation releases the buffer used for
-	 * the pipe and notifies all threads waiting to read or write.
-	 * 
-	 * @throws IOException
-	 *             If an error occurs attempting to close this reader.
-	 */
-	@Override
+    /**
+     * Close this PipedReader. This implementation releases the buffer used for
+     * the pipe and notifies all threads waiting to read or write.
+     * 
+     * @throws IOException
+     *             If an error occurs attempting to close this reader.
+     */
+    @Override
     public void close() throws IOException {
-		synchronized (lock) {
-			/* No exception thrown if already closed */
-			if (data != null) {
-				/* Release buffer to indicate closed. */
-				data = null;
-			}
-		}
-	}
-
-	/**
-	 * Connects this PipedReader to a PipedWriter. Any data written to the
-	 * Writer becomes available in this Reader.
-	 * 
-	 * @param src
-	 *            the source PipedWriter.
-	 * 
-	 * @throws IOException
-	 *             If either Writer or Reader is already connected.
-	 */
-	public void connect(PipedWriter src) throws IOException {
-		synchronized (lock) {
-			src.connect(this);
-		}
-	}
-
-	/**
-	 * Establish the connection to the PipedWriter.
-	 * 
-	 * @throws IOException
-	 *             If this Reader is already connected.
-	 */
-	void establishConnection() throws IOException {
-		synchronized (lock) {
-			if (data == null) {
+        synchronized (lock) {
+            /* No exception thrown if already closed */
+            if (data != null) {
+                /* Release buffer to indicate closed. */
+                data = null;
+            }
+        }
+    }
+
+    /**
+     * Connects this PipedReader to a PipedWriter. Any data written to the
+     * Writer becomes available in this Reader.
+     * 
+     * @param src
+     *            the source PipedWriter.
+     * 
+     * @throws IOException
+     *             If either Writer or Reader is already connected.
+     */
+    public void connect(PipedWriter src) throws IOException {
+        synchronized (lock) {
+            src.connect(this);
+        }
+    }
+
+    /**
+     * Establish the connection to the PipedWriter.
+     * 
+     * @throws IOException
+     *             If this Reader is already connected.
+     */
+    void establishConnection() throws IOException {
+        synchronized (lock) {
+            if (data == null) {
                 throw new IOException(Msg.getString("K0078")); //$NON-NLS-1$
             }
-			if (!isConnected) {
-				isConnected = true;
-			} else {
+            if (isConnected) {
                 throw new IOException(Msg.getString("K007a")); //$NON-NLS-1$
             }
-		}
-	}
+            isConnected = true;
+        }
+    }
 
-	/**
-	 * Reads the next character from this Reader. Answer the character actually
-	 * read or -1 if no character was read and end of reader was encountered.
-	 * Separate threads should be used for the reader of the PipedReader and the
-	 * PipedWriter. There may be undesirable results if more than one Thread
-	 * interacts a reader or writer pipe.
-	 * 
-	 * @return int the character read -1 if end of reader.
-	 * 
-	 * @throws IOException
-	 *             If the reader is already closed or another IOException
-	 *             occurs.
-	 */
-	@Override
+    /**
+     * Reads the next character from this Reader. Answer the character actually
+     * read or -1 if no character was read and end of reader was encountered.
+     * Separate threads should be used for the reader of the PipedReader and the
+     * PipedWriter. There may be undesirable results if more than one Thread
+     * interacts a reader or writer pipe.
+     * 
+     * @return int the character read -1 if end of reader.
+     * 
+     * @throws IOException
+     *             If the reader is already closed or another IOException
+     *             occurs.
+     */
+    @Override
     public int read() throws IOException {
-		char[] carray = new char[1];
-		int result = read(carray, 0, 1);
-		return result != -1 ? carray[0] : result;
-	}
-
-	/**
-	 * Reads at most <code>count</code> character from this PipedReader and
-	 * stores them in char array <code>buffer</code> starting at
-	 * <code>offset</code>. Answer the number of characters actually read or
-	 * -1 if no characters were read and end of stream was encountered. Separate
-	 * threads should be used for the reader of the PipedReader and the
-	 * PipedWriter. There may be undesirable results if more than one Thread
-	 * interacts a reader or writer pipe.
-	 * 
-	 * @param buffer
-	 *            the character array in which to store the read characters.
-	 * @param offset
-	 *            the offset in <code>buffer</code> to store the read
-	 *            characters.
-	 * @param count
-	 *            the maximum number of characters to store in
-	 *            <code>buffer</code>.
-	 * @return int the number of characters actually read or -1 if end of
-	 *         reader.
-	 * 
-	 * @throws IOException
-	 *             If the reader is already closed or another IOException
-	 *             occurs.
-	 */
-	@Override
+        char[] carray = new char[1];
+        int result = read(carray, 0, 1);
+        return result != -1 ? carray[0] : result;
+    }
+
+    /**
+     * Reads at most <code>count</code> character from this PipedReader and
+     * stores them in char array <code>buffer</code> starting at
+     * <code>offset</code>. Answer the number of characters actually read or
+     * -1 if no characters were read and end of stream was encountered. Separate
+     * threads should be used for the reader of the PipedReader and the
+     * PipedWriter. There may be undesirable results if more than one Thread
+     * interacts a reader or writer pipe.
+     * 
+     * @param buffer
+     *            the character array in which to store the read characters.
+     * @param offset
+     *            the offset in <code>buffer</code> to store the read
+     *            characters.
+     * @param count
+     *            the maximum number of characters to store in
+     *            <code>buffer</code>.
+     * @return int the number of characters actually read or -1 if end of
+     *         reader.
+     * 
+     * @throws IOException
+     *             If the reader is already closed or another IOException
+     *             occurs.
+     */
+    @Override
     public int read(char[] buffer, int offset, int count) throws IOException {
         synchronized (lock) {
             if (!isConnected) {
@@ -224,7 +222,8 @@
             int copyLength = 0;
             /* Copy chars from out to end of buffer first */
             if (out >= in) {
-                copyLength = count > data.length - out ? data.length - out : count;
+                copyLength = count > data.length - out ? data.length - out
+                        : count;
                 System.arraycopy(data, out, buffer, offset, copyLength);
                 out += copyLength;
                 if (out == data.length) {
@@ -247,7 +246,8 @@
 
             int charsCopied = copyLength;
             /* Copy bytes from 0 to the number of available bytes */
-            copyLength = in - out > count - copyLength ? count - copyLength : in - out;
+            copyLength = in - out > count - copyLength ? count - copyLength
+                    : in - out;
             System.arraycopy(data, out, buffer, offset + charsCopied,
                     copyLength);
             out += copyLength;
@@ -260,43 +260,45 @@
         }
     }
 
-	/**
-	 * Answer a boolean indicating whether or not this Reader is ready to be
-	 * read. Answers true if the buffer contains characters to be read.
-	 * 
-	 * @return boolean <code>true</code> if there are characters ready,
-	 *         <code>false</code> otherwise.
-	 *
-	 * @throws 		IOException If the reader is already closed or another IOException occurs.
-	 */
-	@Override
+    /**
+     * Answer a boolean indicating whether or not this Reader is ready to be
+     * read. Answers true if the buffer contains characters to be read.
+     * 
+     * @return boolean <code>true</code> if there are characters ready,
+     *         <code>false</code> otherwise.
+     * 
+     * @throws IOException
+     *             If the reader is already closed or another IOException
+     *             occurs.
+     */
+    @Override
     public boolean ready() throws IOException {
         synchronized (lock) {
-            if (isConnected) {
-                if (data != null) {
-                    return in != -1;
-                }
+            if (!isConnected) {
+                throw new IOException(Msg.getString("K007b")); //$NON-NLS-1$
+            }
+            if (data == null) {
                 throw new IOException(Msg.getString("K0078")); //$NON-NLS-1$
             }
-            throw new IOException(Msg.getString("K007b")); //$NON-NLS-1$
+            return in != -1;
         }
     }
 
-	/**
-	 * Receives a char and stores it into the PipedReader. This called by
-	 * PipedWriter.write() when writes occur.
-	 * <P>
-	 * If the buffer is full and the thread sending #receive is interrupted, the
-	 * InterruptedIOException will be thrown.
-	 * 
-	 * @param oneChar
-	 *            the char to store into the pipe.
-	 * 
-	 * @throws IOException
-	 *             If the stream is already closed or another IOException
-	 *             occurs.
-	 */
-	void receive(char oneChar) throws IOException {
+    /**
+     * Receives a char and stores it into the PipedReader. This called by
+     * PipedWriter.write() when writes occur.
+     * <P>
+     * If the buffer is full and the thread sending #receive is interrupted, the
+     * InterruptedIOException will be thrown.
+     * 
+     * @param oneChar
+     *            the char to store into the pipe.
+     * 
+     * @throws IOException
+     *             If the stream is already closed or another IOException
+     *             occurs.
+     */
+    void receive(char oneChar) throws IOException {
         synchronized (lock) {
             if (data == null) {
                 throw new IOException(Msg.getString("K0078")); //$NON-NLS-1$
@@ -334,25 +336,25 @@
         }
     }
 
-	/**
-	 * Receives a char array and stores it into the PipedReader. This called by
-	 * PipedWriter.write() when writes occur.
-	 * <P>
-	 * If the buffer is full and the thread sending #receive is interrupted, the
-	 * InterruptedIOException will be thrown.
-	 * 
-	 * @param chars
-	 *            the char array to store into the pipe.
-	 * @param offset
-	 *            offset to start reading from
-	 * @param count
-	 *            total characters to read
-	 * 
-	 * @throws IOException
-	 *             If the stream is already closed or another IOException
-	 *             occurs.
-	 */
-	void receive(char[] chars, int offset, int count) throws IOException {
+    /**
+     * Receives a char array and stores it into the PipedReader. This called by
+     * PipedWriter.write() when writes occur.
+     * <P>
+     * If the buffer is full and the thread sending #receive is interrupted, the
+     * InterruptedIOException will be thrown.
+     * 
+     * @param chars
+     *            the char array to store into the pipe.
+     * @param offset
+     *            offset to start reading from
+     * @param count
+     *            total characters to read
+     * 
+     * @throws IOException
+     *             If the stream is already closed or another IOException
+     *             occurs.
+     */
+    void receive(char[] chars, int offset, int count) throws IOException {
         synchronized (lock) {
             if (data == null) {
                 throw new IOException(Msg.getString("K0078")); //$NON-NLS-1$
@@ -414,16 +416,16 @@
         }
     }
 
-	void done() {
-		synchronized (lock) {
-			isClosed = true;
-			lock.notifyAll();
-		}
-	}
-
-	void flush() {
-		synchronized (lock) {
-			lock.notifyAll();
-		}
-	}
+    void done() {
+        synchronized (lock) {
+            isClosed = true;
+            lock.notifyAll();
+        }
+    }
+
+    void flush() {
+        synchronized (lock) {
+            lock.notifyAll();
+        }
+    }
 }