remove some codes for scheduling
[IRC.git] / Robust / src / Benchmarks / Spider / Java / Query.java
1 public class Query {
2     private String hostname;
3     private String path;
4
5     private StringBuffer response;
6
7     public Query(String hostname, String path) {
8         this.hostname=hostname;
9         this.path=path;
10         response=new StringBuffer();
11     }
12
13     public String getHostName() {
14         return hostname;
15     }
16
17     public String getPath() {
18         return path;
19     }
20     
21     public void outputFile() {
22         StringBuffer sb=new StringBuffer(hostname);
23         sb.append(path);
24         FileOutputStream fos=new FileOutputStream(sb.toString().replace('/','#'));
25         fos.write(response.toString().getBytes());
26         fos.close();
27     }
28
29     public String makewebcanonical(String page) {
30         StringBuffer b=new StringBuffer(getHostName(page));
31         b.append("/");
32         b.append(getPathName(page));
33         return b.toString();
34     }
35
36     public String getHostName(String page) {
37         String http=new String("http://");
38         if (page.indexOf(http)==-1) {
39             return getHostName();
40         } else {
41             int beginindex=page.indexOf(http)+http.length();
42             int endindex=page.indexOf('/',beginindex+1);
43             if ((beginindex==-1)) {
44                 System.printString("ERROR");
45             }
46             if (endindex==-1)
47                 endindex=page.length();
48             return page.subString(beginindex, endindex);
49         }
50     }
51
52     public String getPathName(String page) {
53         String http=new String("http://");
54         if (page.indexOf(http)==-1) {
55             String path=getPath();
56             int lastindex=path.lastindexOf('/');
57             if (lastindex==-1)
58                 return page;
59             
60             StringBuffer sb=new StringBuffer(path.subString(0,lastindex+1));
61             sb.append(page);
62             return sb.toString();
63         } else {
64             int beginindex=page.indexOf(http)+http.length();
65             int nextindex=page.indexOf('/',beginindex+1);
66             if ((beginindex==-1)||(nextindex==-1))
67                 return new String("index.html");
68             return page.subString(nextindex+1, page.length());
69         }
70     }
71 }