com.threerings.servlet.util
Class QueryBuilder

java.lang.Object
  extended by com.threerings.servlet.util.QueryBuilder

public class QueryBuilder
extends Object


Constructor Summary
QueryBuilder()
           
 
Method Summary
 QueryBuilder add(String key, Object val)
          Adds the given value to the parameter mapping under key adding to any current value.
 QueryBuilder addAll(javax.servlet.http.HttpServletRequest req)
          Adds all the parameters in req to the parameters being constructed.
 Collection<String> get(String key)
          Returns the current values for key or an empty collection if there isn't a value.
 String getFirst(String key)
          Retrieve the first value for the given key, or null if the key is not defined.
 String getOnly(String key)
          Retrieve the only value for the given key, or null if it's not defined.
 String getOnly(String key, String defaultValue)
          Retrieve the only value for the given key, or the default value if it's not defined.
 String toString()
          Returns the query in this builder.
 String toUrl(String base)
          Appends the query in this builder to the given String with a question mark.
 String toUrl(StringBuilder base)
          Appends the query in this builder to the given StringBuilder with a question mark.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryBuilder

public QueryBuilder()
Method Detail

getOnly

public String getOnly(String key)
Retrieve the only value for the given key, or null if it's not defined. If the key has more than one value defined, an IllegalArgumentException will be thrown.


getOnly

public String getOnly(String key,
                      String defaultValue)
Retrieve the only value for the given key, or the default value if it's not defined. If the key has more than one value defined, an IllegalArgumentException will be thrown.


getFirst

public String getFirst(String key)
Retrieve the first value for the given key, or null if the key is not defined.


get

public Collection<String> get(String key)
Returns the current values for key or an empty collection if there isn't a value.


add

public QueryBuilder add(String key,
                        Object val)
Adds the given value to the parameter mapping under key adding to any current value. String.valueOf(java.lang.Object) is called on val to turn it into a string.


addAll

public QueryBuilder addAll(javax.servlet.http.HttpServletRequest req)
Adds all the parameters in req to the parameters being constructed.


toUrl

public String toUrl(StringBuilder base)
Appends the query in this builder to the given StringBuilder with a question mark.


toUrl

public String toUrl(String base)
Appends the query in this builder to the given String with a question mark.


toString

public String toString()
Returns the query in this builder.

Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.