com.sage.swt.client.util
Class URLParameterCache

java.lang.Object
  extended by com.sage.swt.client.util.URLParameterCache

public final class URLParameterCache
extends java.lang.Object

Global static routines to obtain the parameters from the browser's URL string.

It is important to note the maximum URL string length for the browsers:

  • IE - 2083 (http://support.microsoft.com/kb/208427)
  • Firefox - 80,000+ (http://www.boutell.com/newfaq/misc/urllength.html)
  • Safari - 80,000+ (http://www.boutell.com/newfaq/misc/urllength.html)
  • This class returns fully decoded strings, so that higher level code has no need to perform any further URL-related decoding (such as having to call URL.decodeComponent(java.lang.String)). This assumes that the URL used has been encoded using both URI encoding and URI component encoding. (URI Component encoding includes encoding such characters as the /?#&= that URI encoding does not change.)

    For example if the URL aims to include a query parameter MYPARAM=/!@#$^&*()~` then this will have been encoded to MYPARAM=%2F!%40%23%24%5E%26*()~%60 and this class will return the original /!@#$^&*()~`


    Field Summary
    static java.lang.String SESSION_ID_PARAM
               
     
    Method Summary
    static void disable()
              For use in JUnit testing, disconnect from the GWT
    static java.lang.String get(java.lang.String param)
              Gets the URL's parameter of the specified name.
    static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMap()
              Returns a Map of the URL query parameters for the host page; since changing the map would not change the window's location, the map returned is immutable.
    static java.util.List<java.lang.String> getValues(java.lang.String param)
              Gets a list of values for a specified parameter.
    static boolean isEmpty()
              Indicates whether or not the map of URL Parameters is empty.
    static boolean isEnabled()
              A hack until ApplicationParameters is fixed.
    static int size()
              Gets the number of URL parameters.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    SESSION_ID_PARAM

    public static final java.lang.String SESSION_ID_PARAM
    See Also:
    Constant Field Values
    Method Detail

    disable

    public static void disable()
    For use in JUnit testing, disconnect from the GWT


    isEnabled

    public static boolean isEnabled()
    A hack until ApplicationParameters is fixed.

    Returns:
    enabled

    get

    public static java.lang.String get(java.lang.String param)
    Gets the URL's parameter of the specified name. Note that if multiple parameters have been specified with the same name, the last one will be returned.

    Parameters:
    param - The name of the URL parameter.
    Returns:
    The value of the given URL parameter. Returns null if the parameter was not specified.

    getMap

    public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMap()
    Returns a Map of the URL query parameters for the host page; since changing the map would not change the window's location, the map returned is immutable.

    Returns:
    a map from URL query parameter names to a list of values

    getValues

    public static java.util.List<java.lang.String> getValues(java.lang.String param)
    Gets a list of values for a specified parameter. This method is especially useful when there are multiple parameters with the same name in a request. The list returned is immutable.

    Parameters:
    param - The name of the URL parameter.
    Returns:
    The list of values of the given URL parameter. Returns null if the parameter was not specified.

    size

    public static int size()
    Gets the number of URL parameters.

    Returns:
    the number of URL parameters.

    isEmpty

    public static boolean isEmpty()
    Indicates whether or not the map of URL Parameters is empty.

    Returns:
    true if the map of URL Parameters is empty.


    Copyright © 2011 Sage Software, Inc. All rights reserved.