aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/java/net/protocol/jar
diff options
context:
space:
mode:
authorBryce McKinlay <mckinlay@redhat.com>2004-07-23 01:21:40 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2004-07-23 02:21:40 +0100
commitf1f90ae0dee37c133fb46ed973c1eddfcea023fa (patch)
treed02b2df079e500b6c08b6fc1f2a09b28c804beca /libjava/gnu/java/net/protocol/jar
parentef453534c4765aeca6b44c6b496f5a02458ebb1d (diff)
downloadgcc-f1f90ae0dee37c133fb46ed973c1eddfcea023fa.zip
gcc-f1f90ae0dee37c133fb46ed973c1eddfcea023fa.tar.gz
gcc-f1f90ae0dee37c133fb46ed973c1eddfcea023fa.tar.bz2
Makefile.am (ordinary_java_source_files): Add DefaultContentHandlerFactory.java.
2004-07-22 Bryce McKinlay <mckinlay@redhat.com> * Makefile.am (ordinary_java_source_files): Add DefaultContentHandlerFactory.java. * Makefile.in: Rebuilt. * java/net/URLConnection.java (defaultFactory): New field. (getContent): (getContentHandler): Renamed from 'setContentHandler'. Try defaultFactory after user-set factory, if any. Search for content handler implementations in gnu.java.net.content, not gnu.gcj.content. * gnu/java/net/protocol/file/Connection.java (getHeaderField): Implemented. (getLastModified): Implemented. (getPermission): Create file permission here, instead of in constructor. * gnu/java/net/protocol/gcjlib/Connection.java (getHeaderField): Implemented. * gnu/java/net/protocol/jar/Connection.java (getHeaderField): Implemented. (getLastModified): Implemented. * gnu/java/awt/ClasspathToolkit.java (createImageProducer): New. Default implementation. * gnu/java/awt/peer/gtk/GtkToolkit.java (createImageProducer): New. Implement using GdkPixbufDecoder. From-SVN: r85069
Diffstat (limited to 'libjava/gnu/java/net/protocol/jar')
-rw-r--r--libjava/gnu/java/net/protocol/jar/Connection.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/libjava/gnu/java/net/protocol/jar/Connection.java b/libjava/gnu/java/net/protocol/jar/Connection.java
index 04eb3fe3..9ba2e3f 100644
--- a/libjava/gnu/java/net/protocol/jar/Connection.java
+++ b/libjava/gnu/java/net/protocol/jar/Connection.java
@@ -49,8 +49,11 @@ import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.net.URLConnection;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
+import java.util.Locale;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarInputStream;
@@ -66,6 +69,14 @@ import java.util.zip.ZipFile;
public final class Connection extends JarURLConnection
{
private static Hashtable file_cache = new Hashtable();
+
+ /**
+ * HTTP-style DateFormat, used to format the last-modified header.
+ */
+ private static SimpleDateFormat dateFormat
+ = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss 'GMT'",
+ new Locale ("En", "Us", "Unix"));
+
private JarFile jar_file;
/**
@@ -219,6 +230,32 @@ public final class Connection extends JarURLConnection
return jar_file;
}
+ public String getHeaderField(String field)
+ {
+ try
+ {
+ if (!connected)
+ connect();
+
+ if (field.equals("content-type"))
+ return guessContentTypeFromName(getJarEntry().getName());
+ else if (field.equals("content-length"))
+ return Long.toString(getJarEntry().getSize());
+ else if (field.equals("last-modified"))
+ {
+ synchronized (dateFormat)
+ {
+ return dateFormat.format(new Date(getJarEntry().getTime()));
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ // Fall through.
+ }
+ return null;
+ }
+
public int getContentLength()
{
if (!connected)
@@ -233,4 +270,19 @@ public final class Connection extends JarURLConnection
return -1;
}
}
+
+ public long getLastModified()
+ {
+ if (!connected)
+ return -1;
+
+ try
+ {
+ return getJarEntry().getTime();
+ }
+ catch (IOException e)
+ {
+ return -1;
+ }
+ }
}