Sets the raw URL. The host, path, query,protocl, query and port properties are parsed from the raw url. Parsing does not always result in these properties being filled, as collection URLs are not always valid URLs in the java sense. For example, URLs containing variables may not produce discrete va
(String rawUrl)
| 71 | * @param rawUrl The raw URL as a String. The URL is not validated |
| 72 | */ |
| 73 | public void setRaw(String rawUrl) { |
| 74 | |
| 75 | //Is there a query String |
| 76 | |
| 77 | String queryString; |
| 78 | |
| 79 | this.raw = rawUrl; |
| 80 | |
| 81 | |
| 82 | if (rawUrl.split("\\?").length == 2) { |
| 83 | queryString = rawUrl.split("\\?")[1]; |
| 84 | rawUrl = rawUrl.split("\\?")[0]; |
| 85 | this.setQuery(queryString); |
| 86 | } |
| 87 | |
| 88 | String regex = "^(https?)(://)(.*)"; |
| 89 | Pattern pnProtocol = Pattern.compile(regex); |
| 90 | Matcher maProtocol = pnProtocol.matcher(rawUrl); |
| 91 | |
| 92 | if (maProtocol.matches() && maProtocol.groupCount() == 3) { |
| 93 | this.setProtocol(maProtocol.group(1)); |
| 94 | rawUrl = maProtocol.group(3); |
| 95 | |
| 96 | } |
| 97 | |
| 98 | Pattern pnPort = Pattern.compile("(:)([0-9]{2,4})"); |
| 99 | Matcher maPort = pnPort.matcher(rawUrl); |
| 100 | if (maPort.find()) { |
| 101 | this.setPort(maPort.group(2)); |
| 102 | rawUrl = rawUrl.replace(":" + this.getPort(), ""); |
| 103 | } |
| 104 | |
| 105 | if (rawUrl.length() == 0) { |
| 106 | return; |
| 107 | } |
| 108 | |
| 109 | String strHost = rawUrl.split("/")[0]; |
| 110 | this.setHost(strHost); |
| 111 | rawUrl = rawUrl.replace(strHost, ""); |
| 112 | |
| 113 | |
| 114 | if (rawUrl != null && rawUrl.length() > 0) { |
| 115 | this.setPath(rawUrl); |
| 116 | } |
| 117 | |
| 118 | |
| 119 | } |
| 120 | |
| 121 | |
| 122 | /** |