/[classpath]/inetlib/source/gnu/inet/gopher/GopherURLConnection.java
ViewVC logotype

Diff of /inetlib/source/gnu/inet/gopher/GopherURLConnection.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dog, Sun Oct 19 15:40:03 2003 UTC revision 1.2 by dog, Sun Oct 19 16:16:50 2003 UTC
# Line 30  package gnu.inet.gopher; Line 30  package gnu.inet.gopher;
30  import java.io.InputStream;  import java.io.InputStream;
31  import java.io.IOException;  import java.io.IOException;
32  import java.io.OutputStream;  import java.io.OutputStream;
33  import java.net.UnknownServiceConnection;  import java.net.UnknownServiceException;
34  import java.net.URL;  import java.net.URL;
35  import java.net.URLConnection;  import java.net.URLConnection;
36    
# Line 43  import java.net.URLConnection; Line 43  import java.net.URLConnection;
43  public class GopherURLConnection extends URLConnection  public class GopherURLConnection extends URLConnection
44  {  {
45    
46          /**          /**
47           * The connection managing the protocol exchange.           * The connection managing the protocol exchange.
48           */           */
49          protected GopherConnection connection;    protected GopherConnection connection;
50    
51          /**          /**
52           * Constructs a Gopher connection to the specified URL.           * Constructs a Gopher connection to the specified URL.
53           * @param url the URL           * @param url the URL
54           */           */
55          public GopherURLConnection(URL url)    public GopherURLConnection(URL url)
56          {    {
57                  super(url);      super(url);
58          }    }
59    
60          /**          /**
61           * Establishes the connection.           * Establishes the connection.
62           */           */
63          public void connect()    public void connect() throws IOException
64                  throws IOException    {
65          {      if (connected)
66                  if (connected)        return;
67                          return;      String host = url.getHost();
68                  String host = url.getHost();      int port = url.getPort();
69                  int port = url.getPort();        connection = new GopherConnection(host, port);
70                  connection = new GopherConnection(host, port);    }
         }  
71    
72          /**          /**
73           * Returns an input stream that reads from this open connection.           * Returns an input stream that reads from this open connection.
74           */           */
75          public InputStream getInputStream()    public InputStream getInputStream() throws IOException
76                  throws IOException    {
77          {      String dir = url.getPath();
78                  String dir = url.getPath();      String filename = url.getFile();
79                  String filename = url.getFile();      if (dir == null && filename == null)
80                  if (dir==null && filename==null)      {
81                  {        throw new UnsupportedOperationException("not implemented");
82                          throw new UnsupportedOperationException("not implemented");      }
83                  }      else
84                  else      {
85                  {        String selector = (dir == null) ? filename :
86                          String selector = (dir==null) ? filename :          new StringBuffer(dir).append('/').append(filename).toString();
87                                  new StringBuffer(dir)        return connection.get(selector);
88                                  .append('/')      }
89                                  .append(filename)    }
                                 .toString();  
                         return connection.retrieve(selector);  
                 }  
         }  
90    
91          /**          /**
92           * Returns an output stream that writes to this connection.           * Returns an output stream that writes to this connection.
93           */           */
94          public OutputStream getOutputStream()    public OutputStream getOutputStream() throws IOException
95                  throws IOException    {
96          {      throw new UnknownServiceException();
97                  throw new UnknownServiceException();    }
98          }  
99      public Object getContent() throws IOException
100          public Object getContent()    {
101                  throws IOException      return new GopherContentHandler().getContent(this);
102          {    }
103                  return new GopherContentHandler().getContent(this);  
104          }    public Object getContent(Class[]classes) throws IOException
105      {
106          public Object getContent(Class[] classes)      return new GopherContentHandler().getContent(this, classes);
107                  throws IOException    }
         {  
                 return new GopherContentHandler().getContent(this, classes);  
         }  
108    
109  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26