diff options
Diffstat (limited to 'libjava/gnu/java/net/protocol/gcjlib')
-rw-r--r-- | libjava/gnu/java/net/protocol/gcjlib/Connection.h | 57 | ||||
-rw-r--r-- | libjava/gnu/java/net/protocol/gcjlib/Connection.java | 83 | ||||
-rw-r--r-- | libjava/gnu/java/net/protocol/gcjlib/Handler.h | 49 | ||||
-rw-r--r-- | libjava/gnu/java/net/protocol/gcjlib/Handler.java | 24 |
4 files changed, 213 insertions, 0 deletions
diff --git a/libjava/gnu/java/net/protocol/gcjlib/Connection.h b/libjava/gnu/java/net/protocol/gcjlib/Connection.h new file mode 100644 index 000000000..9ecf032ef --- /dev/null +++ b/libjava/gnu/java/net/protocol/gcjlib/Connection.h @@ -0,0 +1,57 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_java_net_protocol_gcjlib_Connection__ +#define __gnu_java_net_protocol_gcjlib_Connection__ + +#pragma interface + +#include <java/net/URLConnection.h> +extern "Java" +{ + namespace gnu + { + namespace gcj + { + class Core; + } + namespace java + { + namespace net + { + namespace protocol + { + namespace gcjlib + { + class Connection; + } + } + } + } + } + namespace java + { + namespace net + { + class URL; + } + } +} + +class gnu::java::net::protocol::gcjlib::Connection : public ::java::net::URLConnection +{ + +public: + Connection(::java::net::URL *); + virtual void connect(); + virtual ::java::io::InputStream * getInputStream(); + virtual ::java::lang::String * getHeaderField(::java::lang::String *); +public: // actually package-private + ::java::lang::String * __attribute__((aligned(__alignof__( ::java::net::URLConnection)))) solib; + ::java::lang::String * name; + ::gnu::gcj::Core * core; +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_java_net_protocol_gcjlib_Connection__ diff --git a/libjava/gnu/java/net/protocol/gcjlib/Connection.java b/libjava/gnu/java/net/protocol/gcjlib/Connection.java new file mode 100644 index 000000000..4e6e462f2 --- /dev/null +++ b/libjava/gnu/java/net/protocol/gcjlib/Connection.java @@ -0,0 +1,83 @@ +// Connection.java - Implementation of URLConnection for gcjlib +// protocol. + +/* Copyright (C) 2003 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.java.net.protocol.gcjlib; + +import java.io.InputStream; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import gnu.gcj.Core; +import gnu.gcj.runtime.SharedLibHelper; +import gnu.java.net.protocol.core.CoreInputStream; + +/** + * @author Tom Tromey <tromey@redhat.com> + * @date January 10, 2003 + */ +class Connection extends URLConnection +{ + String solib; + String name; + Core core; + + public Connection (URL url) throws MalformedURLException + { + super (url); + int index = url.getFile().indexOf ("!/"); + + if (index == -1) + throw new MalformedURLException ("couldn't find !/ in gcjlib URL"); + + name = url.getFile().substring (index + 2); + solib = url.getFile().substring (0, index); + } + + public void connect() throws IOException + { + if (core != null) + return; + // We can't create a new SharedLibHelper here, since we don't know + // what parent class loader to use. + SharedLibHelper helper = SharedLibHelper.findHelper(solib); + if (helper == null) + throw new IOException("library not loaded: " + solib); + core = helper.findCore(name); + if (core == null) + throw new IOException("couldn't find core object: " + name); + } + + public InputStream getInputStream() throws IOException + { + connect(); + return new CoreInputStream(core); + } + + public String getHeaderField(String field) + { + try + { + if (!connected) + connect(); + + if (field.equals("content-type")) + return guessContentTypeFromName(name); + else if (field.equals("content-length")) + return Long.toString(core.length); + } + catch (IOException e) + { + // Fall through. + } + return null; + } +} diff --git a/libjava/gnu/java/net/protocol/gcjlib/Handler.h b/libjava/gnu/java/net/protocol/gcjlib/Handler.h new file mode 100644 index 000000000..40813aeb5 --- /dev/null +++ b/libjava/gnu/java/net/protocol/gcjlib/Handler.h @@ -0,0 +1,49 @@ + +// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- + +#ifndef __gnu_java_net_protocol_gcjlib_Handler__ +#define __gnu_java_net_protocol_gcjlib_Handler__ + +#pragma interface + +#include <java/net/URLStreamHandler.h> +extern "Java" +{ + namespace gnu + { + namespace java + { + namespace net + { + namespace protocol + { + namespace gcjlib + { + class Handler; + } + } + } + } + } + namespace java + { + namespace net + { + class URL; + class URLConnection; + } + } +} + +class gnu::java::net::protocol::gcjlib::Handler : public ::java::net::URLStreamHandler +{ + +public: + Handler(); +public: // actually protected + virtual ::java::net::URLConnection * openConnection(::java::net::URL *); +public: + static ::java::lang::Class class$; +}; + +#endif // __gnu_java_net_protocol_gcjlib_Handler__ diff --git a/libjava/gnu/java/net/protocol/gcjlib/Handler.java b/libjava/gnu/java/net/protocol/gcjlib/Handler.java new file mode 100644 index 000000000..60f5bcc25 --- /dev/null +++ b/libjava/gnu/java/net/protocol/gcjlib/Handler.java @@ -0,0 +1,24 @@ +// Handler.java - URLStreamHandler for gcjlib protocol. + +/* Copyright (C) 2003 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.java.net.protocol.gcjlib; + +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLStreamHandler; + +public class Handler extends URLStreamHandler +{ + protected URLConnection openConnection (URL url) throws IOException + { + return new Connection (url); + } +} |