1105df54097ced61acdfabf0d3eb2cf5022440c5
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
{
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();
58 if (support
!= null) {
59 support
.setType(type
);
66 static public String
getSelector(Type type
) {
67 return preselector
+ "/" + type
+ "/";
70 // TODO: check Downloader.java?
71 static protected InputStream
open(URL url
) throws IOException
{
72 URLConnection conn
= url
.openConnection();
74 InputStream in
= conn
.getInputStream();
75 if ("gzip".equals(conn
.getContentEncoding())) {
76 in
= new GZIPInputStream(in
);