FileDocCategorySizeDatePackage
Configuration.javaAPI DocphoneME MR2 API (J2ME)6613Wed May 02 18:00:24 BST 2007com.sun.midp.main

Configuration

public class Configuration extends Object
access the implementation configuration file parameters.

Fields Summary
Constructors Summary
private Configuration()
Don't let anyone instantiate this class

    
Methods Summary
public static intgetIntProperty(java.lang.String key, int def)
Gets the implementation property indicated by the specified key or returns the specified default value as an int.

param
key the name of the implementation property.
param
def the default value for the property if not specified in the configuration files or command line over rides.
return
the int value of the implementation property, or def if there is no property with that key or the config value is not an int.
exception
NullPointerException if key is null.
exception
IllegalArgumentException if key is empty.

        /*
         * Get the  maximum number of persistent connections
         * from the configuration file.
         */
        String prop = getProperty(key);
        if (prop == null) {
            return def;
        }

        try {
            int temp = Integer.parseInt(prop);
            return temp;
        } catch (NumberFormatException nfe) {
            // keep the default
        }

        return def;
    
public static intgetNonNegativeIntProperty(java.lang.String key, int def)
Gets the implementation property indicated by the specified key or returns the specified default value as an non-zero int.

param
key the name of the implementation property.
param
def the default value for the property if not specified in the configuration files or command line over rides.
return
the int value of the implementation property, or def if there is no property with that key or the config value is not an int.
exception
NullPointerException if key is null.
exception
IllegalArgumentException if key is empty.

        int temp = getIntProperty(key, def);

        if (temp >= 0) {
            return temp;
        }

        return def;
    
public static intgetPositiveIntProperty(java.lang.String key, int def)
Gets the implementation property indicated by the specified key or returns the specified default value as an positive int.

param
key the name of the implementation property.
param
def the default value for the property if not specified in the configuration files or command line over rides.
return
the int value of the implementation property, or def if there is no property with that key or the config value is not a positive int (zero is not positive).
exception
NullPointerException if key is null.
exception
IllegalArgumentException if key is empty.

        int temp = getIntProperty(key, def);

        if (temp > 0) {
            return temp;
        }

        return def;
    
public static java.lang.StringgetProperty(java.lang.String key)
Gets the implementation property indicated by the specified key.

param
key the name of the implementation property.
return
the string value of the implementation property, or null if there is no property with that key.
exception
NullPointerException if key is null.
exception
IllegalArgumentException if key is empty.

	// If key is null, then a NullPointerException is thrown.
	// If key is blank, then throw a specific IllegalArgumentException
        if (key.length() ==  0) {
            throw new IllegalArgumentException("key can't be empty");
        }
        return getProperty0(key);
    
private static native java.lang.StringgetProperty0(java.lang.String key)
native interface to the configuration parameter storage.

param
key the name of the implementation property.
return
the string value of the implementation property, or null if there is no property with that key.

public static java.lang.StringgetPropertyDefault(java.lang.String key, java.lang.String def)
Gets the implementation property indicated by the specified key or returns the specified default value.

param
key the name of the implementation property.
param
def the default value for the property if not specified in the configuration files or command line over rides.
return
the string value of the implementation property, or def if there is no property with that key.
exception
NullPointerException if key is null.
exception
IllegalArgumentException if key is empty.

	String result = getProperty(key);

	return (result != null ? result : def);