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 String https = new String("https://");
47 if ((page.indexOf(http) == -1) && (page.indexOf(https) == -1)) {
50 else if (page.indexOf(https) != -1) {
51 beginindex = page.indexOf(https) + https.length();
54 beginindex = page.indexOf(http) + http.length();
56 endindex = page.indexOf('/',beginindex+1);
58 if ((beginindex == -1)) {
59 System.printString("ERROR");
62 endindex = page.length();
64 return page.subString(beginindex, endindex);
67 public String getPathName(String page) {
68 String http = new String("http://");
69 String https = new String("https://");
73 if ((page.indexOf(http) == -1) && (page.indexOf(https) == -1)) {
74 String path = getPath();
75 int lastindex = path.lastindexOf('/');
79 StringBuffer sb = new StringBuffer(path.subString(0,lastindex+1));
83 else if (page.indexOf(https) != -1) {
84 beginindex = page.indexOf(https) + https.length();
87 beginindex = page.indexOf(http) + http.length();
89 nextindex = page.indexOf('/',beginindex+1);
91 if ((beginindex==-1) || (nextindex==-1))
92 return new String("index.html");
93 return page.subString(nextindex+1, page.length());