com.atlassian.jira.util
Class ParameterUtils

java.lang.Object
  extended by com.atlassian.jira.util.ParameterUtils

public class ParameterUtils
extends Object


Nested Class Summary
static class ParameterUtils.DateTooEarlyException
           
 
Constructor Summary
ParameterUtils()
           
 
Method Summary
static Date getDateParam(Map params, String s, Locale locale)
           
static Long getDatePeriodParam(SearchRequest searchRequest, String name)
          Get the period, and then try to work out approximately what they meant (because the period is constantly changing this is not exact but should work most - all? - of the time)
static Double getDoubleParam(Map params, String key)
           
static String getFormattedDateParam(SearchRequest searchRequest, String name, Locale locale)
           
static List getListFromStringArray(String[] ar)
           
static List getListParam(Map params, String key)
          Create a List from the parameter with the specified key.
static List getListParamKeepMinusOnes(Map params, String key)
           
static List getLongListFromStringArray(String[] ar)
          Given an array of Strings, return a list of Longs representing the IDs
static Long getLongParam(Map params, String key)
           
static String getSingleFilterParam(SearchRequest searchRequest, String name)
           
static String[] getStringArrayFromList(Collection entities)
          Given a collection of entities, return an array of Strings representing the IDs
static String getStringParam(Map params, String key)
           
static String getStringParam(Map params, String targetKey, String targetValue, String desiredKey)
          Searches through the Map (params) for the given targetKey and targetValue extracting the index (i) and uses this to extract the corresponding index value with the desiredKey.
static User getUserParam(Map params, String s)
           
static String makeCommaSeparated(Long[] longs)
           
static List makeListLong(List list)
          Make a list of Strings into a list of Longs
static boolean paramContains(Map params, String key, String value)
          Checks if the given key, value pair exists in the given params Map
static Date parseDate(String paramValue, Locale locale)
           
static Collection swapNulls(Collection col)
          Convert all null values in a collection into "-1"s.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterUtils

public ParameterUtils()
Method Detail

getDateParam

public static Date getDateParam(Map params,
                                String s,
                                Locale locale)
                         throws ParameterUtils.DateTooEarlyException
Throws:
ParameterUtils.DateTooEarlyException

parseDate

public static Date parseDate(String paramValue,
                             Locale locale)

getUserParam

public static User getUserParam(Map params,
                                String s)

getListParam

public static List getListParam(Map params,
                                String key)
Create a List from the parameter with the specified key.

Parameters:
params -
key -
Returns:
null if the object is not a String array, or has no elements
otherwise it returns a List containing all elements of the String array, with the Strings over value ("-1") turned into null's. (Strings with value "" are ignored).

getListParamKeepMinusOnes

public static List getListParamKeepMinusOnes(Map params,
                                             String key)

makeListLong

public static List makeListLong(List list)
Make a list of Strings into a list of Longs


getStringParam

public static String getStringParam(Map params,
                                    String key)

getStringParam

public static String getStringParam(Map params,
                                    String targetKey,
                                    String targetValue,
                                    String desiredKey)
Searches through the Map (params) for the given targetKey and targetValue extracting the index (i) and uses this to extract the corresponding index value with the desiredKey. if there is no match, the first value or null is returned

Parameters:
params -
targetKey -
targetValue -
desiredKey -
Returns:
desiredValue - corresponding value to desiredKey with the same index as the targetKey and targetValue, or the first value if there is only one, otherwise null

paramContains

public static boolean paramContains(Map params,
                                    String key,
                                    String value)
Checks if the given key, value pair exists in the given params Map

Parameters:
params -
key -
value -
Returns:
Boolean

getLongParam

public static Long getLongParam(Map params,
                                String key)

getDoubleParam

public static Double getDoubleParam(Map params,
                                    String key)

swapNulls

public static Collection swapNulls(Collection col)
Convert all null values in a collection into "-1"s.


getSingleFilterParam

public static String getSingleFilterParam(SearchRequest searchRequest,
                                          String name)

getFormattedDateParam

public static String getFormattedDateParam(SearchRequest searchRequest,
                                           String name,
                                           Locale locale)

getDatePeriodParam

public static Long getDatePeriodParam(SearchRequest searchRequest,
                                      String name)
Get the period, and then try to work out approximately what they meant (because the period is constantly changing this is not exact but should work most - all? - of the time)


getLongListFromStringArray

public static List getLongListFromStringArray(String[] ar)
Given an array of Strings, return a list of Longs representing the IDs


getListFromStringArray

public static List getListFromStringArray(String[] ar)

getStringArrayFromList

public static String[] getStringArrayFromList(Collection entities)
Given a collection of entities, return an array of Strings representing the IDs


makeCommaSeparated

public static String makeCommaSeparated(Long[] longs)


Copyright © 2002-2007 Atlassian. All Rights Reserved.