Package digilib.util
Class ParameterMap
java.lang.Object
digilib.util.ParameterMap
- Direct Known Subclasses:
DigilibConfiguration
,DigilibRequest
,PDFRequest
HashMap of digilib.servlet.Parameter's.
Keys are Strings. Values are Parameters.
- Author:
- casties
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ParameterMap
Shallow copy constructor.Get the Parameter with the corresponding key.boolean
getAsBoolean
(String key) Get the value with the corresponding key.Get the value with the corresponding key.float
getAsFloat
(String key) Get the value with the corresponding key.int
Get the value with the corresponding key.getAsString
(String key) Get the value with the corresponding key.static ParameterMap
Creates new ParameterMap by merging Parameters from another ParameterMap.Returns the options Set.getParameters
(int type) Returns a map with all Parameters of a type.Returns the parameter Map.Get the value with the corresponding key.boolean
hasOption
(DigilibOption opt) Returns if the option has been set.boolean
Returns if the Parameter's value has been set.protected void
set up optionsprotected void
set up parametersnewParameter
(String name, Object def, Object val) Add a new Parameter with name, default and value.newParameter
(String name, Object def, Object val, int type) Add a new Parameter with name, default, value and type.Add the Parameter val to the map, using val's name.Add the Parameter to the map with a certain key.void
setOptions
(OptionsSet options) Sets the options Set.void
Sets the parameter Map.boolean
Set the value of an existing parameter.boolean
Set the value of an existing parameter.boolean
Set the value of an existing parameter.boolean
setValueFromString
(String key, String val) Set the value of an existing parameter.
-
Field Details
-
params
-
options
-
-
Constructor Details
-
ParameterMap
public ParameterMap()Default constructor. Does not call initParams(). -
ParameterMap
public ParameterMap(int size) Constructor with initial size. Does not call initParams().- Parameters:
size
- the size
-
-
Method Details
-
cloneInstance
Shallow copy constructor. Be warned that the maps are only cloned i.e. keys and values are shared!- Parameters:
pm
- other ParameterMap- Returns:
- new ParameterMap
-
getInstance
Creates new ParameterMap by merging Parameters from another ParameterMap.- Parameters:
pm
- other ParameterMap- Returns:
- new ParameterMap
-
initParams
protected void initParams()set up parameters -
initOptions
protected void initOptions()set up options -
get
Get the Parameter with the corresponding key. Returns null if no element is associated with key.- Parameters:
key
- the key- Returns:
- the Parameter
-
getValue
Get the value with the corresponding key. Returns null if no element is associated with key.- Parameters:
key
- the key- Returns:
- the value
-
getAsString
Get the value with the corresponding key. Returns empty string if no element is associated with key.- Parameters:
key
- the key- Returns:
- the value
-
getAsInt
Get the value with the corresponding key. Returns 0 if no element is associated with key.- Parameters:
key
- the key- Returns:
- the value
-
getAsFloat
Get the value with the corresponding key. Returns 0 if no element is associated with key.- Parameters:
key
- the key- Returns:
- the value
-
getAsBoolean
Get the value with the corresponding key. Returns false if no element is associated with key.- Parameters:
key
- the key- Returns:
- the value
-
getAsFile
Get the value with the corresponding key. Returns null if no element is associated with key.- Parameters:
key
- the key- Returns:
- the value
-
hasValue
Returns if the Parameter's value has been set.- Parameters:
key
- the key- Returns:
- if the value has been set
-
put
Add the Parameter to the map with a certain key. Returns the value that was previously associated with key.- Parameters:
key
- the keyval
- the value- Returns:
- last Parameter
-
put
Add the Parameter val to the map, using val's name. Returns the value that was previously associated with val's name.- Parameters:
val
- the value- Returns:
- last Parameter
-
newParameter
Add a new Parameter with name, default and value. Returns the key that was previously associated with name.- Parameters:
name
- the namedef
- the defaultval
- the value- Returns:
- last Parameter
-
newParameter
Add a new Parameter with name, default, value and type. Returns the key that was previously associated with name.- Parameters:
name
- the namedef
- the defaultval
- the valuetype
- the type- Returns:
- last Parameter
-
setValue
Set the value of an existing parameter. Sets the value and returns true if the parameter exists.- Parameters:
key
- the keyval
- the value- Returns:
- true if the parameter exists.
-
setValue
Set the value of an existing parameter. Sets the value and returns true if the parameter exists.- Parameters:
key
- the keyval
- the value- Returns:
- true if the parameter exists.
-
setValue
Set the value of an existing parameter. Sets the value and returns true if the parameter exists.- Parameters:
key
- the keyval
- the value- Returns:
- true if the parameter exists.
-
setValueFromString
Set the value of an existing parameter. Sets the value and returns true if the parameter exists.- Parameters:
key
- the keyval
- the value- Returns:
- true if the parameter exists.
-
hasOption
Returns if the option has been set.- Parameters:
opt
- the option- Returns:
- true if the option has been set.
-
getParameters
Returns a map with all Parameters of a type.- Parameters:
type
- the type- Returns:
- map with all Parameters of a type
-
getParams
Returns the parameter Map.- Returns:
- the parameter Map
-
setParams
Sets the parameter Map.- Parameters:
params
- the parameter Map
-
getOptions
Returns the options Set.- Returns:
- the options Set
-
setOptions
Sets the options Set.- Parameters:
options
- the options Set
-