harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r432462 [14/21] - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/
Date Fri, 18 Aug 2006 01:45:39 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/ObjectStreamField.java Thu Aug 17 18:45:35 2006
@@ -1,315 +1,315 @@
-/* Copyright 1998, 2005 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;
-
-import java.lang.ref.WeakReference;
-import java.util.Arrays;
-import java.util.Comparator;
-
-/**
- * This class represents object fields that are saved to the stream, by
- * serialization. Classes can define the collection of fields to be dumped,
- * which can differ from the actual object's declared fields.
- * 
- * @see ObjectOutputStream#writeFields()
- * @see ObjectInputStream#readFields()
- * 
- */
-public class ObjectStreamField implements Comparable<Object> {
-
-	// Declared name of the field
-	private String name;
-
-	// Declared type of the field
-	private Object type;
-
-	// offset of this field in the object
-	int offset;
-
-	// Cached version of intern'ed type String
-	private String typeString;
-
-	private boolean unshared;
-
-	/**
-	 * 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('.', '/');
-	}
-
-	/**
-	 * 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());
-	}
-
-	/**
-	 * 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
-	 * 
-	 * @return A Class object representing the type of the field
-	 */
-	public Class<?> getType() {
-		if (type instanceof WeakReference) {
-			return (Class<?>)((WeakReference) type).get();
-		}
-		return (Class<?>) type;
-	}
-
-	/**
-	 * 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 = getType();
-		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 = getType();
-			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 = getType();
-		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.
-	 */
-	public String toString() {
-		return this.getClass().getName() + '(' + getName() + ':' + getType()
-				+ ')';
-	}
-
-	/**
-	 * 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;
-	}
-}
+/* Copyright 1998, 2005 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;
+
+import java.lang.ref.WeakReference;
+import java.util.Arrays;
+import java.util.Comparator;
+
+/**
+ * This class represents object fields that are saved to the stream, by
+ * serialization. Classes can define the collection of fields to be dumped,
+ * which can differ from the actual object's declared fields.
+ * 
+ * @see ObjectOutputStream#writeFields()
+ * @see ObjectInputStream#readFields()
+ * 
+ */
+public class ObjectStreamField implements Comparable<Object> {
+
+	// Declared name of the field
+	private String name;
+
+	// Declared type of the field
+	private Object type;
+
+	// offset of this field in the object
+	int offset;
+
+	// Cached version of intern'ed type String
+	private String typeString;
+
+	private boolean unshared;
+
+	/**
+	 * 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('.', '/');
+	}
+
+	/**
+	 * 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());
+	}
+
+	/**
+	 * 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
+	 * 
+	 * @return A Class object representing the type of the field
+	 */
+	public Class<?> getType() {
+		if (type instanceof WeakReference) {
+			return (Class<?>)((WeakReference) type).get();
+		}
+		return (Class<?>) type;
+	}
+
+	/**
+	 * 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 = getType();
+		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 = getType();
+			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 = getType();
+		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.
+	 */
+	public String toString() {
+		return this.getClass().getName() + '(' + getName() + ':' + getType()
+				+ ')';
+	}
+
+	/**
+	 * 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;
+	}
+}

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OptionalDataException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OptionalDataException.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OptionalDataException.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OptionalDataException.java Thu Aug 17 18:45:35 2006
@@ -1,57 +1,57 @@
-/* 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;
-/**
- * When readObject() encounters primitive types (int, char, etc) instead of an
- * object instance in the input stream, this type of exception will be thrown.
- * 
- * @see ObjectInputStream#available()
- * @see ObjectInputStream#readObject()
- * @see ObjectInputStream#skipBytes(int)
- */
-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);
-	}
-
-}
+/* 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;
+/**
+ * When readObject() encounters primitive types (int, char, etc) instead of an
+ * object instance in the input stream, this type of exception will be thrown.
+ * 
+ * @see ObjectInputStream#available()
+ * @see ObjectInputStream#readObject()
+ * @see ObjectInputStream#skipBytes(int)
+ */
+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);
+	}
+
+}

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStream.java Thu Aug 17 18:45:35 2006
@@ -1,118 +1,118 @@
-/* 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;
-
-
-/**
- * OutputStream is an abstract class for all byte output streams. It provides
- * basic method implementations for writing bytes to a stream.
- * 
- * @see InputStream
- */
-
-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;
-}
+/* 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;
+
+
+/**
+ * OutputStream is an abstract class for all byte output streams. It provides
+ * basic method implementations for writing bytes to a stream.
+ * 
+ * @see InputStream
+ */
+
+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;
+}

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/OutputStreamWriter.java Thu Aug 17 18:45:35 2006
@@ -1,308 +1,308 @@
-/* Copyright 2005, 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; 
-
-
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetEncoder;
-import java.nio.charset.CoderResult;
-import java.nio.charset.CodingErrorAction;
-import java.security.AccessController;
-
-import org.apache.harmony.luni.util.PriviAction;
-
-/**
- * OutputStreamWriter is a class for turning a character output stream into a
- * byte output stream. The conversion of Unicode characters to their byte
- * equivalents is determined by the converter used. By default, the encoding is
- * 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 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
-                .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);
-		enc.length();
-		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.
-	 */
-	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.
-	 */
-
-	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.
-	 */
-	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.
-	 */
-	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
-	 */
-	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);
-		}
-	}
-}
-
+/* Copyright 2005, 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; 
+
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.CodingErrorAction;
+import java.security.AccessController;
+
+import org.apache.harmony.luni.util.PriviAction;
+
+/**
+ * OutputStreamWriter is a class for turning a character output stream into a
+ * byte output stream. The conversion of Unicode characters to their byte
+ * equivalents is determined by the converter used. By default, the encoding is
+ * 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 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
+                .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);
+		enc.length();
+		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.
+	 */
+	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.
+	 */
+
+	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.
+	 */
+	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.
+	 */
+	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
+	 */
+	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);
+		}
+	}
+}
+

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java Thu Aug 17 18:45:35 2006
@@ -1,340 +1,340 @@
-/* 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;
-
-
-/**
- * PipedInputStream is a class which receives information on a communications
- * pipe. When two threads want to pass data back and forth, one creates a piped
- * output stream and the other creates a piped input stream.
- * 
- * @see PipedOutputStream
- */
-public class PipedInputStream extends InputStream {
-	private Thread lastReader, lastWriter;
-
-	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.
-	 */
-	public synchronized int available() throws IOException {
-		if (buffer == null || in == -1)
-			return 0;
-		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.
-	 */
-	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.
-	 */
-	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 (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.
-	 */
-	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 (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;
-
-				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$
-			}
-		} catch (InterruptedException e) {
-			throw new InterruptedIOException();
-		}
-		if (buffer != null) {
-			if (in == -1)
-				in = 0;
-			buffer[in++] = (byte) oneByte;
-			if (in == buffer.length)
-				in = 0;
-			return;
-		}
-	}
-
-	synchronized void done() {
-		isClosed = true;
-		notifyAll();
-	}
-
-}
+/* 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;
+
+
+/**
+ * PipedInputStream is a class which receives information on a communications
+ * pipe. When two threads want to pass data back and forth, one creates a piped
+ * output stream and the other creates a piped input stream.
+ * 
+ * @see PipedOutputStream
+ */
+public class PipedInputStream extends InputStream {
+	private Thread lastReader, lastWriter;
+
+	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.
+	 */
+	public synchronized int available() throws IOException {
+		if (buffer == null || in == -1)
+			return 0;
+		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.
+	 */
+	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.
+	 */
+	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 (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.
+	 */
+	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 (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;
+
+				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$
+			}
+		} catch (InterruptedException e) {
+			throw new InterruptedIOException();
+		}
+		if (buffer != null) {
+			if (in == -1)
+				in = 0;
+			buffer[in++] = (byte) oneByte;
+			if (in == buffer.length)
+				in = 0;
+			return;
+		}
+	}
+
+	synchronized void done() {
+		isClosed = true;
+		notifyAll();
+	}
+
+}

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedOutputStream.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedOutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedOutputStream.java Thu Aug 17 18:45:35 2006
@@ -1,182 +1,182 @@
-/* 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;
-
-import org.apache.harmony.luni.util.Msg;
-
-/**
- * PipedOutputStream is a class which places information on a communications
- * pipe. When two threads want to pass data back and forth, one creates a piped
- * output stream and the other creates a piped input stream.
- * 
- * @see PipedInputStream
- */
-public class PipedOutputStream extends OutputStream {
-
-    /**
-     * The destination PipedInputStream
-     */
-    private PipedInputStream dest;
-
-    /**
-     * Constructs a new unconnected PipedOutputStream. The resulting Stream must
-     * be connected to a PipedInputStream before data may be written to it.
-     */
-    public PipedOutputStream() {
-        super();
-    }
-
-    /**
-     * Constructs a new PipedOutputStream connected to the PipedInputStream
-     * <code>dest</code>. Any data written to this stream can be read from
-     * the <code>dest</code>.
-     * 
-     * @param dest
-     *            the PipedInputStream to connect to.
-     * 
-     * @throws IOException
-     *             if <code>dest</code> is already connected.
-     */
-    public PipedOutputStream(PipedInputStream dest) throws IOException {
-        super();
-        connect(dest);
-    }
-
-    /**
-     * Close this PipedOutputStream. Any data buffered in the corresponding
-     * PipedInputStream can be read, then -1 will be returned to the reader. If
-     * this OutputStream is not connected, this method does nothing.
-     * 
-     * @throws IOException
-     *             If an error occurs attempting to close this
-     *             PipedOutputStream.
-     */
-    @Override
-    public void close() throws IOException {
-        if (dest != null) { // Is the pipe connected?
-            dest.done();
-            dest = null;
-        }
-    }
-
-    /**
-     * Connects this PipedOutputStream to a PipedInputStream. Any data written
-     * to this OutputStream becomes readable in the InputStream.
-     * 
-     * @param stream
-     *            the destination PipedInputStream.
-     * 
-     * @throws IOException
-     *             If this Stream or the dest is already connected.
-     */
-    public void connect(PipedInputStream stream) throws IOException {
-        if (null == stream) {
-            throw new NullPointerException();
-        }
-        if (this.dest == null) {
-            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 {
-            throw new IOException(Msg.getString("K0079")); //$NON-NLS-1$
-        }
-    }
-
-    /**
-     * Notifies the readers on the PipedInputStream that bytes can be read. This
-     * method does nothing if this Stream is not connected.
-     * 
-     * @throws IOException
-     *             If an IO error occurs during the flush.
-     */
-    @Override
-    public void flush() throws IOException {
-        if (dest != null) {
-            synchronized (dest) {
-                dest.notifyAll();
-            }
-        }
-    }
-
-    /**
-     * Writes <code>count</code> <code>bytes</code> from this byte array
-     * <code>buffer</code> starting at offset <code>index</code> to this
-     * PipedOutputStream. The written data can now be read from the destination
-     * PipedInputStream. 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 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 the receiving thread was terminated without closing the
-     *             pipe. This case is not currently handled correctly.
-     * @throws InterruptedIOException
-     *             If the pipe is full and the current thread is interrupted
-     *             waiting for space to write data. This case is not currently
-     *             handled correctly.
-     * @throws NullPointerException
-     *             If the receiver has not been connected yet.
-     * @throws IllegalArgumentException
-     *             If any of the arguments are out of bounds.
-     */
-    @Override
-    public void write(byte buffer[], int offset, int count) throws IOException {
-        if (dest == null) {
-            throw new IOException("Pipe not connected.");
-        }
-        super.write(buffer, offset, count);
-    }
-
-    /**
-     * Writes the specified byte <code>oneByte</code> to this
-     * PipedOutputStream. Only the low order byte of <code>oneByte</code> is
-     * written. The data can now be read from the destination PipedInputStream.
-     * 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 oneByte
-     *            the byte to be written
-     * 
-     * @throws IOException
-     *             If the receiving thread was terminated without closing the
-     *             pipe. This case is not currently handled correctly.
-     * @throws InterruptedIOException
-     *             If the pipe is full and the current thread is interrupted
-     *             waiting for space to write data. This case is not currently
-     *             handled correctly.
-     * @throws NullPointerException
-     *             If the receiver has not been connected yet.
-     */
-    @Override
-    public void write(int oneByte) throws IOException {
-        if (dest != null) {
-            dest.receive(oneByte);
-        } else {
-            throw new IOException(Msg.getString("K007b")); //$NON-NLS-1$
-        }
-    }
-}
+/* 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;
+
+import org.apache.harmony.luni.util.Msg;
+
+/**
+ * PipedOutputStream is a class which places information on a communications
+ * pipe. When two threads want to pass data back and forth, one creates a piped
+ * output stream and the other creates a piped input stream.
+ * 
+ * @see PipedInputStream
+ */
+public class PipedOutputStream extends OutputStream {
+
+    /**
+     * The destination PipedInputStream
+     */
+    private PipedInputStream dest;
+
+    /**
+     * Constructs a new unconnected PipedOutputStream. The resulting Stream must
+     * be connected to a PipedInputStream before data may be written to it.
+     */
+    public PipedOutputStream() {
+        super();
+    }
+
+    /**
+     * Constructs a new PipedOutputStream connected to the PipedInputStream
+     * <code>dest</code>. Any data written to this stream can be read from
+     * the <code>dest</code>.
+     * 
+     * @param dest
+     *            the PipedInputStream to connect to.
+     * 
+     * @throws IOException
+     *             if <code>dest</code> is already connected.
+     */
+    public PipedOutputStream(PipedInputStream dest) throws IOException {
+        super();
+        connect(dest);
+    }
+
+    /**
+     * Close this PipedOutputStream. Any data buffered in the corresponding
+     * PipedInputStream can be read, then -1 will be returned to the reader. If
+     * this OutputStream is not connected, this method does nothing.
+     * 
+     * @throws IOException
+     *             If an error occurs attempting to close this
+     *             PipedOutputStream.
+     */
+    @Override
+    public void close() throws IOException {
+        if (dest != null) { // Is the pipe connected?
+            dest.done();
+            dest = null;
+        }
+    }
+
+    /**
+     * Connects this PipedOutputStream to a PipedInputStream. Any data written
+     * to this OutputStream becomes readable in the InputStream.
+     * 
+     * @param stream
+     *            the destination PipedInputStream.
+     * 
+     * @throws IOException
+     *             If this Stream or the dest is already connected.
+     */
+    public void connect(PipedInputStream stream) throws IOException {
+        if (null == stream) {
+            throw new NullPointerException();
+        }
+        if (this.dest == null) {
+            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 {
+            throw new IOException(Msg.getString("K0079")); //$NON-NLS-1$
+        }
+    }
+
+    /**
+     * Notifies the readers on the PipedInputStream that bytes can be read. This
+     * method does nothing if this Stream is not connected.
+     * 
+     * @throws IOException
+     *             If an IO error occurs during the flush.
+     */
+    @Override
+    public void flush() throws IOException {
+        if (dest != null) {
+            synchronized (dest) {
+                dest.notifyAll();
+            }
+        }
+    }
+
+    /**
+     * Writes <code>count</code> <code>bytes</code> from this byte array
+     * <code>buffer</code> starting at offset <code>index</code> to this
+     * PipedOutputStream. The written data can now be read from the destination
+     * PipedInputStream. 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 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 the receiving thread was terminated without closing the
+     *             pipe. This case is not currently handled correctly.
+     * @throws InterruptedIOException
+     *             If the pipe is full and the current thread is interrupted
+     *             waiting for space to write data. This case is not currently
+     *             handled correctly.
+     * @throws NullPointerException
+     *             If the receiver has not been connected yet.
+     * @throws IllegalArgumentException
+     *             If any of the arguments are out of bounds.
+     */
+    @Override
+    public void write(byte buffer[], int offset, int count) throws IOException {
+        if (dest == null) {
+            throw new IOException("Pipe not connected.");
+        }
+        super.write(buffer, offset, count);
+    }
+
+    /**
+     * Writes the specified byte <code>oneByte</code> to this
+     * PipedOutputStream. Only the low order byte of <code>oneByte</code> is
+     * written. The data can now be read from the destination PipedInputStream.
+     * 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 oneByte
+     *            the byte to be written
+     * 
+     * @throws IOException
+     *             If the receiving thread was terminated without closing the
+     *             pipe. This case is not currently handled correctly.
+     * @throws InterruptedIOException
+     *             If the pipe is full and the current thread is interrupted
+     *             waiting for space to write data. This case is not currently
+     *             handled correctly.
+     * @throws NullPointerException
+     *             If the receiver has not been connected yet.
+     */
+    @Override
+    public void write(int oneByte) throws IOException {
+        if (dest != null) {
+            dest.receive(oneByte);
+        } else {
+            throw new IOException(Msg.getString("K007b")); //$NON-NLS-1$
+        }
+    }
+}

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



Mime
View raw message