com.norconex.commons.lang.url
Class QueryString

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.TreeMap<String,List<String>>
          extended by com.norconex.commons.lang.map.Properties
              extended by com.norconex.commons.lang.url.QueryString
All Implemented Interfaces:
Serializable, Cloneable, Map<String,List<String>>, NavigableMap<String,List<String>>, SortedMap<String,List<String>>

public class QueryString
extends Properties

Provides utility methods for getting and setting attributes on a URL query string.

Author:
Pascal Essiembre
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
 
Fields inherited from class com.norconex.commons.lang.map.Properties
DEFAULT_PROPERTIES_MULTIVALUE_DELIMITER
 
Constructor Summary
QueryString()
           
QueryString(String urlWithQueryString)
          Constructor.
QueryString(String urlWithQueryString, String encoding)
          Constructor.
QueryString(URL urlWithQueryString)
          Default URL character encoding is UTF-8.
QueryString(URL urlWithQueryString, String encoding)
           
 
Method Summary
 String applyOnURL(String url)
          Apply this url QueryString on the given URL.
 URL applyOnURL(URL url)
           
 String toString()
          Convert this QueryString to a URL-encoded string representation that can be appended as is to a URL with no query string.
 
Methods inherited from class com.norconex.commons.lang.map.Properties
addBigDecimal, addBoolean, addClass, addDate, addDouble, addFile, addFloat, addInt, addLocale, addLong, addString, get, getBigDecimal, getBigDecimal, getBigDecimals, getBoolean, getBoolean, getBooleans, getClass, getClass, getClasses, getDate, getDate, getDates, getDouble, getDouble, getDoubles, getFile, getFile, getFiles, getFloat, getFloat, getFloats, getInt, getInt, getInts, getLocale, getLocale, getLocales, getLong, getLong, getLongs, getString, getString, getStrings, load, load, load, load, loadFromString, loadFromXML, loadFromXML, remove, setBigDecimal, setBigDecimal, setBoolean, setBoolean, setClass, setDate, setDouble, setFile, setFloat, setInt, setLocale, setLong, setString, store, store, store, store, storeToString, storeToXML, storeToXML, storeToXML
 
Methods inherited from class java.util.TreeMap
ceilingEntry, ceilingKey, clear, clone, comparator, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, put, putAll, size, subMap, subMap, tailMap, tailMap, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, isEmpty
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode, isEmpty
 

Constructor Detail

QueryString

public QueryString()

QueryString

public QueryString(URL urlWithQueryString)
Default URL character encoding is UTF-8.

Parameters:
urlWithQueryString -

QueryString

public QueryString(URL urlWithQueryString,
                   String encoding)

QueryString

public QueryString(String urlWithQueryString)
Constructor. Default URL character encoding is UTF-8. It is possible to only supply a query string as opposed to an entire URL. Key and values making up a query string are assumed to be URL-encoded. Will throw a URLException if UTF-8 encoding is not supported.

Parameters:
urlWithQueryString - a URL from which to extract a query string.

QueryString

public QueryString(String urlWithQueryString,
                   String encoding)
Constructor. It is possible to only supply a query string as opposed to an entire URL. Key and values making up a query string are assumed to be URL-encoded. Will throw a URLException if the supplied encoding is unsupported or invalid.

Parameters:
urlWithQueryString - a URL from which to extract a query string.
encoding - character encoding
Method Detail

toString

public String toString()
Convert this QueryString to a URL-encoded string representation that can be appended as is to a URL with no query string.

Overrides:
toString in class AbstractMap<String,List<String>>

applyOnURL

public String applyOnURL(String url)
Apply this url QueryString on the given URL. If a query string already exists, it is replaced by this one.

Parameters:
url - the URL to apply this query string.
Returns:
url with query string added

applyOnURL

public URL applyOnURL(URL url)


Copyright © 2008-2013 Norconex Inc.. All Rights Reserved.