org.aludratest.config.impl
Class AbstractPreferences

java.lang.Object
  extended by org.aludratest.config.impl.AbstractPreferences
All Implemented Interfaces:
Preferences
Direct Known Subclasses:
PropertyPriorityPreferences, SimplePreferences

public abstract class AbstractPreferences
extends Object
implements Preferences

Abstract base implementation of the Preferences interface. All getters are implemented and perform conversions from String to required type. The String getter deals with complex key names (containing slashes for subnode access), with variable references, and eventually redirects to an abstract method internalGetStringValue(String), which only has to deal with a given configuration key simple name.

Author:
falbrech

Constructor Summary
AbstractPreferences()
           
 
Method Summary
 boolean getBooleanValue(String key)
          Returns the boolean representation of the given configuration key's value.
 boolean getBooleanValue(String key, boolean defaultValue)
          Returns the boolean representation of the given configuration key's value, or the given default value when no value is stored for this key, or the stored String form of the value is null.
 char getCharValue(String key)
          Returns the char representation of the given configuration key's value.
 char getCharValue(String key, char defaultValue)
          Returns the char representation of the given configuration key's value, or the given default value when no value is stored for this key, or the stored String form of the value is null.
 double getDoubleValue(String key)
          Returns the double representation of the given configuration key's value.
 double getDoubleValue(String key, double defaultValue)
          Returns the double representation of the given configuration key's value, or the given default value when no value is stored for this key, or the stored String form of the value is null.
 float getFloatValue(String key)
          Returns the float representation of the given configuration key's value.
 float getFloatValue(String key, float defaultValue)
          Returns the float representation of the given configuration key's value, or the given default value when no value is stored for this key, or the stored String form of the value is null.
 int getIntValue(String key)
          Returns the int representation of the given configuration key's value.
 int getIntValue(String key, int defaultValue)
          Returns the int representation of the given configuration key's value, or the given default value when no value is stored for this key, or the stored String form of the value is null.
 String getStringValue(String key)
          Returns the String representation of the given configuration key's value.
 String getStringValue(String key, String defaultValue)
          Returns the String representation of the given configuration key's value, or the given default value when no value is stored for this key, or the stored value is null.
protected abstract  String internalGetStringValue(String key)
          Performs the actual task of retrieving the plain stored value for a given key on this Preferences node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.aludratest.config.Preferences
getChildNode, getChildNodeNames, getKeyNames
 

Constructor Detail

AbstractPreferences

public AbstractPreferences()
Method Detail

internalGetStringValue

protected abstract String internalGetStringValue(String key)
Performs the actual task of retrieving the plain stored value for a given key on this Preferences node.

Parameters:
key - Configuration key to retrieve the value of.
Returns:
The plain stored String for the given configuration key.

getStringValue

public final String getStringValue(String key)
Description copied from interface: Preferences
Returns the String representation of the given configuration key's value.

Specified by:
getStringValue in interface Preferences
Parameters:
key - Configuration key to retrieve the value of.
Returns:
The value of the configuration key, as a String. null is returned if no value is stored.

getIntValue

public final int getIntValue(String key,
                             int defaultValue)
Description copied from interface: Preferences
Returns the int representation of the given configuration key's value, or the given default value when no value is stored for this key, or the stored String form of the value is null.

Specified by:
getIntValue in interface Preferences
Parameters:
key - Configuration key to retrieve the value of.
defaultValue - The default value to return if no value is stored for the given configuration key, or if the stored String form of the value is null.
Returns:
The value of the configuration key, as an int, or the default value.

getBooleanValue

public final boolean getBooleanValue(String key,
                                     boolean defaultValue)
Description copied from interface: Preferences
Returns the boolean representation of the given configuration key's value, or the given default value when no value is stored for this key, or the stored String form of the value is null.

Specified by:
getBooleanValue in interface Preferences
Parameters:
key - Configuration key to retrieve the value of.
defaultValue - The default value to return if no value is stored for the given configuration key, or if the stored String form of the value is null.
Returns:
The value of the configuration key, as a boolean, or the default value.

getFloatValue

public final float getFloatValue(String key,
                                 float defaultValue)
Description copied from interface: Preferences
Returns the float representation of the given configuration key's value, or the given default value when no value is stored for this key, or the stored String form of the value is null.

Specified by:
getFloatValue in interface Preferences
Parameters:
key - Configuration key to retrieve the value of.
defaultValue - The default value to return if no value is stored for the given configuration key, or if the stored String form of the value is null.
Returns:
The value of the configuration key, as a float, or the default value.

getDoubleValue

public final double getDoubleValue(String key,
                                   double defaultValue)
Description copied from interface: Preferences
Returns the double representation of the given configuration key's value, or the given default value when no value is stored for this key, or the stored String form of the value is null.

Specified by:
getDoubleValue in interface Preferences
Parameters:
key - Configuration key to retrieve the value of.
defaultValue - The default value to return if no value is stored for the given configuration key, or if the stored String form of the value is null.
Returns:
The value of the configuration key, as a double, or the default value.

getCharValue

public final char getCharValue(String key,
                               char defaultValue)
Description copied from interface: Preferences
Returns the char representation of the given configuration key's value, or the given default value when no value is stored for this key, or the stored String form of the value is null.

Specified by:
getCharValue in interface Preferences
Parameters:
key - Configuration key to retrieve the value of.
defaultValue - The default value to return if no value is stored for the given configuration key, or if the stored String form of the value is null.
Returns:
The value of the configuration key, as a char, or the default value.

getStringValue

public String getStringValue(String key,
                             String defaultValue)
Description copied from interface: Preferences
Returns the String representation of the given configuration key's value, or the given default value when no value is stored for this key, or the stored value is null.

Specified by:
getStringValue in interface Preferences
Parameters:
key - Configuration key to retrieve the value of.
defaultValue - The default value to return if no value is stored for the given configuration key, or the stored value is null.
Returns:
The value of the configuration key, as a String, or the default value.

getIntValue

public int getIntValue(String key)
Description copied from interface: Preferences
Returns the int representation of the given configuration key's value.

Specified by:
getIntValue in interface Preferences
Parameters:
key - Configuration key to retrieve the value of.
Returns:
The value of the configuration key, as an int. 0 is returned if no value is stored, or the stored String is null.

getFloatValue

public float getFloatValue(String key)
Description copied from interface: Preferences
Returns the float representation of the given configuration key's value.

Specified by:
getFloatValue in interface Preferences
Parameters:
key - Configuration key to retrieve the value of.
Returns:
The value of the configuration key, as a float. 0 is returned if no value is stored, or the stored String is null.

getBooleanValue

public boolean getBooleanValue(String key)
Description copied from interface: Preferences
Returns the boolean representation of the given configuration key's value.

Specified by:
getBooleanValue in interface Preferences
Parameters:
key - Configuration key to retrieve the value of.
Returns:
The value of the configuration key, as a boolean. false is returned if no value is stored, or the stored String is null.

getCharValue

public char getCharValue(String key)
Description copied from interface: Preferences
Returns the char representation of the given configuration key's value.

Specified by:
getCharValue in interface Preferences
Parameters:
key - Configuration key to retrieve the value of.
Returns:
The value of the configuration key, as a char. '\0' is returned if no value is stored, or the stored String is null. If a longer String is stored, only the first character is returned.

getDoubleValue

public double getDoubleValue(String key)
Description copied from interface: Preferences
Returns the double representation of the given configuration key's value.

Specified by:
getDoubleValue in interface Preferences
Parameters:
key - Configuration key to retrieve the value of.
Returns:
The value of the configuration key, as a double. 0 is returned if no value is stored, or the stored String is null.


Copyright © 2015 aludratest.org. All rights reserved.