| 235 | */ |
| 236 | //TO-DO: Add resolve argument to allow resolving variables to their values. |
| 237 | public String generateURL() { |
| 238 | String retVal = ""; |
| 239 | retVal = this.protocol == null ? retVal : retVal + this.protocol + "://"; |
| 240 | |
| 241 | if (this.getHosts() != null) { |
| 242 | for (String curHost : this.getHosts()) { |
| 243 | retVal = retVal + curHost + "."; |
| 244 | } |
| 245 | if (retVal.substring(retVal.length() - 1).equals(".")) { |
| 246 | retVal = retVal.substring(0, retVal.length() - 1); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | |
| 251 | if (this.getPort() != null && this.getPort().length() > 0) { |
| 252 | retVal = retVal + ":" + this.getPort(); |
| 253 | } |
| 254 | |
| 255 | |
| 256 | if (this.getPaths() != null && this.getPaths().size() > 0) { |
| 257 | for (String curPath : this.getPaths()) { |
| 258 | retVal = retVal + "/" + curPath; |
| 259 | } |
| 260 | if (retVal.substring(retVal.length() - 1).equals("/")) { |
| 261 | retVal = retVal.substring(0, retVal.length() - 1); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | if (this.getQueryElements() == null || this.getQueryElements().size() == 0) { |
| 266 | return retVal; |
| 267 | } |
| 268 | |
| 269 | retVal = retVal + "?"; |
| 270 | for (Property curQuery : this.getQueryElements()) { |
| 271 | retVal = retVal + curQuery.getKey() + "=" + curQuery.getValue() + "&"; |
| 272 | } |
| 273 | if (retVal.substring(retVal.length() - 1).equals("&")) { |
| 274 | retVal = retVal.substring(0, retVal.length() - 1); |
| 275 | } |
| 276 | |
| 277 | |
| 278 | return retVal; |
| 279 | } |
| 280 | |
| 281 | |
| 282 | /** |