harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r440908 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util: Inet6Util.java PasswordProtectedInputStream.java PositionedInputStream.java SHAOutputStream.java Sorter.java
Date Thu, 07 Sep 2006 00:02:13 GMT
Author: ndbeyer
Date: Wed Sep  6 17:02:12 2006
New Revision: 440908

URL: http://svn.apache.org/viewvc?view=rev&rev=440908
Log:
Code cleanup; add braces, remove unecessary initialization and compiler warnings

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PasswordProtectedInputStream.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PositionedInputStream.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/SHAOutputStream.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Sorter.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java?view=diff&rev=440908&r1=440907&r2=440908
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Inet6Util.java
Wed Sep  6 17:02:12 2006
@@ -15,7 +15,6 @@
 
 package org.apache.harmony.luni.util;
 
-
 import java.util.ArrayList;
 import java.util.StringTokenizer;
 
@@ -32,8 +31,7 @@
 			String ipAddressString) {
 
 		if (isValidIPV4Address(ipAddressString)) {
-			StringTokenizer tokenizer = new StringTokenizer(ipAddressString,
-					".");
+            StringTokenizer tokenizer = new StringTokenizer(ipAddressString, ".");
 			String token = "";
 			int tempInt = 0;
 			byte[] byteAddress = new byte[4];
@@ -47,24 +45,23 @@
 		}
 		
 		if (ipAddressString.charAt(0) == '[') {
-			ipAddressString = ipAddressString.substring(1, ipAddressString
-					.length() - 1);
-		}
+            ipAddressString = ipAddressString.substring(1, ipAddressString.length() - 1);
+        }
 
-		StringTokenizer tokenizer = new StringTokenizer(ipAddressString,
-				":.", true);
-		ArrayList<String> hexStrings = new ArrayList<String>();
-		ArrayList<String> decStrings = new ArrayList<String>();
-		String token = "";
-		String prevToken = "";
-		int doubleColonIndex = -1; // If a double colon exists, we need to
-									// insert 0s.
-
-		// Go through the tokens, including the seperators ':' and '.'
-		// When we hit a : or . the previous token will be added to either
-		// the hex list or decimal list. In the case where we hit a ::
-		// we will save the index of the hexStrings so we can add zeros
-		// in to fill out the string
+        StringTokenizer tokenizer = new StringTokenizer(ipAddressString, ":.", true);
+        ArrayList<String> hexStrings = new ArrayList<String>();
+        ArrayList<String> decStrings = new ArrayList<String>();
+        String token = "";
+        String prevToken = "";
+        // If a double colon exists, we need to insert 0s.
+        int doubleColonIndex = -1;
+
+        /*
+         * Go through the tokens, including the separators ':' and '.' When we
+         * hit a : or . the previous token will be added to either the hex list
+         * or decimal list. In the case where we hit a :: we will save the index
+         * of the hexStrings so we can add zeros in to fill out the string
+         */
 		while (tokenizer.hasMoreTokens()) {
 			prevToken = token;
 			token = tokenizer.nextToken();
@@ -112,14 +109,13 @@
 
 		// Finally convert these strings to bytes...
 		for (int i = 0; i < hexStrings.size(); i++) {
-			convertToBytes((String) hexStrings.get(i), ipByteArray, i * 2);
+			convertToBytes(hexStrings.get(i), ipByteArray, i * 2);
 		}
 
 		// Now if there are any decimal values, we know where they go...
 		for (int i = 0; i < decStrings.size(); i++) {
-			ipByteArray[i + 12] = (byte) (Integer
-					.parseInt((String) decStrings.get(i)) & 255);
-		}
+            ipByteArray[i + 12] = (byte) (Integer.parseInt(decStrings.get(i)) & 255);
+        }
 
 		// now check to see if this guy is actually and IPv4 address
 		// an ipV4 address is ::FFFF:d.d.d.d
@@ -161,19 +157,18 @@
 					ipv4ByteArray[i] = ipByteArray[i + 12];
 				}
 				return addressToString(bytesToInt(ipv4ByteArray, 0));
-			} else {
-				StringBuffer buffer = new StringBuffer();
-				for (int i = 0; i < ipByteArray.length; i++) {
-					int j = (ipByteArray[i] & 0xf0) >>> 4;
-					buffer.append(hexCharacters.charAt(j));
-					j = ipByteArray[i] & 0x0f;
-					buffer.append(hexCharacters.charAt(j));
-					if (i % 2 != 0 && (i + 1) < ipByteArray.length) {
-						buffer.append(":");
-					}
-				}
-				return buffer.toString();
 			}
+            StringBuilder buffer = new StringBuilder();
+            for (int i = 0; i < ipByteArray.length; i++) {
+            	int j = (ipByteArray[i] & 0xf0) >>> 4;
+            	buffer.append(hexCharacters.charAt(j));
+            	j = ipByteArray[i] & 0x0f;
+            	buffer.append(hexCharacters.charAt(j));
+            	if (i % 2 != 0 && (i + 1) < ipByteArray.length) {
+            		buffer.append(":");
+            	}
+            }
+            return buffer.toString();
 		}
 		return null;
 	}
@@ -306,10 +301,11 @@
 		String word = "";
 		char c = 0;
 		char prevChar = 0;
-		int offset = 0; // offset for [] ip addresses
+		int offset = 0; // offset for [] IP addresses
 
-		if (length < 2)
-			return false;
+		if (length < 2) {
+            return false;
+        }
 
 		for (int i = 0; i < length; i++) {
 			prevChar = c;
@@ -318,56 +314,69 @@
 
 			// case for an open bracket [x:x:x:...x]
 			case '[':
-				if (i != 0)
-					return false; // must be first character
-				if (ipAddress.charAt(length - 1) != ']')
-					return false; // must have a close ]
+				if (i != 0) {
+                    return false; // must be first character
+                }
+				if (ipAddress.charAt(length - 1) != ']') {
+                    return false; // must have a close ]
+                }
 				offset = 1;
-				if (length < 4)
-					return false;
+				if (length < 4) {
+                    return false;
+                }
 				break;
 
 			// case for a closed bracket at end of IP [x:x:x:...x]
 			case ']':
-				if (i != length - 1)
-					return false; // must be last charcter
-				if (ipAddress.charAt(0) != '[')
-					return false; // must have a open [
+				if (i != length - 1) {
+                    return false; // must be last character
+                }
+				if (ipAddress.charAt(0) != '[') {
+                    return false; // must have a open [
+                }
 				break;
 
 			// case for the last 32-bits represented as IPv4 x:x:x:x:x:x:d.d.d.d
 			case '.':
 				numberOfPeriods++;
-				if (numberOfPeriods > 3)
-					return false;
-				if (!isValidIP4Word(word))
-					return false;
-				if (numberOfColons != 6 && !doubleColon)
-					return false;
+				if (numberOfPeriods > 3) {
+                    return false;
+                }
+				if (!isValidIP4Word(word)) {
+                    return false;
+                }
+				if (numberOfColons != 6 && !doubleColon) {
+                    return false;
+                }
 				// a special case ::1:2:3:4:5:d.d.d.d allows 7 colons with an
 				// IPv4 ending, otherwise 7 :'s is bad
 				if (numberOfColons == 7 && ipAddress.charAt(0 + offset) != ':'
-						&& ipAddress.charAt(1 + offset) != ':')
-					return false;
+						&& ipAddress.charAt(1 + offset) != ':') {
+                    return false;
+                }
 				word = "";
 				break;
 
 			case ':':
 				numberOfColons++;
-				if (numberOfColons > 7)
-					return false;
-				if (numberOfPeriods > 0)
-					return false;
+				if (numberOfColons > 7) {
+                    return false;
+                }
+				if (numberOfPeriods > 0) {
+                    return false;
+                }
 				if (prevChar == ':') {
-					if (doubleColon)
-						return false;
+					if (doubleColon) {
+                        return false;
+                    }
 					doubleColon = true;
 				}
 				word = "";
 				break;
 			case '%':
-				if (numberOfColons == 0)
-					return false;
+				if (numberOfColons == 0) {
+                    return false;
+                }
 				numberOfPercent++;
 
 				// validate that the stuff after the % is valid
@@ -388,10 +397,12 @@
 
 			default:
 				if (numberOfPercent == 0) {
-					if (word.length() > 3)
-						return false;
-					if (!isValidHexChar(c))
-						return false;
+					if (word.length() > 3) {
+                        return false;
+                    }
+					if (!isValidHexChar(c)) {
+                        return false;
+                    }
 				}
 				word += c;
 			}
@@ -399,8 +410,9 @@
 
 		// Check if we have an IPv4 ending
 		if (numberOfPeriods > 0) {
-			if (numberOfPeriods != 3 || !isValidIP4Word(word))
-				return false;
+			if (numberOfPeriods != 3 || !isValidIP4Word(word)) {
+                return false;
+            }
 		} else {
 			// If we're at then end and we haven't had 7 colons then there is a
 			// problem unless we encountered a doubleColon
@@ -424,15 +436,18 @@
 
 	public static boolean isValidIP4Word(String word) {
 		char c;
-		if (word.length() < 1 || word.length() > 3)
-			return false;
+		if (word.length() < 1 || word.length() > 3) {
+            return false;
+        }
 		for (int i = 0; i < word.length(); i++) {
 			c = word.charAt(i);
-			if (!(c >= '0' && c <= '9'))
-				return false;
-		}
-		if (Integer.parseInt(word) > 255)
-			return false;
+			if (!(c >= '0' && c <= '9')) {
+                return false;
+            }
+		}
+		if (Integer.parseInt(word) > 255) {
+            return false;
+        }
 		return true;
 	}
 
@@ -454,34 +469,41 @@
 		int i = 0;
 		int length = value.length();
 
-		if (length > 15)
-			return false;
+		if (length > 15) {
+            return false;
+        }
 		char c = 0;
 		String word = "";
 		for (i = 0; i < length; i++) {
 			c = value.charAt(i);
 			if (c == '.') {
 				periods++;
-				if (periods > 3)
-					return false;
-				if (word == "")
-					return false;
-				if (Integer.parseInt(word) > 255)
-					return false;
+				if (periods > 3) {
+                    return false;
+                }
+				if (word == "") {
+                    return false;
+                }
+				if (Integer.parseInt(word) > 255) {
+                    return false;
+                }
 				word = "";
-			} else if (!(Character.isDigit(c)))
-				return false;
-			else {
-				if (word.length() > 2)
-					return false;
+			} else if (!(Character.isDigit(c))) {
+                return false;
+            } else {
+				if (word.length() > 2) {
+                    return false;
+                }
 				word += c;
 			}
 		}
 
-		if (word == "" || Integer.parseInt(word) > 255)
-			return false;
-		if (periods != 3)
-			return false;
+		if (word == "" || Integer.parseInt(word) > 255) {
+            return false;
+        }
+		if (periods != 3) {
+            return false;
+        }
 		return true;
 	}
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PasswordProtectedInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PasswordProtectedInputStream.java?view=diff&rev=440908&r1=440907&r2=440908
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PasswordProtectedInputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PasswordProtectedInputStream.java
Wed Sep  6 17:02:12 2006
@@ -15,7 +15,6 @@
 
 package org.apache.harmony.luni.util;
 
-
 import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -27,76 +26,48 @@
  */
 public class PasswordProtectedInputStream extends FilterInputStream {
 
-	private byte[] password; // Password to use to decrypt the input bytes
+    private byte[] password; // Password to use to decrypt the input bytes
 
-	private int pwdIndex = 0; // Index into the password array.
+    private int pwdIndex; // Index into the password array.
 
-	/**
-	 * Constructs a new instance of the receiver.
-	 * 
-	 * @param in
-	 *            java.io.InputStream The actual input stream where to read the
-	 *            bytes from.
-	 * @param password
-	 *            byte[] password bytes to use to decrypt the input bytes
-	 */
-	public PasswordProtectedInputStream(InputStream in, byte[] password) {
-		super(in);
-		this.password = password;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.InputStream#read()
-	 */
-	public int read() throws IOException {
-		int read = in.read();
-		if (read >= 0) {
-			read ^= password[pwdIndex];
-			pwdIndex = (pwdIndex + 1) % password.length;
-		}
-		return read;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.InputStream#read(byte[], int, int)
-	 */
-	public int read(byte b[], int off, int len) throws IOException {
-		int read = in.read(b, off, len);
-		if (read > 0) {
-			int lastIndex = off + read;
-			for (int i = off; i < lastIndex; i++) {
-				b[i] ^= password[pwdIndex];
-				pwdIndex = (pwdIndex + 1) % password.length;
-			}
-		}
-		return read;
-	}
-
-	/**
-	 * Skips over and discards <code>n</code> bytes of data from the input
-	 * stream. The <code>skip</code> method may, for a variety of reasons, end
-	 * up skipping over some smaller number of bytes, possibly <code>0</code>.
-	 * The actual number of bytes skipped is returned.
-	 * <p>
-	 * The <code>skip </code>method of <code>FilterInputStream</code>
calls
-	 * the <code>skip</code> method of its underlying input stream with the
-	 * same argument, and returns whatever value that method does.
-	 * 
-	 * @param n
-	 *            the number of bytes to be skipped.
-	 * @return the actual number of bytes skipped.
-	 * @exception IOException
-	 *                if an I/O error occurs.
-	 * @since JDK1.0
-	 */
-
-	public long skip(long n) throws IOException {
-		long skip = super.skip(n);
-		pwdIndex += skip;
-		return skip;
-	}
+    /**
+     * Constructs a new instance of the receiver.
+     * 
+     * @param in The actual input stream where to read the bytes from.
+     * @param password The password bytes to use to decrypt the input bytes
+     */
+    public PasswordProtectedInputStream(InputStream in, byte[] password) {
+        super(in);
+        this.password = password;
+    }
+
+    @Override
+    public int read() throws IOException {
+        int read = in.read();
+        if (read >= 0) {
+            read ^= password[pwdIndex];
+            pwdIndex = (pwdIndex + 1) % password.length;
+        }
+        return read;
+    }
+
+    @Override
+    public int read(byte b[], int off, int len) throws IOException {
+        int read = in.read(b, off, len);
+        if (read > 0) {
+            int lastIndex = off + read;
+            for (int i = off; i < lastIndex; i++) {
+                b[i] ^= password[pwdIndex];
+                pwdIndex = (pwdIndex + 1) % password.length;
+            }
+        }
+        return read;
+    }
+
+    @Override
+    public long skip(long n) throws IOException {
+        long skip = super.skip(n);
+        pwdIndex += skip;
+        return skip;
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PositionedInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PositionedInputStream.java?view=diff&rev=440908&r1=440907&r2=440908
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PositionedInputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/PositionedInputStream.java
Wed Sep  6 17:02:12 2006
@@ -15,79 +15,66 @@
 
 package org.apache.harmony.luni.util;
 
-
 import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
 /**
- * This class implements a Stream whose position can be querried for.
+ * This class implements a Stream whose position can be queried for.
  */
 public class PositionedInputStream extends FilterInputStream {
 
-	int currentPosition = 0; // Current position on the underlying stream
+    private int currentPosition; // Current position on the underlying stream
 
-	/**
-	 * Constructs a new instance of the receiver.
-	 * 
-	 * @param in
-	 *            java.io.InputStream The actual input stream where to read the
-	 *            bytes from.
-	 */
-	public PositionedInputStream(InputStream in) {
-		super(in);
-	}
-
-	/**
-	 * Return the current position in the receiver
-	 * 
-	 * @return int The current position in the receiver
-	 */
-	public int currentPosition() {
-		return currentPosition;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.InputStream#read()
-	 */
-	public int read() throws IOException {
-		int read = in.read();
-		if (read >= 0)
-			currentPosition++;
-		return read;
-
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.InputStream#read(byte[], int, int)
-	 */
-	public int read(byte b[], int off, int len) throws IOException {
-		int read = in.read(b, off, len);
-		if (read >= 0)
-			currentPosition += read;
-		return read;
-	}
-
-	/**
-	 * Makes the current position on the underlying stream be assigned relative
-	 * position zero.
-	 */
-	public void resetCurrentPosition() {
-		currentPosition = 0;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.io.InputStream#skip(long)
-	 */
-	public long skip(long n) throws IOException {
-		long skip = in.skip(n);
-		currentPosition += skip; // Maybe currentPosition should be long ?
-		return skip;
-	}
+    /**
+     * Constructs a new instance of the receiver.
+     * 
+     * @param in The actual input stream where to read the bytes from.
+     */
+    public PositionedInputStream(InputStream in) {
+        super(in);
+    }
+
+    /**
+     * Return the current position in the receiver
+     * 
+     * @return int The current position in the receiver
+     */
+    public int currentPosition() {
+        return currentPosition;
+    }
+
+    @Override
+    public int read() throws IOException {
+        int read = in.read();
+        if (read >= 0) {
+            currentPosition++;
+        }
+        return read;
+
+    }
+
+    @Override
+    public int read(byte b[], int off, int len) throws IOException {
+        int read = in.read(b, off, len);
+        if (read >= 0) {
+            currentPosition += read;
+        }
+        return read;
+    }
+
+    /**
+     * Makes the current position on the underlying stream be assigned relative
+     * position zero.
+     */
+    public void resetCurrentPosition() {
+        currentPosition = 0;
+    }
+
+    @Override
+    public long skip(long n) throws IOException {
+        long skip = in.skip(n);
+        currentPosition += skip; // Maybe currentPosition should be long ?
+        return skip;
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/SHAOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/SHAOutputStream.java?view=diff&rev=440908&r1=440907&r2=440908
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/SHAOutputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/SHAOutputStream.java
Wed Sep  6 17:02:12 2006
@@ -24,24 +24,6 @@
  */
 public class SHAOutputStream extends OutputStream implements Cloneable {
 
-	// 5-word Array. Starts with well-known constants, ends with SHA
-	private int[] HConstants;
-
-	// 80-word Array.
-	private int[] WArray;
-
-	// 16-word Array. Input bit stream M is divided in chunks of MArray
-	private byte[] MArray;
-
-	// Number of bytes of input already processed towards SHA result
-	private long bytesProcessed;
-
-	// Number of bytes in WArray not processed yet
-	private int bytesToProcess;
-
-	// Optimization, for write
-	private byte[] oneByte = new byte[1];
-
 	/* Constants as in the specification */
 
 	// K in iterations 0..19, from spec
@@ -80,6 +62,24 @@
 
 	// 80 words
 	private static final int WArraySize = 80;
+    
+    // 5-word Array. Starts with well-known constants, ends with SHA
+    private int[] HConstants;
+
+    // 80-word Array.
+    private int[] WArray;
+
+    // 16-word Array. Input bit stream M is divided in chunks of MArray
+    private byte[] MArray;
+
+    // Number of bytes of input already processed towards SHA result
+    private long bytesProcessed;
+
+    // Number of bytes in WArray not processed yet
+    private int bytesToProcess;
+
+    // Optimization, for write
+    private byte[] oneByte = new byte[1];
 
 	/**
 	 * Constructs a new SHAOutputStream.
@@ -91,15 +91,13 @@
 	}
 
 	/**
-	 * Constructs a new MD5OutputStream with the given initial state.
-	 * 
-	 * @param state
-	 *            The initial state of the output stream. This is what will be
-	 *            returned by getHash() if write() is never called.
-	 * 
-	 * @exception IllegalArgumentException
-	 *                if state.length is less than 16.
-	 */
+     * Constructs a new MD5OutputStream with the given initial state.
+     * 
+     * @param state The initial state of the output stream. This is what will be
+     *        returned by getHash() if write() is never called.
+     * 
+     * @throws IllegalArgumentException if state.length is less than 16.
+     */
 	public SHAOutputStream(byte[] state) {
 		this();
 
@@ -116,39 +114,36 @@
 	}
 
 	/**
-	 * Answers a new instance of the same class as the receiver, whose slots
-	 * have been filled in with the values in the slots of the receiver.
-	 * <p>
-	 * Classes which wish to support cloning must specify that they implement
-	 * the Cloneable interface, since the native implementation checks for this.
-	 * 
-	 * @return a complete copy of this object
-	 * @exception CloneNotSupportedException
-	 *                if the component does not implement the interface
-	 *                Cloneable
-	 */
-	public Object clone() throws CloneNotSupportedException {
+     * Answers a new instance of the same class as the receiver, whose slots
+     * have been filled in with the values in the slots of the receiver.
+     * <p>
+     * Classes which wish to support cloning must specify that they implement
+     * the Cloneable interface, since the native implementation checks for this.
+     * 
+     * @return a complete copy of this object
+     * @throws CloneNotSupportedException if the component does not implement
+     *         the interface Cloneable
+     */
+	@Override
+    public Object clone() throws CloneNotSupportedException {
 		// Calling super takes care of primitive type slots
 		SHAOutputStream result = (SHAOutputStream) super.clone();
-		result.HConstants = (int[]) this.HConstants.clone();
-		result.WArray = (int[]) this.WArray.clone();
-		result.MArray = (byte[]) this.MArray.clone();
-		result.oneByte = (byte[]) this.oneByte.clone();
+		result.HConstants = this.HConstants.clone();
+		result.WArray = this.WArray.clone();
+		result.MArray = this.MArray.clone();
+		result.oneByte = this.oneByte.clone();
 		return result;
 	}
 
 	/**
-	 * Copies a byte array into the receiver's internal buffer, making the
-	 * adjustments as necessary and keeping the receiver in a consistent state.
-	 * 
-	 * @param buffer
-	 *            byte array representation of the bytes
-	 * @param off
-	 *            offset into the source buffer where to start the copying
-	 * @param len
-	 *            how many bytes in the source byte array to copy
-	 * 
-	 */
+     * Copies a byte array into the receiver's internal buffer, making the
+     * adjustments as necessary and keeping the receiver in a consistent state.
+     * 
+     * @param buffer byte array representation of the bytes
+     * @param off offset into the source buffer where to start the copying
+     * @param len how many bytes in the source byte array to copy
+     * 
+     */
 	private void copyToInternalBuffer(byte[] buffer, int off, int len) {
 		int index;
 		index = off;
@@ -160,16 +155,16 @@
 	}
 
 	/**
-	 * Returns an int array (length = 5) with the SHA value of the bytes written
-	 * to the receiver.
-	 * 
-	 * @return int[] The 5 ints that form the SHA value of the bytes written to
-	 *         the receiver
-	 */
+     * Returns an int array (length = 5) with the SHA value of the bytes written
+     * to the receiver.
+     * 
+     * @return The 5 ints that form the SHA value of the bytes written to
+     *         the receiver
+     */
 	public int[] getHash() {
 		this.padBuffer();
 		this.processBuffer();
-		int[] result = (int[]) HConstants.clone();
+		int[] result = HConstants.clone();
 		// After the user asks for the hash value, the stream is put back to the
 		// initial state
 		reset();
@@ -180,7 +175,7 @@
 	 * Returns a byte array (length = 20) with the SHA value of the bytes
 	 * written to the receiver.
 	 * 
-	 * @return byte[] The bytes that form the SHA value of the bytes written to
+	 * @return The bytes that form the SHA value of the bytes written to
 	 *         the receiver
 	 */
 	public byte[] getHashAsBytes() {
@@ -206,7 +201,7 @@
 	 * Returns a byte array (length = 20) with the SHA value of the bytes
 	 * written to the receiver.
 	 * 
-	 * @return byte[] The bytes that form the SHA value of the bytes written to
+	 * @return The bytes that form the SHA value of the bytes written to
 	 *         the receiver
 	 */
 	public byte[] getHashAsBytes(boolean pad) {
@@ -371,16 +366,10 @@
 		bytesToProcess = 0;
 	}
 
-	/**
-	 * 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() + ':'
-				+ toStringBlock(getHashAsBytes());
-	}
+	@Override
+    public String toString() {
+        return this.getClass().getName() + ':' + toStringBlock(getHashAsBytes());
+    }
 
 	/**
 	 * Converts a block to a String representation.
@@ -405,12 +394,14 @@
 	 */
 	private static String toStringBlock(byte[] block, int off, int len) {
 		String hexdigits = "0123456789ABCDEF";
-		StringBuffer buf = new StringBuffer();
+		StringBuilder buf = new StringBuilder();
+        buf.append('[');
 		for (int i = off; i < off + len; ++i) {
 			buf.append(hexdigits.charAt((block[i] >>> 4) & 0xf));
 			buf.append(hexdigits.charAt(block[i] & 0xf));
 		}
-		return "[" + buf + "]";
+        buf.append(']');
+		return buf.toString();
 	}
 
 	/**
@@ -426,7 +417,8 @@
 	 * @param len
 	 *            number of bytes in buffer to write
 	 */
-	public void write(byte[] buffer, int off, int len) {
+	@Override
+    public void write(byte[] buffer, int off, int len) {
 		int spaceLeft;
 		int start;
 		int bytesLeft;
@@ -460,7 +452,8 @@
 	 * @param b
 	 *            the byte to be written
 	 */
-	public void write(int b) {
+	@Override
+    public void write(int b) {
 		// Not thread-safe because we use a shared one-byte buffer
 		oneByte[0] = (byte) b;
 		write(oneByte, 0, 1);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Sorter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Sorter.java?view=diff&rev=440908&r1=440907&r2=440908
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Sorter.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Sorter.java
Wed Sep  6 17:02:12 2006
@@ -21,6 +21,7 @@
  * Helper class with methods for sorting arrays.
  * @deprecated Use Comparator and Arrays.sort().
  */
+@Deprecated
 public final class Sorter {
 	public interface Comparator<T> extends java.util.Comparator<T> {
 	}
@@ -32,6 +33,7 @@
 	 *            array of objects to be sorted
 	 * @param comp
 	 *            A Comparator to be used to sort the elements
+     * 
 	 */
 	public static <T> void sort(T[] objs, Comparator<T> comp) {
 		Arrays.sort(objs, comp);



Mime
View raw message