2 private String hostname;
5 private StringBuffer response;
7 public Query(String hostname, String path) {
8 this.hostname=hostname;
10 response=new StringBuffer();
13 public String getHostName() {
17 public String getPath() {
21 public String makewebcanonical(String page) {
22 StringBuffer b=new StringBuffer(getHostName(page));
24 b.append(getPathName(page));
28 public String getHostName(String page) {
29 String http=new String("http://");
30 if (page.indexOf(http)==-1) {
33 int beginindex=page.indexOf(http)+http.length();
34 int endindex=page.indexOf('/',beginindex+1);
35 if ((beginindex==-1)) {
36 System.printString("ERROR");
39 endindex=page.length();
40 return page.subString(beginindex, endindex);
44 public String getPathName(String page) {
45 String http=new String("http://");
46 if (page.indexOf(http)==-1) {
47 String path=getPath();
48 int lastindex=path.lastindexOf('/');
52 StringBuffer sb=new StringBuffer(path.subString(0,lastindex+1));
56 int beginindex=page.indexOf(http)+http.length();
57 int nextindex=page.indexOf('/',beginindex+1);
58 if ((beginindex==-1)||(nextindex==-1))
59 return new String("index.html");
60 return page.subString(nextindex+1, page.length()-1);