UrlBuilder's addParameter & addParameters could return this for method chaning
------------------------------------------------------------------------------
Key: STS-457
URL: http://mc4j.org/jira/browse/STS-457
Project: Stripes
Issue Type: Improvement
Affects Versions: Release 1.4.3
Reporter: John Newman
Assigned To: Tim Fennell
Priority: Minor
title says it all, i've attached a simple patch
UrlBuilder urlBuilder = new UrlBuilder(getLocale(), getUrlBinding(), true);
urlBuilder.addParameters(params);
return urlBuilder.toString();
or
return new UrlBuilder(getLocale(), getUrlBinding(),
true).addParameters(params).toString()
any reason this is not a good change?
Index:
C:/projects/stripes/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java
===================================================================
---
C:/projects/stripes/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java
(revision 682)
+++
C:/projects/stripes/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java
(working copy)
@@ -195,7 +195,7 @@
* @param name the name of the request parameter being added
* @param values one or more values for the parameter supplied
*/
- public void addParameter(String name, Object... values) {
+ public UrlBuilder addParameter(String name, Object... values) {
// If values is null or empty, then simply sub in a single empty string
if (values == null || values.length == 0) {
values = Literal.array("");
@@ -214,6 +214,7 @@
url = null;
}
}
+ return this;
}
/**
@@ -225,7 +226,7 @@
*
* @param parameters a non-null Map as described above
*/
- public void addParameters(Map<? extends Object,? extends Object>
parameters) {
+ public UrlBuilder addParameters(Map<? extends Object,? extends Object>
parameters) {
for (Map.Entry<? extends Object,? extends Object> parameter :
parameters.entrySet()) {
String name = parameter.getKey().toString();
Object valueOrValues = parameter.getValue();
@@ -243,6 +244,7 @@
addParameter(name, valueOrValues);
}
}
+ return this;
}
/**
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://mc4j.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development