1 package be
.nikiroo
.gofetch
.support
;
3 import java
.io
.IOException
;
4 import java
.io
.InputStream
;
6 import java
.net
.URLConnection
;
8 import java
.util
.zip
.GZIPInputStream
;
10 import be
.nikiroo
.gofetch
.data
.Comment
;
11 import be
.nikiroo
.gofetch
.data
.Story
;
13 public abstract class BasicSupport
{
15 SLASHDOT
, PIPEDOT
, LWN
,
18 static private String preselector
;
22 abstract public List
<Story
> list() throws IOException
;
24 abstract public List
<Comment
> getComments(Story story
) throws IOException
;
26 abstract public String
getDescription();
28 public String
getSelector() {
29 return getSelector(type
);
32 public Type
getType() {
36 protected void setType(Type type
) {
42 * the preselector to set
44 static public void setPreselector(String preselector
) {
45 BasicSupport
.preselector
= preselector
;
48 static public BasicSupport
getSupport(Type type
) {
49 BasicSupport support
= null;
54 support
= new Slashdot();
57 support
= new Pipedot();
64 if (support
!= null) {
65 support
.setType(type
);
72 static public String
getSelector(Type type
) {
73 return preselector
+ "/" + type
+ "/";
76 // TODO: check Downloader.java?
77 static protected InputStream
open(URL url
) throws IOException
{
78 URLConnection conn
= url
.openConnection();
80 InputStream in
= conn
.getInputStream();
81 if ("gzip".equals(conn
.getContentEncoding())) {
82 in
= new GZIPInputStream(in
);