org.qedeq.base.io
Class Parameters

java.lang.Object
  extended by org.qedeq.base.io.Parameters

public class Parameters
extends java.lang.Object

Provides convenience methods for getting parameters out of a Map. The keys and the values are stored as Strings.

Author:
Michael Meyling

Field Summary
static Parameters EMPTY
          Empty parameters.
 
Constructor Summary
Parameters()
          Constructs parameter access object.
Parameters(java.util.Map map)
          Constructs parameter access object.
 
Method Summary
 boolean getBoolean(java.lang.String key)
          Searches for the value with the specified key.
 boolean getBoolean(java.lang.String key, boolean def)
          Searches for the value with the specified key.
 int getInt(java.lang.String key)
          Searches for the value with the specified key.
 int getInt(java.lang.String key, int def)
          Searches for the value with the specified key.
 java.lang.String getParameterString()
          Get all parameters as a long string.
 java.lang.String getString(java.lang.String key)
          Searches for the value with the specified key.
 java.lang.String getString(java.lang.String key, java.lang.String def)
          Searches for the value with the specified key.
 java.util.Set keySet()
          Return key set for internal map.
 void setDefault(java.lang.String key, boolean value)
          Set default configuration parameter if the key has still no value.
 void setDefault(java.lang.String key, int value)
          Set default configuration parameter if the key has still no value.
 void setDefault(java.lang.String key, java.lang.String value)
          Set default configuration parameter if the key has still no value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY

public static final Parameters EMPTY
Empty parameters.

Constructor Detail

Parameters

public Parameters(java.util.Map map)
Constructs parameter access object.

Parameters:
map - Herein are the parameters. Must not be null.

Parameters

public Parameters()
Constructs parameter access object.

Method Detail

getString

public java.lang.String getString(java.lang.String key)
Searches for the value with the specified key. If the key has no String value an empty String is returned.

Parameters:
key - The key we want a value for.
Returns:
The value for the specified key value.

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.String def)
Searches for the value with the specified key. If the key has no String value def is returned.

Parameters:
key - The key we want a value for.
def - The default value we get if we have no String value.
Returns:
The value for the specified key value.

getInt

public int getInt(java.lang.String key)
Searches for the value with the specified key. If the key has no int value 0 is returned.

Parameters:
key - The key we want a value for.
Returns:
The value for the specified key value.

getInt

public int getInt(java.lang.String key,
                  int def)
Searches for the value with the specified key. If the key has no int value def is returned.

Parameters:
key - The key we want a value for.
def - The default value we get if we have no String value.
Returns:
The value for the specified key value.

getBoolean

public boolean getBoolean(java.lang.String key)
Searches for the value with the specified key. If the key has no boolean value false is returned.

Parameters:
key - The key we want a value for.
Returns:
The value for the specified key value.

getBoolean

public boolean getBoolean(java.lang.String key,
                          boolean def)
Searches for the value with the specified key. If the key has no boolean value def is returned.

Parameters:
key - The key we want a value for.
def - The default value we get if we have no String value.
Returns:
The value for the specified key value.

getParameterString

public java.lang.String getParameterString()
Get all parameters as a long string. Strings are not quoted.

Returns:
String in form "a=b, c=d" and so on.

setDefault

public void setDefault(java.lang.String key,
                       int value)
Set default configuration parameter if the key has still no value.

Parameters:
key - Key we want to check.
value - Default value.

setDefault

public void setDefault(java.lang.String key,
                       java.lang.String value)
Set default configuration parameter if the key has still no value.

Parameters:
key - Key we want to check.
value - Default value.

setDefault

public void setDefault(java.lang.String key,
                       boolean value)
Set default configuration parameter if the key has still no value.

Parameters:
key - Key we want to check.
value - Default value.

keySet

public java.util.Set keySet()
Return key set for internal map.

Returns:
Key set.


Copyright © 2014. All Rights Reserved.