MCPcopy Create free account
hub / github.com/EsperoTech/yaade / generateURL

Method generateURL

server/src/main/java/com/postman/collection/Url.java:237–279  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 /**

Callers

nothing calls this directly

Calls 8

getHostsMethod · 0.95
getPortMethod · 0.95
getPathsMethod · 0.95
getQueryElementsMethod · 0.95
lengthMethod · 0.80
equalsMethod · 0.45
getKeyMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected