Package edu.indiana.lib.twinpeaks.util
Class ParameterMap
- java.lang.Object
-
- edu.indiana.lib.twinpeaks.util.ParameterMap
-
public class ParameterMap extends Object
Parameter (name=value pair) manipulation. In particular, this utility supports multiple parameters with the same name:xxx=value1&xxx=value2
-
-
Constructor Summary
Constructors Constructor Description ParameterMap()Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Empty the parameter mapIteratorgetParameterMapIterator()Get an Iterator to the parameter mapStringgetParameterMapName(String value)Get the parameter name associated with the 1st occurance of this valueStringgetParameterMapValue(String name)Get a named value from the parameter mapStringgetParameterNameFromIterator()Get the parameter name from the current iteratorStringgetParameterValueFromIterator()Get the parameter value from the current iteratorbooleannextParameterMapEntry(Iterator iterator)Save the next Entry Set for this IteratorintpopulateMapFromUrlArguments(String url, String delimiter)Populate a parameter map from an URL argument list.voidsetParameterMapValue(String name, String value)Set a name/value pair
-
-
-
Method Detail
-
clear
public void clear()
Empty the parameter map
-
getParameterMapIterator
public Iterator getParameterMapIterator()
Get an Iterator to the parameter map- Returns:
- Map iterator
-
nextParameterMapEntry
public boolean nextParameterMapEntry(Iterator iterator)
Save the next Entry Set for this Iterator- Parameters:
iterator- Parameter map iterator- Returns:
- false If no more entries exist
-
getParameterNameFromIterator
public String getParameterNameFromIterator()
Get the parameter name from the current iterator- Returns:
- Item name
-
getParameterValueFromIterator
public String getParameterValueFromIterator()
Get the parameter value from the current iterator- Returns:
- Item value
-
setParameterMapValue
public void setParameterMapValue(String name, String value)
Set a name/value pair- Parameters:
name- Item namevalue- Item value
-
getParameterMapValue
public String getParameterMapValue(String name)
Get a named value from the parameter map- Parameters:
name- Item name- Returns:
- Item value (a String, null if none)
-
getParameterMapName
public String getParameterMapName(String value)
Get the parameter name associated with the 1st occurance of this value- Parameters:
value- Item value- Returns:
- Item name (a String, null if none)
-
populateMapFromUrlArguments
public int populateMapFromUrlArguments(String url, String delimiter)
Populate a parameter map from an URL argument list. Any of:http://x.y.com?xxx=yyy&aaa=bbb
?xxx=yyy&aaa=bbb
xxx=yyy&aaa=bbbWill populated the map as:
xxx=yyy aaa=bbb- Parameters:
url- Original URL [with optional parameter list] or only the parameter list [with an optional ? prefix]delimiter- Argument separator text (regular expression)- Returns:
- Number of parameters saved
-
-