Class QueryString

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,​java.lang.String>, java.util.NavigableMap<java.lang.String,​java.lang.String>, java.util.SortedMap<java.lang.String,​java.lang.String>

    public class QueryString
    extends java.util.TreeMap<java.lang.String,​java.lang.String>
    Since:
    0.5.0
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      QueryString()  
      QueryString​(java.util.Map<java.lang.String,​?> source)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String buildHref​(java.lang.String href, QueryString qs)
      Build an href with query string.
      static QueryString create​(java.lang.String query)  
      java.lang.String put​(java.lang.String key, java.lang.Object value)  
      java.lang.String toString()  
      java.lang.String toString​(boolean canonical)
      The canonicalized query string is formed by first sorting all the query string parameters, then URI encoding both the key and value and then joining them, in order, separating key value pairs with an '&'.
      • Methods inherited from class java.util.TreeMap

        ceilingEntry, ceilingKey, clear, clone, comparator, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, forEach, get, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, put, putAll, remove, replace, replace, replaceAll, 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

        compute, computeIfAbsent, computeIfPresent, equals, getOrDefault, hashCode, isEmpty, merge, putIfAbsent, remove
    • Constructor Detail

      • QueryString

        public QueryString()
      • QueryString

        public QueryString​(java.util.Map<java.lang.String,​?> source)
    • Method Detail

      • put

        public java.lang.String put​(java.lang.String key,
                                    java.lang.Object value)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.AbstractMap<java.lang.String,​java.lang.String>
      • toString

        public java.lang.String toString​(boolean canonical)
        The canonicalized query string is formed by first sorting all the query string parameters, then URI encoding both the key and value and then joining them, in order, separating key value pairs with an '&'.
        Parameters:
        canonical - whether or not the string should be canonicalized
        Returns:
        the canonical query string
      • create

        public static QueryString create​(java.lang.String query)
      • buildHref

        public static java.lang.String buildHref​(java.lang.String href,
                                                 QueryString qs)
        Build an href with query string. Only appends it queryArgs is NOT empty.
        Parameters:
        href - URL path
        qs - query string to append to href
        Returns:
        href + query string if query string is NOT empty, otherwise, just returns the href