1 |
/* |
/* |
2 |
* $Id$ |
* GopherContentHandler.java |
3 |
* Copyright (C) 2003 The Free Software Foundation |
* Copyright (C) 2003 The Free Software Foundation |
4 |
* |
* |
5 |
* This file is part of GNU inetlib, a library. |
* This file is part of GNU inetlib, a library. |
49 |
* This will return either directory listings or input streams. |
* This will return either directory listings or input streams. |
50 |
* |
* |
51 |
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> |
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a> |
|
* @version $Revision$ $Date$ |
|
52 |
*/ |
*/ |
53 |
public class GopherContentHandler extends ContentHandler |
public class GopherContentHandler |
54 |
|
extends ContentHandler |
55 |
{ |
{ |
56 |
|
|
57 |
public Object getContent(URLConnection urlc) throws IOException |
public Object getContent(URLConnection urlc) |
58 |
{ |
throws IOException |
59 |
if (urlc instanceof GopherURLConnection) |
{ |
60 |
{ |
if (urlc instanceof GopherURLConnection) |
61 |
GopherURLConnection gurlc = (GopherURLConnection) urlc; |
{ |
62 |
GopherConnection connection = gurlc.connection; |
GopherURLConnection gurlc = (GopherURLConnection) urlc; |
63 |
URL url = gurlc.getURL (); |
GopherConnection connection = gurlc.connection; |
64 |
String dir = url.getPath (); |
URL url = gurlc.getURL(); |
65 |
String filename = url.getPath (); |
String dir = url.getPath(); |
66 |
if (dir == null && filename == null) |
String file = url.getFile(); |
67 |
{ |
if (dir == null && file == null) |
68 |
return connection.list (); |
{ |
69 |
} |
return connection.list(); |
70 |
else |
} |
71 |
{ |
else |
72 |
return gurlc.getInputStream (); |
{ |
73 |
} |
return gurlc.getInputStream(); |
74 |
} |
} |
75 |
else |
} |
76 |
{ |
else |
77 |
throw new UnknownServiceException (); |
{ |
78 |
} |
throw new UnknownServiceException(); |
79 |
} |
} |
80 |
|
} |
81 |
|
|
82 |
} |
} |
83 |
|
|