public class

ParameterUtils

extends Object
java.lang.Object
   ↳ com.atlassian.jira.util.ParameterUtils

Class Overview

This class can be used to "parse" values from a map of parameters. This is really intended to be used in webwork.action.Action code that needs to read input parameters from getParameters()

Summary

Nested Classes
class ParameterUtils.DateTooEarlyException This class is deprecated. Only used in deprecated method. Since v5.2.  
Public Constructors
ParameterUtils()
Public Methods
static boolean getBooleanParam(Map mapOfParameters, String paramName)
Returns a boolean value from the map of parameters.
static Date getDateParam(Map params, String s, Locale locale)
This method is deprecated. Use DateTimeFormatterFactory instead. Since v5.2.
static Double getDoubleParam(Map params, String key)
static int getIntParam(Map mapOfParameters, String paramName, int defaultValue)
Gets a int value from the map and uses the defaultValue if the value can be converted.
static List<String> 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<Long> 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[] getStringArrayFromList(Collection entities)
Given a collection of entities, return an array of Strings representing the IDs
static String[] getStringArrayParam(Map params, String paramName)
Returns the value of the specified parameter name as a String[]
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)
This method is deprecated. Use DateTimeFormatterFactory instead. Since v5.2.
static Collection swapNulls(Collection col)
Convert all null values in a collection into "-1"s.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ParameterUtils ()

Public Methods

public static boolean getBooleanParam (Map mapOfParameters, String paramName)

Returns a boolean value from the map of parameters. if it does no exist in the map, then false is returned

Parameters
mapOfParameters the map of parameters
paramName the parameter name to use
Returns
  • true if the value converted to true or false otherwise

public static Date getDateParam (Map params, String s, Locale locale)

This method is deprecated.
Use DateTimeFormatterFactory instead. Since v5.2.

public static Double getDoubleParam (Map params, String key)

public static int getIntParam (Map mapOfParameters, String paramName, int defaultValue)

Gets a int value from the map and uses the defaultValue if the value can be converted.

Parameters
mapOfParameters the map of parameters
paramName the parameter name to use
defaultValue the default value in case things cant be converted
Returns
  • the converted value or the defaultValue if it cant be converted

public static List<String> getListFromStringArray (String[] ar)

public static List getListParam (Map params, String key)

Create a List from the parameter with the specified 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).

public static List getListParamKeepMinusOnes (Map params, String key)

public static List<Long> getLongListFromStringArray (String[] ar)

Given an array of Strings, return a list of Longs representing the IDs

public static Long getLongParam (Map params, String key)

public static String[] getStringArrayFromList (Collection entities)

Given a collection of entities, return an array of Strings representing the IDs

public static String[] getStringArrayParam (Map params, String paramName)

Returns the value of the specified parameter name as a String[]

Parameters
params the map of parameters
paramName the name of the parameter
Returns
  • a String[] of values or null if there are no parameters

public static String getStringParam (Map params, String key)

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

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

public static User getUserParam (Map params, String s)

public static String makeCommaSeparated (Long[] longs)

public static List makeListLong (List list)

Make a list of Strings into a list of Longs

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 the map of web parameters
key the name of the parameter to check
value the value to check for
Returns
  • true of this key/value pair exists

public static Date parseDate (String paramValue, Locale locale)

This method is deprecated.
Use DateTimeFormatterFactory instead. Since v5.2.

public static Collection swapNulls (Collection col)

Convert all null values in a collection into "-1"s.