jET
1.0alpha5


org.jet
Class Configuration

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--java.util.HashMap
              |
              +--org.jet.Configuration
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class Configuration
extends java.util.HashMap

The configuration of jET.

It has similar features as java.util.Properties class. It can read and write properties to files. The extension is in that it can save values other than strings.

Implementation bases on hashed map.

See Also:
Serialized Form

Field Summary
static java.lang.String FILENAME
          Configuration file name.
 
Constructor Summary
Configuration()
          Constructs configuration object.
 
Method Summary
 boolean getBoolean(java.lang.String str)
          Gets boolean value.
 double getDouble(java.lang.String str)
          Gets double value.
 int getInt(java.lang.String str)
          Gets integer value.
 void load()
          Loads configuration from file.
protected  void loadProperties(java.util.Properties prop)
          Gets key value pairs from properties loaded from file and puts it to configuration map.
 boolean put(java.lang.String str, boolean b)
          Puts a boolean to configuration.
 int put(java.lang.String str, int num)
          Puts a integer to configuration.
 void store()
          Stores current configuration to the file.
protected  java.util.Properties storeProperties()
          Stores key, value pairs from configuration to properties, which are going to be stored in file.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

FILENAME

public static final java.lang.String FILENAME
Configuration file name.

See Also:
Constant Field Values
Constructor Detail

Configuration

public Configuration()
Constructs configuration object.

Method Detail

load

public void load()
Loads configuration from file. If file doesn't exist or there is no key, the configuration get defaults.


store

public void store()
Stores current configuration to the file.


loadProperties

protected void loadProperties(java.util.Properties prop)
Gets key value pairs from properties loaded from file and puts it to configuration map. If some properties were not found in the file, gives them default values.

This method is invoked inside load() method after reading file.

Parameters:
prop - Properties loaded from file.

storeProperties

protected java.util.Properties storeProperties()
Stores key, value pairs from configuration to properties, which are going to be stored in file.

It is invoked inside store() method before writing to configuration file.

Returns:
Properties with copied key value pairs from configuration.

put

public int put(java.lang.String str,
               int num)
Puts a integer to configuration.

Parameters:
str - Option name.
num - Integer number.
Returns:
Previous value of this key.

put

public boolean put(java.lang.String str,
                   boolean b)
Puts a boolean to configuration.

Parameters:
str - Option name.
b - Boolean value.
Returns:
Previous value of this key.

getInt

public int getInt(java.lang.String str)
Gets integer value.

Parameters:
str - Option name.
Returns:
The integer value of this key.
Throws:
java.lang.ClassCastException - Method may throw a class cast exception when the key does not match integer value.

getBoolean

public boolean getBoolean(java.lang.String str)
Gets boolean value.

Parameters:
str - Option name.
Returns:
The boolean value of this key.
Throws:
java.lang.ClassCastException - Method may throw a class cast exception when the key does not match boolean value.

getDouble

public double getDouble(java.lang.String str)
Gets double value.

Parameters:
str - Option name.
Returns:
The double value of given key.
Throws:
java.lang.ClassCastException - Method may throw a class cast exception when the key does not match boolean value.

jET
1.0alpha5