home *** CD-ROM | disk | FTP | other *** search
- package sun.net.www.protocol.systemresource;
-
- import java.io.IOException;
- import java.io.InputStream;
- import java.net.MalformedURLException;
- import java.net.URL;
- import sun.net.www.URLConnection;
-
- public class SystemResourceConnection extends URLConnection {
- private static boolean debug;
- private Object resource;
- private SystemResourceManager manager;
-
- SystemResourceConnection(URL var1) throws MalformedURLException, IOException {
- super(var1);
- this.debug("SystemResourceConnection(" + var1 + ")");
- this.manager = new SystemResourceManager(var1);
- }
-
- public void connect() throws IOException {
- this.debug("Looking for " + super.url + " in SystemResourceManager");
- Object var1 = this.manager.getLocalResource();
- if (var1 == null) {
- this.debug("Invalid resource name");
- this.resource = null;
- } else {
- this.debug("Found resource");
- this.resource = var1;
- }
- }
-
- public Object getContent() throws IOException {
- if (!super.connected) {
- this.connect();
- }
-
- return this.resource;
- }
-
- public InputStream getInputStream() throws IOException {
- if (!super.connected) {
- this.connect();
- }
-
- return this.resource instanceof InputStream ? (InputStream)this.resource : this.manager.getLocalResourceStream();
- }
-
- private void debug(String var1) {
- if (debug) {
- System.err.println(var1);
- }
-
- }
- }
-