com.monica.javacom.util
Class MJCInputStreamConfiguration

java.lang.Object
  |
  +--com.monica.javacom.util.MJCInputStreamConfiguration
All Implemented Interfaces:
MJCConfiguration
Direct Known Subclasses:
MJCFileConfiguration, MJCStringConfiguration

public abstract class MJCInputStreamConfiguration
extends java.lang.Object
implements MJCConfiguration

This class implements the MJConfiguration interface to provide customization possibility for MJC classes. This class reads customization information from a file called MJC.conf, which has to be located in the current directory.

The configuration file can have the following stucure:


Field Summary
protected  java.io.InputStream iS
           
 
Constructor Summary
MJCInputStreamConfiguration()
           
 
Method Summary
 boolean getBoolean(java.lang.String id)
          Returns a boolean configuraton value for the specified configuration id.
 boolean getBoolean(java.lang.String id, boolean def)
          Returns a boolean configuraton value for the specified configuration id.
 java.lang.String getConfigurationName()
          Sets the MJCConfiguration for this object.
 java.lang.String getConfigurationVersion()
          Returns the MJCConfiguration with which this object is customized.
 int getInt(java.lang.String id)
          Retuns an int configuration value for the specified configuration id.
 int getInt(java.lang.String id, int def)
          Returns an int configuraton value for the specified configuration id.
 int getIntFromStrings(java.lang.String id, java.lang.String[] possibilities, int[] values, int def)
          Useable if String possible values in the configuration source should be mapped into ints as configuration values.
 java.lang.String getString(java.lang.String id)
          Returns a String configuraton value for the specified configuration id.
 java.lang.String getString(java.lang.String id, java.lang.String def)
          Returns a String configuraton value for the specified configuration id.
protected  void post_init()
           
protected  void pre_init()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iS

protected java.io.InputStream iS
Constructor Detail

MJCInputStreamConfiguration

public MJCInputStreamConfiguration()
Method Detail

pre_init

protected void pre_init()

post_init

protected void post_init()

getConfigurationName

public java.lang.String getConfigurationName()
Sets the MJCConfiguration for this object.
Specified by:
getConfigurationName in interface MJCConfiguration
Parameters:
MJCConfiguration - configuration: the MJCConfiguration object for the customization

getConfigurationVersion

public java.lang.String getConfigurationVersion()
Returns the MJCConfiguration with which this object is customized.
Specified by:
getConfigurationVersion in interface MJCConfiguration
Returns:
MJCConfiguration: the MJCConfiguration with which this object is customized

getInt

public int getInt(java.lang.String id)
           throws java.lang.Exception
Retuns an int configuration value for the specified configuration id.
Specified by:
getInt in interface MJCConfiguration
Parameters:
String - id: the required configuration id
Returns:
int: the configuration int matching the configuration id
Throws:
Exception: - if the id is invalid or the id doesn't represent an int value

getBoolean

public boolean getBoolean(java.lang.String id)
                   throws java.lang.Exception
Returns a boolean configuraton value for the specified configuration id.
Specified by:
getBoolean in interface MJCConfiguration
Parameters:
String - id: the required configuration id ` @return boolean: the configuration boolean matching the configuration id
Throws:
Exception: - if the id is invalid or the id doesn't represent a boolean value

getString

public java.lang.String getString(java.lang.String id)
                           throws java.lang.Exception
Returns a String configuraton value for the specified configuration id.
Specified by:
getString in interface MJCConfiguration
Parameters:
String - id: the required configuration id
Returns:
String: the configuration String matching the configuration id
Throws:
Exception: - if the id is invalid or the id doesn't represent a String value

getInt

public int getInt(java.lang.String id,
                  int def)
Returns an int configuraton value for the specified configuration id. Should call the getInt(String) method of this interface and if there was an exception, returns the specified default value.
Specified by:
getInt in interface MJCConfiguration
Parameters:
String - id: the required configuration id
int - def: the specified default value
Returns:
int: the configuration int matching the configuration id or if there was an exception then the default int

getBoolean

public boolean getBoolean(java.lang.String id,
                          boolean def)
Returns a boolean configuraton value for the specified configuration id. Should call the getBoolean(String) method of this interface and if there was an exception, returns the specified default value.
Specified by:
getBoolean in interface MJCConfiguration
Parameters:
String - id: the required configuration id
boolean - def: the specified default value
Returns:
boolean: the configuration boolean matching the configuration id or if there was an exception then the default boolean

getString

public java.lang.String getString(java.lang.String id,
                                  java.lang.String def)
Returns a String configuraton value for the specified configuration id. Should call the getString(String) method of this interface and if there was an exception, returns the specified default value.
Specified by:
getString in interface MJCConfiguration
Parameters:
String - id: the required configuration id
boolean - String: the specified default value
Returns:
boolean: the configuration String matching the configuration id or if there was an exception then the default String

getIntFromStrings

public int getIntFromStrings(java.lang.String id,
                             java.lang.String[] possibilities,
                             int[] values,
                             int def)
Useable if String possible values in the configuration source should be mapped into ints as configuration values. If there is a problem retrieving the int returned, the default value will be returned.
Specified by:
getIntFromStrings in interface MJCConfiguration
Parameters:
String - id: the required configuration id
String[] - possibilities: possible Strings acceptable in the configuration source
int[] - values: int values matching the possible Strings
int - def: the dafault int that should be returned in case of errors
Returns:
int: the int value matching the found possibility String of the def int