harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r491834 [7/7] - in /harmony/enhanced/classlib/trunk/modules/luni/src/main/java: java/net/ java/util/ org/apache/harmony/luni/internal/nls/ org/apache/harmony/luni/internal/reflect/ org/apache/harmony/luni/net/
Date Tue, 02 Jan 2007 16:22:07 GMT
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/WeakHashMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/WeakHashMap.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/WeakHashMap.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/WeakHashMap.java
Tue Jan  2 08:22:05 2007
@@ -25,6 +25,7 @@
  * The key/value mapping is removed when the key is no longer referenced. All
  * optional operations are supported, adding and removing. Keys and values can
  * be any objects.
+ * 
  * @since 1.2
  * @see HashMap
  * @see WeakReference
@@ -32,7 +33,7 @@
 public class WeakHashMap<K, V> extends AbstractMap<K, V> implements Map<K,
V> {
 
     private static final int DEFAULT_SIZE = 16;
-    
+
     private final ReferenceQueue<K> referenceQueue;
 
     int elementCount;
@@ -44,8 +45,8 @@
     private int threshold;
 
     volatile int modCount;
-    
-    //Simple utility method to isolate unchecked cast for array creation
+
+    // Simple utility method to isolate unchecked cast for array creation
     @SuppressWarnings("unchecked")
     private static <K, V> Entry<K, V>[] newEntryArray(int size) {
         return new Entry[size];
@@ -106,7 +107,7 @@
 
         @Override
         public String toString() {
-            return super.get() + "=" + value;
+            return super.get() + "=" + value; //$NON-NLS-1$
         }
     }
 
@@ -245,11 +246,11 @@
     }
 
     /**
-	 * Removes all mappings from this WeakHashMap, leaving it empty.
-	 * 
-	 * @see #isEmpty
-	 * @see #size
-	 */
+     * Removes all mappings from this WeakHashMap, leaving it empty.
+     * 
+     * @see #isEmpty
+     * @see #size
+     */
     @Override
     public void clear() {
         if (elementCount > 0) {
@@ -304,7 +305,8 @@
             @Override
             public boolean remove(Object object) {
                 if (contains(object)) {
-                    WeakHashMap.this.remove(((Map.Entry) object).getKey());
+                    WeakHashMap.this
+                            .remove(((Map.Entry<?, ?>) object).getKey());
                     return true;
                 }
                 return false;
@@ -313,7 +315,8 @@
             @Override
             public boolean contains(Object object) {
                 if (object instanceof Map.Entry) {
-                    Entry<?, ?> entry = getEntry(((Map.Entry) object).getKey());
+                    Entry<?, ?> entry = getEntry(((Map.Entry<?, ?>) object)
+                            .getKey());
                     if (entry != null) {
                         Object key = entry.get();
                         if (key != null || entry.isNull) {
@@ -326,11 +329,12 @@
 
             @Override
             public Iterator<Map.Entry<K, V>> iterator() {
-                return new HashIterator<Map.Entry<K, V>>(new Entry.Type<Map.Entry<K,
V>, K, V>() {
-                    public Map.Entry<K, V> get(Map.Entry<K, V> entry) {
-                        return entry;
-                    }
-                });
+                return new HashIterator<Map.Entry<K, V>>(
+                        new Entry.Type<Map.Entry<K, V>, K, V>() {
+                            public Map.Entry<K, V> get(Map.Entry<K, V> entry)
{
+                                return entry;
+                            }
+                        });
             }
         };
     }
@@ -532,8 +536,8 @@
     @SuppressWarnings("unchecked")
     void poll() {
         Entry<K, V> toRemove;
-        while ((toRemove = (Entry<K, V>)referenceQueue.poll()) != null) {
-                removeEntry(toRemove);
+        while ((toRemove = (Entry<K, V>) referenceQueue.poll()) != null) {
+            removeEntry(toRemove);
         }
     }
 
@@ -573,7 +577,7 @@
     public V put(K key, V value) {
         poll();
         int index = 0;
-        Entry<K,V> entry;
+        Entry<K, V> entry;
         if (key != null) {
             index = (key.hashCode() & 0x7FFFFFFF) % elementData.length;
             entry = elementData[index];
@@ -623,7 +627,7 @@
         elementData = newData;
         computeMaxSize();
     }
-    
+
     /**
      * Copies all the mappings in the given map to this map. These mappings will
      * replace all mappings that this map had for any of the keys currently in
@@ -689,7 +693,7 @@
         poll();
         return elementCount;
     }
-    
+
     private void putAllImpl(Map<? extends K, ? extends V> map) {
         if (map.entrySet() != null) {
             super.putAll(map);

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties
Tue Jan  2 08:22:05 2007
@@ -18,3 +18,6 @@
 luni.01=Could not make SSL Tunneling. Got response: {0} ({1})
 luni.02=Hostname <{0}> was not verified
 luni.03=The enum constant {0}.{1} is missing
+luni.04=this Map
+luni.05=Attempt to insert {0} element into collection with element type {1}
+luni.06=The string argument is null

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyCharArrayCache.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyCharArrayCache.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyCharArrayCache.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyCharArrayCache.java
Tue Jan  2 08:22:05 2007
@@ -97,7 +97,8 @@
     }
 
     private void rehash() {
-        ProxyCharArrayCache newHashtable = new ProxyCharArrayCache(keyTable.length * 2);
+        ProxyCharArrayCache newHashtable = new ProxyCharArrayCache(
+                keyTable.length * 2);
         for (int i = keyTable.length; --i >= 0;) {
             if (keyTable[i] != null) {
                 newHashtable.put(keyTable[i], valueTable[i]);
@@ -117,16 +118,16 @@
     public String toString() {
         int max = size();
         StringBuilder buf = new StringBuilder();
-        buf.append("{");
+        buf.append("{"); //$NON-NLS-1$
         for (int i = 0; i < max; ++i) {
             if (keyTable[i] != null) {
-                buf.append(keyTable[i]).append("->").append(valueTable[i]);
+                buf.append(keyTable[i]).append("->").append(valueTable[i]); //$NON-NLS-1$
             }
             if (i < max) {
-                buf.append(", ");
+                buf.append(", "); //$NON-NLS-1$
             }
         }
-        buf.append("}");
+        buf.append("}"); //$NON-NLS-1$
         return buf.toString();
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyObjectCache.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyObjectCache.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyObjectCache.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyObjectCache.java
Tue Jan  2 08:22:05 2007
@@ -70,7 +70,8 @@
     }
 
     private void rehash() {
-        ProxyObjectCache newHashtable = new ProxyObjectCache(keyTable.length * 2);
+        ProxyObjectCache newHashtable = new ProxyObjectCache(
+                keyTable.length * 2);
         for (int i = keyTable.length; --i >= 0;) {
             if (keyTable[i] != null) {
                 newHashtable.put(keyTable[i], valueTable[i]);
@@ -90,16 +91,16 @@
     public String toString() {
         int max = size();
         StringBuilder buf = new StringBuilder();
-        buf.append("{");
+        buf.append("{"); //$NON-NLS-1$
         for (int i = 0; i < max; ++i) {
             if (keyTable[i] != null) {
-                buf.append(keyTable[i]).append("->").append(valueTable[i]);
+                buf.append(keyTable[i]).append("->").append(valueTable[i]); //$NON-NLS-1$
             }
             if (i < max) {
-                buf.append(", ");
+                buf.append(", "); //$NON-NLS-1$
             }
         }
-        buf.append("}");
+        buf.append("}"); //$NON-NLS-1$
         return buf.toString();
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
Tue Jan  2 08:22:05 2007
@@ -114,8 +114,8 @@
 
     @Override
     public void bind(int port, InetAddress addr) throws SocketException {
-        String prop = AccessController.doPrivileged(new PriviAction<String>("bindToDevice"));
-        boolean useBindToDevice = prop != null && prop.toLowerCase().equals("true");
+        String prop = AccessController.doPrivileged(new PriviAction<String>("bindToDevice"));
//$NON-NLS-1$
+        boolean useBindToDevice = prop != null && prop.toLowerCase().equals("true");
//$NON-NLS-1$
         bindToDevice = netImpl.bind2(fd, port, useBindToDevice, addr);
         if (0 != port) {
             localPort = port;

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
Tue Jan  2 08:22:05 2007
@@ -100,20 +100,20 @@
         try {
             if (newImpl instanceof PlainSocketImpl) {
                 PlainSocketImpl newPlainSocketImpl = (PlainSocketImpl) newImpl;
-                netImpl.acceptStreamSocket(fd, newImpl, newPlainSocketImpl.getFileDescriptor(),
-                        receiveTimeout);
+                netImpl.acceptStreamSocket(fd, newImpl, newPlainSocketImpl
+                        .getFileDescriptor(), receiveTimeout);
                 newPlainSocketImpl.setLocalport(getLocalPort());
             } else {
                 // if newImpl is not an instance of PlainSocketImpl, use
                 // reflection to get/set protected fields.
                 if (null == fdField) {
-                    fdField = getSocketImplField("fd"); // $NON-NLS-1$
+                    fdField = getSocketImplField("fd"); //$NON-NLS-1$
                 }
                 FileDescriptor newFd = (FileDescriptor) fdField.get(newImpl);
                 netImpl.acceptStreamSocket(fd, newImpl, newFd, receiveTimeout);
 
                 if (null == localportField) {
-                    localportField = getSocketImplField("localport"); // $NON-NLS-1$
+                    localportField = getSocketImplField("localport"); //$NON-NLS-1$
                 }
                 localportField.setInt(newImpl, getLocalPort());
             }
@@ -164,7 +164,8 @@
         if (0 != aPort) {
             localport = aPort;
         } else {
-            localport = netImpl.getSocketLocalPort(fd, NetUtil.preferIPv6Addresses());
+            localport = netImpl.getSocketLocalPort(fd, NetUtil
+                    .preferIPv6Addresses());
         }
     }
 
@@ -186,7 +187,8 @@
 
     @Override
     protected void connect(String aHost, int aPort) throws IOException {
-        InetAddress anAddr = netImpl.getHostByName(aHost, NetUtil.preferIPv6Addresses());
+        InetAddress anAddr = netImpl.getHostByName(aHost, NetUtil
+                .preferIPv6Addresses());
         connect(anAddr, aPort);
     }
 
@@ -198,13 +200,19 @@
     /**
      * Connects this socket to the specified remote host address/port.
      * 
-     * @param anAddr the remote host address to connect to
-     * @param aPort the remote port to connect to
-     * @param timeout a timeout where supported. 0 means no timeout
-     * @throws IOException if an error occurs while connecting
+     * @param anAddr
+     *            the remote host address to connect to
+     * @param aPort
+     *            the remote port to connect to
+     * @param timeout
+     *            a timeout where supported. 0 means no timeout
+     * @throws IOException
+     *             if an error occurs while connecting
      */
-    private void connect(InetAddress anAddr, int aPort, int timeout) throws IOException {
-        InetAddress address = anAddr.isAnyLocalAddress() ? InetAddress.getByName("localhost")
+    private void connect(InetAddress anAddr, int aPort, int timeout)
+            throws IOException {
+        InetAddress address = anAddr.isAnyLocalAddress() ? InetAddress
+                .getByName("localhost") //$NON-NLS-1$
                 : anAddr;
 
         try {
@@ -215,13 +223,14 @@
                     if (timeout == 0) {
                         netImpl.connect(fd, trafficClass, address, aPort);
                     } else {
-                        netImpl.connectStreamWithTimeoutSocket(fd, aPort, timeout,
-                                trafficClass, address);
+                        netImpl.connectStreamWithTimeoutSocket(fd, aPort,
+                                timeout, trafficClass, address);
                     }
                 }
             }
         } catch (ConnectException e) {
-            throw new ConnectException(anAddr + ":" + aPort + " - " + e.getMessage());
+            throw new ConnectException(anAddr + ":" + aPort + " - "
+                    + e.getMessage());
         }
         super.address = anAddr;
         super.port = aPort;
@@ -272,7 +281,7 @@
     @Override
     protected synchronized OutputStream getOutputStream() throws IOException {
         if (!fd.valid()) {
-            throw new SocketException(Msg.getString("K003d"));
+            throw new SocketException(Msg.getString("K003d")); //$NON-NLS-1$
         }
         return new SocketOutputStream(this);
     }
@@ -347,27 +356,28 @@
             proxyName = addr.getAddress().getHostAddress();
         }
 
-        InetAddress anAddr = netImpl.getHostByName(proxyName, NetUtil.preferIPv6Addresses());
+        InetAddress anAddr = netImpl.getHostByName(proxyName, NetUtil
+                .preferIPv6Addresses());
         return anAddr;
     }
 
     /**
      * Connect using a SOCKS server.
      */
-    private void socksConnect(InetAddress applicationServerAddress, int applicationServerPort,
-            int timeout) throws IOException {
+    private void socksConnect(InetAddress applicationServerAddress,
+            int applicationServerPort, int timeout) throws IOException {
         try {
             if (timeout == 0) {
-                netImpl
-                        .connect(fd, trafficClass, socksGetServerAddress(),
-                                socksGetServerPort());
+                netImpl.connect(fd, trafficClass, socksGetServerAddress(),
+                        socksGetServerPort());
             } else {
-                netImpl.connectStreamWithTimeoutSocket(fd, socksGetServerPort(), timeout,
-                        trafficClass, socksGetServerAddress());
+                netImpl.connectStreamWithTimeoutSocket(fd,
+                        socksGetServerPort(), timeout, trafficClass,
+                        socksGetServerAddress());
             }
 
         } catch (Exception e) {
-            throw new SocketException(Msg.getString("K003e", e));
+            throw new SocketException(Msg.getString("K003e", e)); //$NON-NLS-1$
         }
 
         socksRequestConnection(applicationServerAddress, applicationServerPort);
@@ -382,11 +392,12 @@
      */
     private void socksRequestConnection(InetAddress applicationServerAddress,
             int applicationServerPort) throws IOException {
-        socksSendRequest(Socks4Message.COMMAND_CONNECT, applicationServerAddress,
-                applicationServerPort);
+        socksSendRequest(Socks4Message.COMMAND_CONNECT,
+                applicationServerAddress, applicationServerPort);
         Socks4Message reply = socksReadReply();
         if (reply.getCommandOrResult() != Socks4Message.RETURN_SUCCESS) {
-            throw new IOException(reply.getErrorString(reply.getCommandOrResult()));
+            throw new IOException(reply.getErrorString(reply
+                    .getCommandOrResult()));
         }
     }
 
@@ -396,7 +407,8 @@
     public void socksAccept() throws IOException {
         Socks4Message reply = socksReadReply();
         if (reply.getCommandOrResult() != Socks4Message.RETURN_SUCCESS) {
-            throw new IOException(reply.getErrorString(reply.getCommandOrResult()));
+            throw new IOException(reply.getErrorString(reply
+                    .getCommandOrResult()));
         }
     }
 
@@ -422,23 +434,26 @@
      */
     private void socksBind() throws IOException {
         try {
-            netImpl.connect(fd, trafficClass, socksGetServerAddress(), socksGetServerPort());
+            netImpl.connect(fd, trafficClass, socksGetServerAddress(),
+                    socksGetServerPort());
         } catch (Exception e) {
-            throw new IOException(Msg.getString("K003f", e));
+            throw new IOException(Msg.getString("K003f", e)); //$NON-NLS-1$
         }
 
         // There must be a connection to an application host for the bind to
         // work.
         if (lastConnectedAddress == null) {
-            throw new SocketException(Msg.getString("K0040"));
+            throw new SocketException(Msg.getString("K0040")); //$NON-NLS-1$
         }
 
         // Use the last connected address and port in the bind request.
-        socksSendRequest(Socks4Message.COMMAND_BIND, lastConnectedAddress, lastConnectedPort);
+        socksSendRequest(Socks4Message.COMMAND_BIND, lastConnectedAddress,
+                lastConnectedPort);
         Socks4Message reply = socksReadReply();
 
         if (reply.getCommandOrResult() != Socks4Message.RETURN_SUCCESS) {
-            throw new IOException(reply.getErrorString(reply.getCommandOrResult()));
+            throw new IOException(reply.getErrorString(reply
+                    .getCommandOrResult()));
         }
 
         // A peculiarity of socks 4 - if the address returned is 0, use the
@@ -465,7 +480,7 @@
         request.setCommandOrResult(command);
         request.setPort(port);
         request.setIP(address.getAddress());
-        request.setUserId("default");
+        request.setUserId("default"); //$NON-NLS-1$
 
         getOutputStream().write(request.getBytes(), 0, request.getLength());
     }
@@ -485,13 +500,14 @@
             bytesRead += count;
         }
         if (Socks4Message.REPLY_LENGTH != bytesRead) {
-            throw new SocketException(Msg.getString("KA011"));
+            throw new SocketException(Msg.getString("KA011")); //$NON-NLS-1$
         }
         return reply;
     }
 
     @Override
-    protected void connect(SocketAddress remoteAddr, int timeout) throws IOException {
+    protected void connect(SocketAddress remoteAddr, int timeout)
+            throws IOException {
         InetSocketAddress inetAddr = (InetSocketAddress) remoteAddr;
         connect(inetAddr.getAddress(), inetAddr.getPort(), timeout);
     }
@@ -522,7 +538,8 @@
             return -1;
         }
         try {
-            int read = netImpl.receiveStream(fd, buffer, offset, count, receiveTimeout);
+            int read = netImpl.receiveStream(fd, buffer, offset, count,
+                    receiveTimeout);
             if (read == -1) {
                 shutdownInput = true;
             }
@@ -534,7 +551,8 @@
 
     int write(byte[] buffer, int offset, int count) throws IOException {
         if (!streaming) {
-            return netImpl.sendDatagram2(fd, buffer, offset, count, port, address);
+            return netImpl.sendDatagram2(fd, buffer, offset, count, port,
+                    address);
         }
         return netImpl.sendStream(fd, buffer, offset, count);
     }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/Socks4Message.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/Socks4Message.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/Socks4Message.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/Socks4Message.java
Tue Jan  2 08:22:05 2007
@@ -19,6 +19,8 @@
 
 import java.io.UnsupportedEncodingException;
 
+import org.apache.harmony.luni.util.Msg;
+
 class Socks4Message {
     static final int COMMAND_CONNECT = 1;
 
@@ -160,13 +162,13 @@
     public String getErrorString(int error) {
         switch (error) {
             case RETURN_FAILURE:
-                return org.apache.harmony.luni.util.Msg.getString("K00cd");
+                return Msg.getString("K00cd"); //$NON-NLS-1$
             case RETURN_CANNOT_CONNECT_TO_IDENTD:
-                return org.apache.harmony.luni.util.Msg.getString("K00ce");
+                return Msg.getString("K00ce"); //$NON-NLS-1$
             case RETURN_DIFFERENT_USER_IDS:
-                return org.apache.harmony.luni.util.Msg.getString("K00cf");
+                return Msg.getString("K00cf"); //$NON-NLS-1$
             default:
-                return org.apache.harmony.luni.util.Msg.getString("K00d0");
+                return Msg.getString("K00d0"); //$NON-NLS-1$
         }
     }
 
@@ -188,7 +190,8 @@
      * Get a 32 bit integer from the buffer at the offset given.
      */
     private int getInt32(int offset) {
-        return ((buffer[offset + 3] & 0xFF) + ((buffer[offset + 2] & 0xFF) <<
8)
+        return ((buffer[offset + 3] & 0xFF)
+                + ((buffer[offset + 2] & 0xFF) << 8)
                 + ((buffer[offset + 1] & 0xFF) << 16) + ((buffer[offset + 0] &
0xFF) << 24));
     }
 
@@ -205,7 +208,7 @@
             index++;
         }
         try {
-            result = new String(buffer, offset, index - offset, "ISO8859_1");
+            result = new String(buffer, offset, index - offset, "ISO8859_1"); //$NON-NLS-1$
         } catch (UnsupportedEncodingException e) {
             throw new RuntimeException(e.toString());
         }
@@ -233,7 +236,7 @@
     private void setString(int offset, int maxLength, String theString) {
         byte[] stringBytes;
         try {
-            stringBytes = theString.getBytes("ISO8859_1");
+            stringBytes = theString.getBytes("ISO8859_1"); //$NON-NLS-1$
         } catch (UnsupportedEncodingException e) {
             throw new RuntimeException(e.toString());
         }



Mime
View raw message