home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VPage / Java.bin / CLASSES.ZIP / sun / net / www / protocol / systemresource / SystemResourceConnection.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-07-08  |  1.8 KB  |  55 lines

  1. package sun.net.www.protocol.systemresource;
  2.  
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5. import java.net.MalformedURLException;
  6. import java.net.URL;
  7. import sun.net.www.URLConnection;
  8.  
  9. public class SystemResourceConnection extends URLConnection {
  10.    private static boolean debug;
  11.    private Object resource;
  12.    private SystemResourceManager manager;
  13.  
  14.    SystemResourceConnection(URL var1) throws MalformedURLException, IOException {
  15.       super(var1);
  16.       this.debug("SystemResourceConnection(" + var1 + ")");
  17.       this.manager = new SystemResourceManager(var1);
  18.    }
  19.  
  20.    public void connect() throws IOException {
  21.       this.debug("Looking for " + super.url + " in SystemResourceManager");
  22.       Object var1 = this.manager.getLocalResource();
  23.       if (var1 == null) {
  24.          this.debug("Invalid resource name");
  25.          this.resource = null;
  26.       } else {
  27.          this.debug("Found resource");
  28.          this.resource = var1;
  29.       }
  30.    }
  31.  
  32.    public Object getContent() throws IOException {
  33.       if (!super.connected) {
  34.          this.connect();
  35.       }
  36.  
  37.       return this.resource;
  38.    }
  39.  
  40.    public InputStream getInputStream() throws IOException {
  41.       if (!super.connected) {
  42.          this.connect();
  43.       }
  44.  
  45.       return this.resource instanceof InputStream ? (InputStream)this.resource : this.manager.getLocalResourceStream();
  46.    }
  47.  
  48.    private void debug(String var1) {
  49.       if (debug) {
  50.          System.err.println(var1);
  51.       }
  52.  
  53.    }
  54. }
  55.