net.sf.eos.config
Class Configuration

java.lang.Object
  extended by net.sf.eos.config.Configuration
All Implemented Interfaces:
Iterable<Map.Entry<String,String>>
Direct Known Subclasses:
HadoopConfigurationAdapter

public class Configuration
extends Object
implements Iterable<Map.Entry<String,String>>

A simple name value configuration handler.

Author:
Sascha Kohlmann

Constructor Summary
Configuration()
          Creates a new instance.
Configuration(Configuration toCopy)
          Copy constructor.
 
Method Summary
 String get(String name)
          Returns a value for the given name.
 String get(String name, String defaultValue)
          Returns a value for the given name.
 boolean getBoolean(String name, boolean defaultValue)
          Returns a value for the given name as boolean
 float getFloat(String name, float defaultValue)
          Returns a value for the given name as float
 int getInt(String name, int defaultValue)
          Returns a value for the given name as int
 Iterator<Map.Entry<String,String>> iterator()
          Returns an iterator for the configuration entries.
 void set(String name, String value)
          Puts the configuration for the name and the value
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Configuration

public Configuration()
Creates a new instance.


Configuration

public Configuration(Configuration toCopy)
Copy constructor.

Parameters:
toCopy - the Configuration to copy.
Method Detail

set

public void set(String name,
                String value)
Puts the configuration for the name and the value

Parameters:
name - the name of the configuration value
value - the value of the configuration name.

get

public String get(String name)
Returns a value for the given name.

Parameters:
name - the name to look up for a value
Returns:
a value or null

get

public String get(String name,
                  String defaultValue)
Returns a value for the given name.

Parameters:
name - the name to look up for a value
defaultValue - a default value
Returns:
a value or null

iterator

public Iterator<Map.Entry<String,String>> iterator()
Returns an iterator for the configuration entries.

Specified by:
iterator in interface Iterable<Map.Entry<String,String>>
Returns:
an iterator for the configuration entries

toString

public String toString()
Overrides:
toString in class Object

getBoolean

public boolean getBoolean(String name,
                          boolean defaultValue)
Returns a value for the given name as boolean

Parameters:
name - the name to look up for a value
defaultValue - a default value
Returns:
the value
See Also:
ConfigurationKey.Type.BOOLEAN

getInt

public int getInt(String name,
                  int defaultValue)
Returns a value for the given name as int

Parameters:
name - the name to look up for a value
defaultValue - a default value
Returns:
the value
See Also:
ConfigurationKey.Type.INTEGER

getFloat

public float getFloat(String name,
                      float defaultValue)
Returns a value for the given name as float

Parameters:
name - the name to look up for a value
defaultValue - a default value
Returns:
the value
See Also:
ConfigurationKey.Type.FLOAT


Copyright © 2008. All Rights Reserved.