1 public class LocalQuery {
7 public LocalQuery(String hostname, String path, int depth) {
8 this.hostname = new String(hostname);
9 this.path = new String(path);
10 response = new StringBuffer();
14 public int getDepth() {
18 public String getHostName() {
22 public String getPath() {
26 public void outputFile() {
27 StringBuffer sb = new StringBuffer(hostname);
29 FileOutputStream fos = new FileOutputStream(sb.toString().replace('/','#'));
30 fos.write(response.toString().getBytes());
34 public String makewebcanonical(String page) {
35 StringBuffer b = new StringBuffer(getHostName(page));
37 b.append(getPathName(page));
41 public String getHostName(String page) {
42 String http = new String("http://");
43 if (page.indexOf(http) == -1) {
46 int beginindex = page.indexOf(http) + http.length();
47 int endindex = page.indexOf('/',beginindex+1);
48 if ((beginindex == -1)) {
49 System.printString("ERROR");
52 endindex=page.length();
53 return page.subString(beginindex, endindex);
57 public String getPathName(String page) {
58 String http = new String("http://");
59 if (page.indexOf(http) == -1) {
60 String path = getPath();
61 int lastindex = path.lastindexOf('/');
65 StringBuffer sb = new StringBuffer(path.subString(0,lastindex+1));
69 int beginindex = page.indexOf(http) + http.length();
70 int nextindex = page.indexOf('/',beginindex+1);
71 if ((beginindex==-1) || (nextindex==-1))
72 return new String("index.html");
73 return page.subString(nextindex+1, page.length());