@Test public void testEmptyBuilder() { final UrlStringBuilder builder = new UrlStringBuilder("UTF-8", null); final String url = builder.toString(); Assert.assertEquals("/", url); }
@Override public String toString() { final StringBuilder url = new StringBuilder(); if (this.host != null) { url.append(this.protocol).append(": if (this.port != null) { url.append(":").append(this.port); } } if (this.context != null) { url.append("/").append(context); } else if (this.path.size() == 0) { url.append("/"); } for (final String element : this.path) { url.append("/").append(this.encode(element)); } if (this.parameters.size() > 0) { url.append("?"); for (final Iterator<Map.Entry<String, List<String>>> paramEntryItr = this.parameters.entrySet().iterator(); paramEntryItr.hasNext(); ) { final Entry<String, List<String>> paramEntry = paramEntryItr.next(); String name = paramEntry.getKey(); final List<String> values = paramEntry.getValue(); name = this.encode(name); if (values == null || values.size() == 0) { url.append(name); } else { for (final Iterator<String> valueItr = values.iterator(); valueItr.hasNext(); ) { String value = valueItr.next(); if (value == null) { value = ""; } value = this.encode(value); url.append(name).append("=").append(value); if (valueItr.hasNext()) { url.append("&"); } } } if (paramEntryItr.hasNext()) { url.append("&"); } } } return url.toString(); }
UrlStringBuilder extends BaseEncodedStringBuilder { @Override public String toString() { final StringBuilder url = new StringBuilder(); if (this.host != null) { url.append(this.protocol).append(": if (this.port != null) { url.append(":").append(this.port); } } if (this.context != null) { url.append("/").append(context); } else if (this.path.size() == 0) { url.append("/"); } for (final String element : this.path) { url.append("/").append(this.encode(element)); } if (this.parameters.size() > 0) { url.append("?"); for (final Iterator<Map.Entry<String, List<String>>> paramEntryItr = this.parameters.entrySet().iterator(); paramEntryItr.hasNext(); ) { final Entry<String, List<String>> paramEntry = paramEntryItr.next(); String name = paramEntry.getKey(); final List<String> values = paramEntry.getValue(); name = this.encode(name); if (values == null || values.size() == 0) { url.append(name); } else { for (final Iterator<String> valueItr = values.iterator(); valueItr.hasNext(); ) { String value = valueItr.next(); if (value == null) { value = ""; } value = this.encode(value); url.append(name).append("=").append(value); if (valueItr.hasNext()) { url.append("&"); } } } if (paramEntryItr.hasNext()) { url.append("&"); } } } return url.toString(); } }
UrlStringBuilder extends BaseEncodedStringBuilder { @Override public String toString() { final StringBuilder url = new StringBuilder(); if (this.host != null) { url.append(this.protocol).append(": if (this.port != null) { url.append(":").append(this.port); } } if (this.context != null) { url.append("/").append(context); } else if (this.path.size() == 0) { url.append("/"); } for (final String element : this.path) { url.append("/").append(this.encode(element)); } if (this.parameters.size() > 0) { url.append("?"); for (final Iterator<Map.Entry<String, List<String>>> paramEntryItr = this.parameters.entrySet().iterator(); paramEntryItr.hasNext(); ) { final Entry<String, List<String>> paramEntry = paramEntryItr.next(); String name = paramEntry.getKey(); final List<String> values = paramEntry.getValue(); name = this.encode(name); if (values == null || values.size() == 0) { url.append(name); } else { for (final Iterator<String> valueItr = values.iterator(); valueItr.hasNext(); ) { String value = valueItr.next(); if (value == null) { value = ""; } value = this.encode(value); url.append(name).append("=").append(value); if (valueItr.hasNext()) { url.append("&"); } } } if (paramEntryItr.hasNext()) { url.append("&"); } } } return url.toString(); } UrlStringBuilder(String encoding, String context);  UrlStringBuilder(String encoding, String protocol, String host);  UrlStringBuilder(String encoding, String protocol, String host, Integer port);  UrlStringBuilder(UrlStringBuilder urlBuilder); }
UrlStringBuilder extends BaseEncodedStringBuilder { @Override public String toString() { final StringBuilder url = new StringBuilder(); if (this.host != null) { url.append(this.protocol).append(": if (this.port != null) { url.append(":").append(this.port); } } if (this.context != null) { url.append("/").append(context); } else if (this.path.size() == 0) { url.append("/"); } for (final String element : this.path) { url.append("/").append(this.encode(element)); } if (this.parameters.size() > 0) { url.append("?"); for (final Iterator<Map.Entry<String, List<String>>> paramEntryItr = this.parameters.entrySet().iterator(); paramEntryItr.hasNext(); ) { final Entry<String, List<String>> paramEntry = paramEntryItr.next(); String name = paramEntry.getKey(); final List<String> values = paramEntry.getValue(); name = this.encode(name); if (values == null || values.size() == 0) { url.append(name); } else { for (final Iterator<String> valueItr = values.iterator(); valueItr.hasNext(); ) { String value = valueItr.next(); if (value == null) { value = ""; } value = this.encode(value); url.append(name).append("=").append(value); if (valueItr.hasNext()) { url.append("&"); } } } if (paramEntryItr.hasNext()) { url.append("&"); } } } return url.toString(); } UrlStringBuilder(String encoding, String context);  UrlStringBuilder(String encoding, String protocol, String host);  UrlStringBuilder(String encoding, String protocol, String host, Integer port);  UrlStringBuilder(UrlStringBuilder urlBuilder); UrlStringBuilder setParameter(String name, String... values); UrlStringBuilder setParameter(String name, List<String> values); UrlStringBuilder addParameter(String name, String... values); UrlStringBuilder addParameter(String name, List<String> values); UrlStringBuilder setParameters(Map<String, List<String>> parameters); UrlStringBuilder setParameters(String namespace, Map<String, List<String>> parameters); UrlStringBuilder addParameters(Map<String, List<String>> parameters); UrlStringBuilder addParameters(String namespace, Map<String, List<String>> parameters); UrlStringBuilder addParametersArray(String namespace, Map<String, String[]> parameters); UrlStringBuilder setPath(String... elements); UrlStringBuilder addPath(String element); UrlStringBuilder addPath(String... elements); @Override Object clone(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
UrlStringBuilder extends BaseEncodedStringBuilder { @Override public String toString() { final StringBuilder url = new StringBuilder(); if (this.host != null) { url.append(this.protocol).append(": if (this.port != null) { url.append(":").append(this.port); } } if (this.context != null) { url.append("/").append(context); } else if (this.path.size() == 0) { url.append("/"); } for (final String element : this.path) { url.append("/").append(this.encode(element)); } if (this.parameters.size() > 0) { url.append("?"); for (final Iterator<Map.Entry<String, List<String>>> paramEntryItr = this.parameters.entrySet().iterator(); paramEntryItr.hasNext(); ) { final Entry<String, List<String>> paramEntry = paramEntryItr.next(); String name = paramEntry.getKey(); final List<String> values = paramEntry.getValue(); name = this.encode(name); if (values == null || values.size() == 0) { url.append(name); } else { for (final Iterator<String> valueItr = values.iterator(); valueItr.hasNext(); ) { String value = valueItr.next(); if (value == null) { value = ""; } value = this.encode(value); url.append(name).append("=").append(value); if (valueItr.hasNext()) { url.append("&"); } } } if (paramEntryItr.hasNext()) { url.append("&"); } } } return url.toString(); } UrlStringBuilder(String encoding, String context);  UrlStringBuilder(String encoding, String protocol, String host);  UrlStringBuilder(String encoding, String protocol, String host, Integer port);  UrlStringBuilder(UrlStringBuilder urlBuilder); UrlStringBuilder setParameter(String name, String... values); UrlStringBuilder setParameter(String name, List<String> values); UrlStringBuilder addParameter(String name, String... values); UrlStringBuilder addParameter(String name, List<String> values); UrlStringBuilder setParameters(Map<String, List<String>> parameters); UrlStringBuilder setParameters(String namespace, Map<String, List<String>> parameters); UrlStringBuilder addParameters(Map<String, List<String>> parameters); UrlStringBuilder addParameters(String namespace, Map<String, List<String>> parameters); UrlStringBuilder addParametersArray(String namespace, Map<String, String[]> parameters); UrlStringBuilder setPath(String... elements); UrlStringBuilder addPath(String element); UrlStringBuilder addPath(String... elements); @Override Object clone(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }