1 public class GlobalQuery {
6 public GlobalQuery(GlobalString hostname) {
7 this.hostname = global new GlobalString(hostname);
8 this.path = global new GlobalString("");
12 public GlobalQuery(GlobalString hostname, GlobalString path, int depth) {
13 this.hostname = global new GlobalString(hostname);
14 this.path = global new GlobalString(path);
18 public int getDepth() {
22 public GlobalString getHostName() {
26 public GlobalString getPath() {
30 public GlobalString makewebcanonical(GlobalString page) {
31 GlobalStringBuffer b = global new GlobalStringBuffer(getHostName(page));
33 b.append(getPathName(page));
34 return b.toGlobalString();
37 public GlobalString getHostName(GlobalString page) {
38 GlobalString http = global new GlobalString("http://");
39 GlobalString https = global new GlobalString("https://");
43 if ((page.indexOf(http) == -1) && (page.indexOf(https) == -1)) {
46 else if (page.indexOf(https) != -1) {
47 beginindex = page.indexOf(https) + https.length();
50 beginindex = page.indexOf(http) + http.length();
52 endindex = page.indexOf('/',beginindex+1);
54 if ((beginindex == -1)) {
55 System.printString("ERROR");
58 endindex = page.length();
60 return page.subString(beginindex, endindex);
64 public GlobalString getPathName(GlobalString page) {
65 GlobalString http = global new GlobalString("http://");
66 GlobalString https = global new GlobalString("https://");
70 if ((page.indexOf(http) == -1) && (page.indexOf(https) == -1)) {
71 GlobalString path = getPath();
72 int lastindex = path.lastindexOf('/');
76 GlobalStringBuffer sb = global new GlobalStringBuffer(path.subString(0,lastindex+1));
78 return sb.toGlobalString();
80 else if (page.indexOf(https) != -1) {
81 beginindex = page.indexOf(https) + https.length();
84 beginindex = page.indexOf(http) + http.length();
86 nextindex = page.indexOf('/',beginindex+1);
88 if ((beginindex == -1) || (nextindex == -1))
89 return global new GlobalString("index.html");
90 return page.subString(nextindex+1, page.length());