Package digilib.util

Class ParameterMap

java.lang.Object
digilib.util.ParameterMap
Direct Known Subclasses:
DigilibConfiguration, DigilibRequest, PDFRequest

public class ParameterMap extends Object
HashMap of digilib.servlet.Parameter's. Keys are Strings. Values are Parameters.
Author:
casties
  • Field Details

  • 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

      public static ParameterMap cloneInstance(ParameterMap pm)
      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

      public static ParameterMap getInstance(ParameterMap pm)
      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

      public Parameter get(String key)
      Get the Parameter with the corresponding key. Returns null if no element is associated with key.
      Parameters:
      key - the key
      Returns:
      the Parameter
    • getValue

      public Object getValue(String key)
      Get the value with the corresponding key. Returns null if no element is associated with key.
      Parameters:
      key - the key
      Returns:
      the value
    • getAsString

      public String getAsString(String key)
      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

      public int getAsInt(String key)
      Get the value with the corresponding key. Returns 0 if no element is associated with key.
      Parameters:
      key - the key
      Returns:
      the value
    • getAsFloat

      public float getAsFloat(String key)
      Get the value with the corresponding key. Returns 0 if no element is associated with key.
      Parameters:
      key - the key
      Returns:
      the value
    • getAsBoolean

      public boolean getAsBoolean(String key)
      Get the value with the corresponding key. Returns false if no element is associated with key.
      Parameters:
      key - the key
      Returns:
      the value
    • getAsFile

      public File getAsFile(String key)
      Get the value with the corresponding key. Returns null if no element is associated with key.
      Parameters:
      key - the key
      Returns:
      the value
    • hasValue

      public boolean hasValue(String key)
      Returns if the Parameter's value has been set.
      Parameters:
      key - the key
      Returns:
      if the value has been set
    • put

      public Parameter put(String key, Parameter val)
      Add the Parameter to the map with a certain key. Returns the value that was previously associated with key.
      Parameters:
      key - the key
      val - the value
      Returns:
      last Parameter
    • put

      public Parameter put(Parameter val)
      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

      public Parameter newParameter(String name, Object def, Object val)
      Add a new Parameter with name, default and value. Returns the key that was previously associated with name.
      Parameters:
      name - the name
      def - the default
      val - the value
      Returns:
      last Parameter
    • newParameter

      public Parameter newParameter(String name, Object def, Object val, int type)
      Add a new Parameter with name, default, value and type. Returns the key that was previously associated with name.
      Parameters:
      name - the name
      def - the default
      val - the value
      type - the type
      Returns:
      last Parameter
    • setValue

      public boolean setValue(String key, Object val)
      Set the value of an existing parameter. Sets the value and returns true if the parameter exists.
      Parameters:
      key - the key
      val - the value
      Returns:
      true if the parameter exists.
    • setValue

      public boolean setValue(String key, int val)
      Set the value of an existing parameter. Sets the value and returns true if the parameter exists.
      Parameters:
      key - the key
      val - the value
      Returns:
      true if the parameter exists.
    • setValue

      public boolean setValue(String key, float val)
      Set the value of an existing parameter. Sets the value and returns true if the parameter exists.
      Parameters:
      key - the key
      val - the value
      Returns:
      true if the parameter exists.
    • setValueFromString

      public boolean setValueFromString(String key, String val)
      Set the value of an existing parameter. Sets the value and returns true if the parameter exists.
      Parameters:
      key - the key
      val - the value
      Returns:
      true if the parameter exists.
    • hasOption

      public boolean hasOption(DigilibOption opt)
      Returns if the option has been set.
      Parameters:
      opt - the option
      Returns:
      true if the option has been set.
    • getParameters

      public HashMap<String,Parameter> getParameters(int type)
      Returns a map with all Parameters of a type.
      Parameters:
      type - the type
      Returns:
      map with all Parameters of a type
    • getParams

      public HashMap<String,Parameter> getParams()
      Returns the parameter Map.
      Returns:
      the parameter Map
    • setParams

      public void setParams(HashMap<String,Parameter> params)
      Sets the parameter Map.
      Parameters:
      params - the parameter Map
    • getOptions

      public OptionsSet getOptions()
      Returns the options Set.
      Returns:
      the options Set
    • setOptions

      public void setOptions(OptionsSet options)
      Sets the options Set.
      Parameters:
      options - the options Set