manager
Class PropertyManager

java.lang.Object
  extended by manager.PropertyManager

public class PropertyManager
extends java.lang.Object

A class to handle properties.

Author:
Peter Hlavac

Field Summary
static java.lang.String LANGUAGE
           
static java.lang.String LOCAL_MP3_DIRECTORY
           
static java.lang.String MAP_IMAGE
           
static java.lang.String MAP_SOURCE
           
static java.lang.String MODE
           
static java.lang.String MP3_SERVER
           
static java.lang.String PLAYLIST_NAME
           
static java.lang.String RANDOMIZE_UNIT_ITEMS
           
static java.lang.String REMOTE_SERVER
           
 
Constructor Summary
PropertyManager()
           
 
Method Summary
 void getPropertiesFromString(java.lang.String str)
          Parses properties from a string and store them in the PropertyManager
 java.lang.String getProperty(java.lang.String key)
          Returns the value of a property
 void initProperties()
          Initializes the PropertyManager.
 Properties loadPropertiesFromResource(java.lang.String resource)
          Loads properties from a given resource within the jar file
 void resetProperties()
          Restores default properties
 void saveProperties()
          Saves properties to RMS
 void saveResourcesToRMS()
          Saves resources (MAP Image and MAP Source) to RMS
 void setProperty(java.lang.String key, java.lang.String value)
          Sets the value of a given property
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAP_SOURCE

public static final java.lang.String MAP_SOURCE
See Also:
Constant Field Values

MAP_IMAGE

public static final java.lang.String MAP_IMAGE
See Also:
Constant Field Values

MP3_SERVER

public static final java.lang.String MP3_SERVER
See Also:
Constant Field Values

REMOTE_SERVER

public static final java.lang.String REMOTE_SERVER
See Also:
Constant Field Values

LOCAL_MP3_DIRECTORY

public static final java.lang.String LOCAL_MP3_DIRECTORY
See Also:
Constant Field Values

PLAYLIST_NAME

public static final java.lang.String PLAYLIST_NAME
See Also:
Constant Field Values

MODE

public static final java.lang.String MODE
See Also:
Constant Field Values

LANGUAGE

public static final java.lang.String LANGUAGE
See Also:
Constant Field Values

RANDOMIZE_UNIT_ITEMS

public static final java.lang.String RANDOMIZE_UNIT_ITEMS
See Also:
Constant Field Values
Constructor Detail

PropertyManager

public PropertyManager()
Method Detail

initProperties

public void initProperties()
                    throws javax.microedition.rms.RecordStoreException
Initializes the PropertyManager. Checks if properties are stored on the device (RMS) and loads them if they are available. If not, the properties declared in the default resource "conf.properties" are loaded. Properties are encoded as key value pairs in the property object. (e.g.: key: "map", value: "gztan.png"). Binary resources like the data mapping-file of items to units (=mapsource) or the graphical representation of the items (=mapimage) are stored in a seperate recordstore. Once the default values have been loaded, they are stored to the RMS.

Throws:
javax.microedition.rms.RecordStoreException - throwed if MIDlet cannot access RMS

resetProperties

public void resetProperties()
                     throws javax.microedition.rms.RecordStoreException
Restores default properties

Throws:
javax.microedition.rms.RecordStoreException - throwed when access to RMS fails

saveProperties

public void saveProperties()
                    throws javax.microedition.rms.RecordStoreException
Saves properties to RMS

Throws:
javax.microedition.rms.RecordStoreException - throwed when access to RMS fails

getProperty

public java.lang.String getProperty(java.lang.String key)
Returns the value of a property

Parameters:
key - the key of the property
Returns:
the value

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
Sets the value of a given property

Parameters:
key - the key of the property
value - the value of the property

loadPropertiesFromResource

public Properties loadPropertiesFromResource(java.lang.String resource)
Loads properties from a given resource within the jar file

Parameters:
resource - the resource where to load the properties from
Returns:
the property object

getPropertiesFromString

public void getPropertiesFromString(java.lang.String str)
Parses properties from a string and store them in the PropertyManager

Parameters:
str - the string where to parse properties from

saveResourcesToRMS

public void saveResourcesToRMS()
                        throws javax.microedition.rms.RecordStoreException
Saves resources (MAP Image and MAP Source) to RMS

Throws:
javax.microedition.rms.RecordStoreException