summaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu/java/net
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/gnu/java/net')
-rw-r--r--libjava/classpath/gnu/java/net/BASE64.java190
-rw-r--r--libjava/classpath/gnu/java/net/DefaultContentHandlerFactory.java4
-rw-r--r--libjava/classpath/gnu/java/net/GetLocalHostAction.java4
-rw-r--r--libjava/classpath/gnu/java/net/HeaderFieldHelper.java19
-rw-r--r--libjava/classpath/gnu/java/net/IndexListParser.java8
-rw-r--r--libjava/classpath/gnu/java/net/loader/JarURLLoader.java20
-rw-r--r--libjava/classpath/gnu/java/net/loader/URLLoader.java2
-rw-r--r--libjava/classpath/gnu/java/net/loader/URLStreamHandlerCache.java9
-rw-r--r--libjava/classpath/gnu/java/net/local/LocalServerSocket.java1
-rw-r--r--libjava/classpath/gnu/java/net/local/LocalSocket.java1
-rw-r--r--libjava/classpath/gnu/java/net/protocol/ftp/FTPConnection.java4
-rw-r--r--libjava/classpath/gnu/java/net/protocol/ftp/FTPURLConnection.java15
-rw-r--r--libjava/classpath/gnu/java/net/protocol/http/ChunkedInputStream.java4
-rw-r--r--libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java14
-rw-r--r--libjava/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java13
-rw-r--r--libjava/classpath/gnu/java/net/protocol/http/Headers.java45
-rw-r--r--libjava/classpath/gnu/java/net/protocol/http/Request.java17
-rw-r--r--libjava/classpath/gnu/java/net/protocol/http/SimpleCookieManager.java28
-rw-r--r--libjava/classpath/gnu/java/net/protocol/jar/Connection.java5
-rw-r--r--libjava/classpath/gnu/java/net/protocol/jar/Handler.java4
20 files changed, 109 insertions, 298 deletions
diff --git a/libjava/classpath/gnu/java/net/BASE64.java b/libjava/classpath/gnu/java/net/BASE64.java
deleted file mode 100644
index 901aa0c35fc..00000000000
--- a/libjava/classpath/gnu/java/net/BASE64.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/* BASE.java --
- Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.java.net;
-
-/**
- * Encodes and decodes text according to the BASE64 encoding.
- *
- * @author Chris Burdess (dog@gnu.org)
- */
-public final class BASE64
-{
- private static final byte[] src = {
- 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a,
- 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54,
- 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64,
- 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
- 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
- 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
- 0x38, 0x39, 0x2b, 0x2f
- };
-
- private static final byte[] dst;
- static
- {
- dst = new byte[0x100];
- for (int i = 0x0; i < 0xff; i++)
- {
- dst[i] = -1;
- }
- for (int i = 0; i < src.length; i++)
- {
- dst[src[i]] = (byte) i;
- }
- }
-
- private BASE64()
- {
- }
-
- /**
- * Encode the specified byte array using the BASE64 algorithm.
- *
- * @param bs the source byte array
- */
- public static byte[] encode(byte[] bs)
- {
- int si = 0, ti = 0; // source/target array indices
- byte[] bt = new byte[((bs.length + 2) * 4) / 3]; // target byte array
- for (; si < bs.length; si += 3)
- {
- int buflen = bs.length - si;
- if (buflen == 1)
- {
- byte b = bs[si];
- int i = 0;
- bt[ti++] = src[b >>> 2 & 0x3f];
- bt[ti++] = src[(b << 4 & 0x30) + (i >>> 4 & 0xf)];
- }
- else if (buflen == 2)
- {
- byte b1 = bs[si], b2 = bs[si + 1];
- int i = 0;
- bt[ti++] = src[b1 >>> 2 & 0x3f];
- bt[ti++] = src[(b1 << 4 & 0x30) + (b2 >>> 4 & 0xf)];
- bt[ti++] = src[(b2 << 2 & 0x3c) + (i >>> 6 & 0x3)];
- }
- else
- {
- byte b1 = bs[si], b2 = bs[si + 1], b3 = bs[si + 2];
- bt[ti++] = src[b1 >>> 2 & 0x3f];
- bt[ti++] = src[(b1 << 4 & 0x30) + (b2 >>> 4 & 0xf)];
- bt[ti++] = src[(b2 << 2 & 0x3c) + (b3 >>> 6 & 0x3)];
- bt[ti++] = src[b3 & 0x3f];
- }
- }
- if (ti < bt.length)
- {
- byte[] tmp = new byte[ti];
- System.arraycopy(bt, 0, tmp, 0, ti);
- bt = tmp;
- }
- /*while (ti < bt.length)
- {
- bt[ti++] = 0x3d;
- }*/
- return bt;
- }
-
- /**
- * Decode the specified byte array using the BASE64 algorithm.
- *
- * @param bs the source byte array
- */
- public static byte[] decode(byte[] bs)
- {
- int srclen = bs.length;
- while (srclen > 0 && bs[srclen - 1] == 0x3d)
- {
- srclen--; /* strip padding character */
- }
- byte[] buffer = new byte[srclen];
- int buflen = 0;
- int si = 0;
- int len = srclen - si;
- while (len > 0)
- {
- byte b0 = dst[bs[si++] & 0xff];
- byte b2 = dst[bs[si++] & 0xff];
- buffer[buflen++] = (byte) (b0 << 2 & 0xfc | b2 >>> 4 & 0x3);
- if (len > 2)
- {
- b0 = b2;
- b2 = dst[bs[si++] & 0xff];
- buffer[buflen++] = (byte) (b0 << 4 & 0xf0 | b2 >>> 2 & 0xf);
- if (len > 3)
- {
- b0 = b2;
- b2 = dst[bs[si++] & 0xff];
- buffer[buflen++] = (byte) (b0 << 6 & 0xc0 | b2 & 0x3f);
- }
- }
- len = srclen - si;
- }
- byte[] bt = new byte[buflen];
- System.arraycopy(buffer, 0, bt, 0, buflen);
- return bt;
- }
-
- public static void main(String[] args)
- {
- boolean decode = false;
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].equals("-d"))
- {
- decode = true;
- }
- else
- {
- try
- {
- byte[] in = args[i].getBytes("US-ASCII");
- byte[] out = decode ? decode(in) : encode(in);
- System.out.println(args[i] + " = " +
- new String(out, "US-ASCII"));
- }
- catch (java.io.UnsupportedEncodingException e)
- {
- e.printStackTrace(System.err);
- }
- }
- }
- }
-}
diff --git a/libjava/classpath/gnu/java/net/DefaultContentHandlerFactory.java b/libjava/classpath/gnu/java/net/DefaultContentHandlerFactory.java
index bb0a7ce5d21..e3d1b8e5a96 100644
--- a/libjava/classpath/gnu/java/net/DefaultContentHandlerFactory.java
+++ b/libjava/classpath/gnu/java/net/DefaultContentHandlerFactory.java
@@ -81,8 +81,8 @@ public class DefaultContentHandlerFactory implements ContentHandlerFactory
"image/x-xpixmap"
};
- private static HashSet imageTypes
- = new HashSet(Arrays.asList(known_image_types));
+ private static HashSet<String> imageTypes
+ = new HashSet<String>(Arrays.asList(known_image_types));
public ContentHandler createContentHandler(String mimeType)
{
diff --git a/libjava/classpath/gnu/java/net/GetLocalHostAction.java b/libjava/classpath/gnu/java/net/GetLocalHostAction.java
index 7483b025773..fa76015552b 100644
--- a/libjava/classpath/gnu/java/net/GetLocalHostAction.java
+++ b/libjava/classpath/gnu/java/net/GetLocalHostAction.java
@@ -48,9 +48,9 @@ import java.security.PrivilegedAction;
* @author Chris Burdess (dog@gnu.org)
*/
public class GetLocalHostAction
- implements PrivilegedAction
+ implements PrivilegedAction<InetAddress>
{
- public Object run()
+ public InetAddress run()
{
try
{
diff --git a/libjava/classpath/gnu/java/net/HeaderFieldHelper.java b/libjava/classpath/gnu/java/net/HeaderFieldHelper.java
index 0fb8d953d21..a8d13ce153b 100644
--- a/libjava/classpath/gnu/java/net/HeaderFieldHelper.java
+++ b/libjava/classpath/gnu/java/net/HeaderFieldHelper.java
@@ -49,8 +49,8 @@ import java.util.Vector;
*/
public class HeaderFieldHelper
{
- private Vector headerFieldKeys;
- private Vector headerFieldValues;
+ private Vector<String> headerFieldKeys;
+ private Vector<String> headerFieldValues;
public HeaderFieldHelper()
{
@@ -59,8 +59,8 @@ public class HeaderFieldHelper
public HeaderFieldHelper (int size)
{
- headerFieldKeys = new Vector (size);
- headerFieldValues = new Vector (size);
+ headerFieldKeys = new Vector<String> (size);
+ headerFieldValues = new Vector<String> (size);
}
public void addHeaderField (String key, String value)
@@ -75,7 +75,7 @@ public class HeaderFieldHelper
try
{
- key = (String) headerFieldKeys.elementAt (index);
+ key = headerFieldKeys.elementAt (index);
}
catch (ArrayIndexOutOfBoundsException e)
{
@@ -90,7 +90,7 @@ public class HeaderFieldHelper
try
{
- value = (String) headerFieldValues.elementAt (index);
+ value = headerFieldValues.elementAt (index);
}
catch (ArrayIndexOutOfBoundsException e)
{
@@ -105,8 +105,7 @@ public class HeaderFieldHelper
try
{
- value = (String) headerFieldValues.elementAt
- (headerFieldKeys.indexOf(key));
+ value = headerFieldValues.elementAt(headerFieldKeys.indexOf(key));
}
catch (ArrayIndexOutOfBoundsException e)
{
@@ -115,9 +114,9 @@ public class HeaderFieldHelper
return value;
}
- public Map getHeaderFields()
+ public Map<String, String> getHeaderFields()
{
- HashMap headers = new HashMap();
+ HashMap<String, String> headers = new HashMap<String, String>();
int max = headerFieldKeys.size();
for (int index = 0; index < max; index++)
diff --git a/libjava/classpath/gnu/java/net/IndexListParser.java b/libjava/classpath/gnu/java/net/IndexListParser.java
index 1165929fc35..2d90ceb6433 100644
--- a/libjava/classpath/gnu/java/net/IndexListParser.java
+++ b/libjava/classpath/gnu/java/net/IndexListParser.java
@@ -43,6 +43,7 @@ import java.io.InputStreamReader;
import java.net.URL;
import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.Set;
import java.util.jar.JarFile;
/**
@@ -70,7 +71,8 @@ public class IndexListParser
double versionNumber;
// Map each jar to the prefixes defined for the jar.
// This is intentionally kept in insertion order.
- LinkedHashMap prefixes = new LinkedHashMap();
+ LinkedHashMap<URL, Set<String>> prefixes
+ = new LinkedHashMap<URL, Set<String>>();
/**
* Parses the given jarfile's INDEX.LIST file if it exists.
@@ -107,7 +109,7 @@ public class IndexListParser
while ((line = br.readLine()) != null)
{
URL jarURL = new URL(baseURL, line);
- HashSet values = new HashSet();
+ HashSet<String> values = new HashSet<String>();
// Read the names in the section.
while ((line = br.readLine()) != null)
@@ -174,7 +176,7 @@ public class IndexListParser
*
* @return an map of all the headers, or null if no INDEX.LIST was found
*/
- public LinkedHashMap getHeaders()
+ public LinkedHashMap<URL, Set<String>> getHeaders()
{
return prefixes;
}
diff --git a/libjava/classpath/gnu/java/net/loader/JarURLLoader.java b/libjava/classpath/gnu/java/net/loader/JarURLLoader.java
index 9385760d547..40194be799a 100644
--- a/libjava/classpath/gnu/java/net/loader/JarURLLoader.java
+++ b/libjava/classpath/gnu/java/net/loader/JarURLLoader.java
@@ -32,7 +32,7 @@ public final class JarURLLoader extends URLLoader
// Base jar: url for all resources loaded from jar.
final URL baseJarURL;
// The "Class-Path" attribute of this Jar's manifest.
- ArrayList classPath;
+ ArrayList<URLLoader> classPath;
// If not null, a mapping from INDEX.LIST for this jar only.
// This is a set of all prefixes and top-level files that
// ought to be available in this jar.
@@ -90,20 +90,20 @@ public final class JarURLLoader extends URLLoader
IndexListParser parser = new IndexListParser(jarfile, baseJarURL,
baseURL);
- LinkedHashMap indexMap = parser.getHeaders();
+ LinkedHashMap<URL, Set<String>> indexMap = parser.getHeaders();
if (indexMap != null)
{
// Note that the index also computes
// the resulting Class-Path -- there are jars out there
// where the index lists some required jars which do
// not appear in the Class-Path attribute in the manifest.
- this.classPath = new ArrayList();
- Iterator it = indexMap.entrySet().iterator();
+ this.classPath = new ArrayList<URLLoader>();
+ Iterator<Map.Entry<URL, Set<String>>> it = indexMap.entrySet().iterator();
while (it.hasNext())
{
- Map.Entry entry = (Map.Entry) it.next();
- URL subURL = (URL) entry.getKey();
- Set prefixes = (Set) entry.getValue();
+ Map.Entry<URL, Set<String>> entry = it.next();
+ URL subURL = entry.getKey();
+ Set<String> prefixes = entry.getValue();
if (subURL.equals(baseURL))
this.indexSet = prefixes;
else
@@ -127,7 +127,7 @@ public final class JarURLLoader extends URLLoader
= attributes.getValue(Attributes.Name.CLASS_PATH))
!= null))
{
- this.classPath = new ArrayList();
+ this.classPath = new ArrayList<URLLoader>();
StringTokenizer st = new StringTokenizer(classPathString, " ");
while (st.hasMoreElements ())
{
@@ -144,7 +144,7 @@ public final class JarURLLoader extends URLLoader
cache, factory,
subURL, subURL);
this.classPath.add(subLoader);
- ArrayList extra = subLoader.getClassPath();
+ ArrayList<URLLoader> extra = subLoader.getClassPath();
if (extra != null)
this.classPath.addAll(extra);
}
@@ -208,7 +208,7 @@ public final class JarURLLoader extends URLLoader
}
}
- public ArrayList getClassPath()
+ public ArrayList<URLLoader> getClassPath()
{
return classPath;
}
diff --git a/libjava/classpath/gnu/java/net/loader/URLLoader.java b/libjava/classpath/gnu/java/net/loader/URLLoader.java
index d073c54296a..5228bcac96d 100644
--- a/libjava/classpath/gnu/java/net/loader/URLLoader.java
+++ b/libjava/classpath/gnu/java/net/loader/URLLoader.java
@@ -140,7 +140,7 @@ public abstract class URLLoader
* Return a list of new URLLoader objects representing any
* class path entries added by this container.
*/
- public ArrayList getClassPath()
+ public ArrayList<URLLoader> getClassPath()
{
return null;
}
diff --git a/libjava/classpath/gnu/java/net/loader/URLStreamHandlerCache.java b/libjava/classpath/gnu/java/net/loader/URLStreamHandlerCache.java
index 295a15d2b53..b7b8bf12bf1 100644
--- a/libjava/classpath/gnu/java/net/loader/URLStreamHandlerCache.java
+++ b/libjava/classpath/gnu/java/net/loader/URLStreamHandlerCache.java
@@ -51,7 +51,8 @@ public class URLStreamHandlerCache
* private protocol handler cache (also a HashMap), so we can avoid
* creating handlers each time the same protocol comes.
*/
- private HashMap factoryCache = new HashMap(5);
+ private HashMap<URLStreamHandlerFactory, HashMap<String, URLStreamHandler>> factoryCache
+ = new HashMap<URLStreamHandlerFactory, HashMap<String, URLStreamHandler>>(5);
public URLStreamHandlerCache()
{
@@ -62,7 +63,7 @@ public class URLStreamHandlerCache
// Since we only support three protocols so far, 5 is enough
// for cache initial size.
if (factory != null && factoryCache.get(factory) == null)
- factoryCache.put(factory, new HashMap(5));
+ factoryCache.put(factory, new HashMap<String, URLStreamHandler>(5));
}
public synchronized URLStreamHandler get(URLStreamHandlerFactory factory,
@@ -71,8 +72,8 @@ public class URLStreamHandlerCache
if (factory == null)
return null;
// Check if there're handler for the same protocol in cache.
- HashMap cache = (HashMap) factoryCache.get(factory);
- URLStreamHandler handler = (URLStreamHandler) cache.get(protocol);
+ HashMap<String, URLStreamHandler> cache = factoryCache.get(factory);
+ URLStreamHandler handler = cache.get(protocol);
if (handler == null)
{
// Add it to cache.
diff --git a/libjava/classpath/gnu/java/net/local/LocalServerSocket.java b/libjava/classpath/gnu/java/net/local/LocalServerSocket.java
index 15163f243a8..9d8a6ccdf32 100644
--- a/libjava/classpath/gnu/java/net/local/LocalServerSocket.java
+++ b/libjava/classpath/gnu/java/net/local/LocalServerSocket.java
@@ -44,7 +44,6 @@ import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;
-import java.net.SocketException;
public final class LocalServerSocket extends ServerSocket
{
diff --git a/libjava/classpath/gnu/java/net/local/LocalSocket.java b/libjava/classpath/gnu/java/net/local/LocalSocket.java
index b262c794e3d..92acc65bb62 100644
--- a/libjava/classpath/gnu/java/net/local/LocalSocket.java
+++ b/libjava/classpath/gnu/java/net/local/LocalSocket.java
@@ -46,7 +46,6 @@ import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketException;
-import java.net.SocketImpl;
import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.SocketChannel;
diff --git a/libjava/classpath/gnu/java/net/protocol/ftp/FTPConnection.java b/libjava/classpath/gnu/java/net/protocol/ftp/FTPConnection.java
index f5317d479bc..fd79019183a 100644
--- a/libjava/classpath/gnu/java/net/protocol/ftp/FTPConnection.java
+++ b/libjava/classpath/gnu/java/net/protocol/ftp/FTPConnection.java
@@ -1139,7 +1139,7 @@ public class FTPConnection
* @param pathname the directory pathname, or null
* @return a list of filenames(strings)
*/
- public List nameList(String pathname)
+ public List<String> nameList(String pathname)
throws IOException
{
if (dtp == null || transferMode == MODE_STREAM)
@@ -1164,7 +1164,7 @@ public class FTPConnection
in = new BufferedInputStream(in);
in = new CRLFInputStream(in); // TODO ensure that TYPE is correct
LineInputStream li = new LineInputStream(in);
- List ret = new ArrayList();
+ ArrayList<String> ret = new ArrayList<String>();
for (String line = li.readLine();
line != null;
line = li.readLine())
diff --git a/libjava/classpath/gnu/java/net/protocol/ftp/FTPURLConnection.java b/libjava/classpath/gnu/java/net/protocol/ftp/FTPURLConnection.java
index f937e51f606..cfad5a7c1a6 100644
--- a/libjava/classpath/gnu/java/net/protocol/ftp/FTPURLConnection.java
+++ b/libjava/classpath/gnu/java/net/protocol/ftp/FTPURLConnection.java
@@ -50,7 +50,9 @@ import java.net.InetAddress;
import java.net.URL;
import java.net.URLConnection;
import java.security.AccessController;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -112,7 +114,7 @@ public class FTPURLConnection
{
username = "anonymous";
GetLocalHostAction a = new GetLocalHostAction();
- InetAddress localhost =(InetAddress) AccessController.doPrivileged(a);
+ InetAddress localhost = AccessController.doPrivileged(a);
password = SystemProperties.getProperty("user.name") + "@" +
((localhost == null) ? "localhost" : localhost.getHostName());
}
@@ -232,9 +234,9 @@ public class FTPURLConnection
return null;
}
- public Map getRequestProperties()
+ public Map<String, List<String>> getRequestProperties()
{
- Map map = new HashMap();
+ Map<String, List<String>> map = new HashMap<String, List<String>>();
addRequestPropertyValue(map, "passive");
addRequestPropertyValue(map, "representationType");
addRequestPropertyValue(map, "fileStructure");
@@ -242,10 +244,13 @@ public class FTPURLConnection
return map;
}
- private void addRequestPropertyValue(Map map, String key)
+ private void addRequestPropertyValue(Map<String, List<String>> map,
+ String key)
{
String value = getRequestProperty(key);
- map.put(key, value);
+ ArrayList<String> l = new ArrayList<String>();
+ l.add(value);
+ map.put(key, l);
}
public void setRequestProperty(String key, String value)
diff --git a/libjava/classpath/gnu/java/net/protocol/http/ChunkedInputStream.java b/libjava/classpath/gnu/java/net/protocol/http/ChunkedInputStream.java
index 9870412f2da..8abef71d521 100644
--- a/libjava/classpath/gnu/java/net/protocol/http/ChunkedInputStream.java
+++ b/libjava/classpath/gnu/java/net/protocol/http/ChunkedInputStream.java
@@ -58,10 +58,6 @@ import java.net.ProtocolException;
public class ChunkedInputStream
extends InputStream
{
-
- private static final byte CR = 0x0d;
- private static final byte LF = 0x0a;
-
Headers headers;
/** The underlying stream. */
diff --git a/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java b/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java
index 3956d2aba3a..9d19bfbdba4 100644
--- a/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java
+++ b/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java
@@ -129,7 +129,7 @@ public class HTTPConnection
*/
protected int minorVersion;
- private final List handshakeCompletedListeners;
+ private final List<HandshakeCompletedListener> handshakeCompletedListeners;
/**
* The socket this connection communicates on.
@@ -154,7 +154,7 @@ public class HTTPConnection
/**
* Nonce values seen by this connection.
*/
- private Map nonceCounts;
+ private Map<String, Integer> nonceCounts;
/**
* The cookie manager for this connection.
@@ -244,7 +244,8 @@ public class HTTPConnection
this.connectionTimeout = connectionTimeout;
this.timeout = timeout;
majorVersion = minorVersion = 1;
- handshakeCompletedListeners = new ArrayList(2);
+ handshakeCompletedListeners
+ = new ArrayList<HandshakeCompletedListener>(2);
}
/**
@@ -357,7 +358,8 @@ public class HTTPConnection
/**
* The pool
*/
- final LinkedList connectionPool = new LinkedList();
+ final LinkedList<HTTPConnection> connectionPool
+ = new LinkedList<HTTPConnection>();
/**
* Maximum size of the pool.
@@ -857,7 +859,7 @@ public class HTTPConnection
{
return 0;
}
- return((Integer) nonceCounts.get(nonce)).intValue();
+ return nonceCounts.get(nonce).intValue();
}
/**
@@ -868,7 +870,7 @@ public class HTTPConnection
int current = getNonceCount(nonce);
if (nonceCounts == null)
{
- nonceCounts = new HashMap();
+ nonceCounts = new HashMap<String, Integer>();
}
nonceCounts.put(nonce, new Integer(current + 1));
}
diff --git a/libjava/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java b/libjava/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java
index 6c926b72fb4..b31f426695f 100644
--- a/libjava/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java
+++ b/libjava/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java
@@ -50,11 +50,11 @@ import java.net.URL;
import java.security.cert.Certificate;
import java.util.Collections;
import java.util.Date;
+import java.util.List;
import java.util.Map;
import javax.net.ssl.HandshakeCompletedEvent;
import javax.net.ssl.HandshakeCompletedListener;
-import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSocketFactory;
@@ -170,7 +170,8 @@ public class HTTPURLConnection
if (secure)
{
SSLSocketFactory factory = getSSLSocketFactory();
- HostnameVerifier verifier = getHostnameVerifier();
+ // FIXME: use the verifier
+ // HostnameVerifier verifier = getHostnameVerifier();
if (factory != null)
{
connection.setSSLSocketFactory(factory);
@@ -428,12 +429,12 @@ public class HTTPURLConnection
return requestHeaders.getValue(key);
}
- public Map getRequestProperties()
+ public Map<String, List<String>> getRequestProperties()
{
if (connected)
throw new IllegalStateException("Already connected");
- Map m = requestHeaders.getAsMap();
+ Map<String, List<String>> m = requestHeaders.getAsMap();
return Collections.unmodifiableMap(m);
}
@@ -509,7 +510,7 @@ public class HTTPURLConnection
return errorSink;
}
- public Map getHeaderFields()
+ public Map<String,List<String>> getHeaderFields()
{
if (!connected)
{
@@ -522,7 +523,7 @@ public class HTTPURLConnection
return null;
}
}
- Map m = response.getHeaders().getAsMap();
+ Map<String,List<String>> m = response.getHeaders().getAsMap();
m.put(null, Collections.singletonList(getStatusLine(response)));
return Collections.unmodifiableMap(m);
}
diff --git a/libjava/classpath/gnu/java/net/protocol/http/Headers.java b/libjava/classpath/gnu/java/net/protocol/http/Headers.java
index a793bbd9728..c8736bbac8f 100644
--- a/libjava/classpath/gnu/java/net/protocol/http/Headers.java
+++ b/libjava/classpath/gnu/java/net/protocol/http/Headers.java
@@ -42,6 +42,7 @@ import gnu.java.net.LineInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.Iterable;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.ArrayList;
@@ -49,6 +50,7 @@ import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -60,12 +62,13 @@ import java.util.Map;
* @author Chris Burdess (dog@gnu.org)
* @author David Daney (ddaney@avtrex.com)
*/
-class Headers
+class Headers implements Iterable<Headers.HeaderElement>
{
/**
* A list of HeaderElements
*/
- private final ArrayList headers = new ArrayList();
+ private final ArrayList<HeaderElement> headers
+ = new ArrayList<HeaderElement>();
/**
* The HTTP dateformat used to parse date header fields.
@@ -102,7 +105,7 @@ class Headers
*
* @return the Iterator.
*/
- Iterator iterator()
+ public Iterator<HeaderElement> iterator()
{
return headers.iterator();
}
@@ -118,7 +121,7 @@ class Headers
{
for (int i = headers.size() - 1; i >= 0; i--)
{
- HeaderElement e = (HeaderElement)headers.get(i);
+ HeaderElement e = headers.get(i);
if (e.name.equalsIgnoreCase(header))
{
return e.value;
@@ -219,7 +222,7 @@ class Headers
{
for (int i = headers.size() - 1; i >= 0; i--)
{
- HeaderElement e = (HeaderElement)headers.get(i);
+ HeaderElement e = headers.get(i);
if (e.name.equalsIgnoreCase(name))
{
e.value = value;
@@ -240,9 +243,9 @@ class Headers
*/
public void putAll(Headers o)
{
- for (Iterator it = o.iterator(); it.hasNext(); )
+ for (Iterator<HeaderElement> it = o.iterator(); it.hasNext(); )
{
- HeaderElement e = (HeaderElement)it.next();
+ HeaderElement e = it.next();
remove(e.name);
addValue(e.name, e.value);
}
@@ -256,9 +259,9 @@ class Headers
*/
public void remove(String name)
{
- for (Iterator it = headers.iterator(); it.hasNext(); )
+ for (Iterator<HeaderElement> it = headers.iterator(); it.hasNext(); )
{
- HeaderElement e = (HeaderElement)it.next();
+ HeaderElement e = it.next();
if (e.name.equalsIgnoreCase(name))
it.remove();
}
@@ -358,26 +361,26 @@ class Headers
*
* @return a Map containing all the headers.
*/
- public Map getAsMap()
+ public Map<String,List<String>> getAsMap()
{
- LinkedHashMap m = new LinkedHashMap();
- for (Iterator it = headers.iterator(); it.hasNext(); )
+ LinkedHashMap<String,List<String>> m = new LinkedHashMap<String,List<String>>();
+ for (Iterator<HeaderElement> it = headers.iterator(); it.hasNext(); )
{
- HeaderElement e = (HeaderElement)it.next();
- ArrayList l = (ArrayList)m.get(e.name);
+ HeaderElement e = it.next();
+ ArrayList<String> l = (ArrayList<String>)m.get(e.name);
if (l == null)
{
- l = new ArrayList(1);
+ l = new ArrayList<String>(1);
l.add(e.value);
m.put(e.name, l);
}
else
l.add(0, e.value);
}
- for (Iterator it = m.entrySet().iterator(); it.hasNext(); )
+ for (Iterator<Map.Entry<String,List<String>>> it = m.entrySet().iterator(); it.hasNext(); )
{
- Map.Entry me = (Map.Entry)it.next();
- ArrayList l = (ArrayList)me.getValue();
+ Map.Entry<String,List<String>> me = it.next();
+ List<String> l = me.getValue();
me.setValue(Collections.unmodifiableList(l));
}
return m;
@@ -397,7 +400,7 @@ class Headers
if (i >= headers.size() || i < 0)
return null;
- return ((HeaderElement)headers.get(i)).name;
+ return headers.get(i).name;
}
/**
@@ -414,8 +417,6 @@ class Headers
if (i >= headers.size() || i < 0)
return null;
- return ((HeaderElement)headers.get(i)).value;
+ return headers.get(i).value;
}
-
}
-
diff --git a/libjava/classpath/gnu/java/net/protocol/http/Request.java b/libjava/classpath/gnu/java/net/protocol/http/Request.java
index cd9d7ea4423..06a779f3311 100644
--- a/libjava/classpath/gnu/java/net/protocol/http/Request.java
+++ b/libjava/classpath/gnu/java/net/protocol/http/Request.java
@@ -1,5 +1,5 @@
/* Request.java --
- Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.java.net.protocol.http;
-import gnu.java.net.BASE64;
import gnu.java.net.LineInputStream;
+import gnu.java.util.Base64;
import java.io.IOException;
import java.io.InputStream;
@@ -96,7 +96,7 @@ public class Request
/**
* Map of response header handlers.
*/
- protected Map responseHeaderHandlers;
+ protected Map<String, ResponseHeaderHandler> responseHeaderHandlers;
/**
* The authenticator.
@@ -121,7 +121,7 @@ public class Request
this.method = method;
this.path = path;
requestHeaders = new Headers();
- responseHeaderHandlers = new HashMap();
+ responseHeaderHandlers = new HashMap<String, ResponseHeaderHandler>();
}
/**
@@ -302,9 +302,8 @@ public class Request
String line = method + ' ' + requestUri + ' ' + version + CRLF;
out.write(line.getBytes(US_ASCII));
// Request headers
- for (Iterator i = requestHeaders.iterator(); i.hasNext(); )
+ for (Headers.HeaderElement elt : requestHeaders)
{
- Headers.HeaderElement elt = (Headers.HeaderElement)i.next();
line = elt.name + HEADER_SEP + elt.value + CRLF;
out.write(line.getBytes(US_ASCII));
}
@@ -439,9 +438,8 @@ public class Request
void notifyHeaderHandlers(Headers headers)
{
- for (Iterator i = headers.iterator(); i.hasNext(); )
+ for (Headers.HeaderElement entry : headers)
{
- Headers.HeaderElement entry = (Headers.HeaderElement) i.next();
// Handle Set-Cookie
if ("Set-Cookie".equalsIgnoreCase(entry.name))
handleSetCookie(entry.value);
@@ -461,7 +459,6 @@ public class Request
throws IOException
{
long contentLength = -1;
- Headers trailer = null;
// Persistent connections are the default in HTTP/1.1
boolean doClose = "close".equalsIgnoreCase(getHeader("Connection")) ||
@@ -532,7 +529,7 @@ public class Request
Credentials creds = authenticator.getCredentials(realm, attempts);
String userPass = creds.getUsername() + ':' + creds.getPassword();
byte[] b_userPass = userPass.getBytes("US-ASCII");
- byte[] b_encoded = BASE64.encode(b_userPass);
+ byte[] b_encoded = Base64.encode(b_userPass).getBytes("US-ASCII");
String authorization =
scheme + " " + new String(b_encoded, "US-ASCII");
setHeader("Authorization", authorization);
diff --git a/libjava/classpath/gnu/java/net/protocol/http/SimpleCookieManager.java b/libjava/classpath/gnu/java/net/protocol/http/SimpleCookieManager.java
index 8947471885c..fe05ba09e5e 100644
--- a/libjava/classpath/gnu/java/net/protocol/http/SimpleCookieManager.java
+++ b/libjava/classpath/gnu/java/net/protocol/http/SimpleCookieManager.java
@@ -1,5 +1,5 @@
/* CookieManager.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,7 +42,6 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
/**
@@ -59,23 +58,23 @@ public class SimpleCookieManager
* The cookie cache.
* This is a dictionary mapping domains to maps of cookies by name.
*/
- protected Map cookies;
+ protected Map<String, Map<String, Cookie>> cookies;
/**
* Constructor.
*/
public SimpleCookieManager()
{
- cookies = new HashMap();
+ cookies = new HashMap<String, Map<String, Cookie>>();
}
public void setCookie(Cookie cookie)
{
String domain = cookie.getDomain();
- Map map =(Map) cookies.get(domain);
+ Map<String, Cookie> map = cookies.get(domain);
if (map == null)
{
- map = new HashMap();
+ map = new HashMap<String, Cookie>();
cookies.put(domain, map);
}
String name = cookie.getName();
@@ -84,7 +83,7 @@ public class SimpleCookieManager
public Cookie[] getCookies(String host, boolean secure, String path)
{
- List matches = new ArrayList();
+ ArrayList<Cookie> matches = new ArrayList<Cookie>();
Date now = new Date();
if (Character.isLetter(host.charAt(0)))
{
@@ -102,17 +101,16 @@ public class SimpleCookieManager
return ret;
}
- private void addCookies(List matches, String domain, boolean secure,
- String path, Date now)
+ private void addCookies(ArrayList<Cookie> matches, String domain,
+ boolean secure, String path, Date now)
{
- Map map = (Map) cookies.get(domain);
+ Map<String, Cookie> map = cookies.get(domain);
if (map != null)
{
- List expired = new ArrayList();
- for (Iterator i = map.entrySet().iterator(); i.hasNext(); )
+ ArrayList<String> expired = new ArrayList<String>();
+ for (Map.Entry<String, Cookie> entry : map.entrySet())
{
- Map.Entry entry = (Map.Entry) i.next();
- Cookie cookie = (Cookie) entry.getValue();
+ Cookie cookie = entry.getValue();
Date expires = cookie.getExpiryDate();
if (expires != null && expires.before(now))
{
@@ -129,7 +127,7 @@ public class SimpleCookieManager
}
}
// Good housekeeping
- for (Iterator i = expired.iterator(); i.hasNext(); )
+ for (Iterator<String> i = expired.iterator(); i.hasNext(); )
{
map.remove(i.next());
}
diff --git a/libjava/classpath/gnu/java/net/protocol/jar/Connection.java b/libjava/classpath/gnu/java/net/protocol/jar/Connection.java
index f99806ae42d..386aacef63e 100644
--- a/libjava/classpath/gnu/java/net/protocol/jar/Connection.java
+++ b/libjava/classpath/gnu/java/net/protocol/jar/Connection.java
@@ -76,7 +76,8 @@ public final class Connection extends JarURLConnection
public static class JarFileCache
{
- private static Hashtable cache = new Hashtable();
+ private static Hashtable<URL, JarFile> cache
+ = new Hashtable<URL, JarFile>();
private static final int READBUFSIZE = 4*1024;
public static synchronized JarFile get (URL url, boolean useCaches)
@@ -85,7 +86,7 @@ public final class Connection extends JarURLConnection
JarFile jf;
if (useCaches)
{
- jf = (JarFile) cache.get (url);
+ jf = cache.get (url);
if (jf != null)
return jf;
}
diff --git a/libjava/classpath/gnu/java/net/protocol/jar/Handler.java b/libjava/classpath/gnu/java/net/protocol/jar/Handler.java
index 7c09766a557..c57d0a36016 100644
--- a/libjava/classpath/gnu/java/net/protocol/jar/Handler.java
+++ b/libjava/classpath/gnu/java/net/protocol/jar/Handler.java
@@ -164,7 +164,7 @@ public class Handler extends URLStreamHandler
if (jar_path.indexOf("/.") < 0)
return url_string;
- ArrayList tokens = new ArrayList();
+ ArrayList<String> tokens = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(jar_path, "/");
while (st.hasMoreTokens())
{
@@ -183,7 +183,7 @@ public class Handler extends URLStreamHandler
StringBuffer path = new StringBuffer(url_string.length());
path.append(url_string.substring(0, jar_stop + 1));
- Iterator it = tokens.iterator();
+ Iterator<String> it = tokens.iterator();
while (it.hasNext())
path.append('/').append(it.next());