FileDocCategorySizeDatePackage
SuiteProperties.javaAPI DocphoneME MR2 API (J2ME)4242Wed May 02 18:00:06 BST 2007com.sun.midp.midletsuite

SuiteProperties

public class SuiteProperties extends Object
The properties for the suite.

Fields Summary
private com.sun.midp.util.Properties
properties
Suite properties from the application descriptor and manifest.
private int
suiteId
The ID of this suite.
Constructors Summary
SuiteProperties(int id)
Package private constructor for SuiteProperties.

param
id of the suite for these settings

        suiteId = id;
    
Methods Summary
public java.lang.StringgetProperty(java.lang.String key)
Gets a property of the suite. A property is an attribute from either the application descriptor or JAR Manifest.

param
key the name of the property
return
A string with the value of the property. null is returned if no value is available for the key.

        if (properties == null) {
            loadProperties();
        }

        return properties.getProperty(key);
    
public intgetSuiteId()
Gets the unique ID of the suite.

return
suite ID

        return suiteId;
    
native java.lang.String[]load()
Gets the suite properties from persistent store. Returns the properties as an array of strings: key0, value0, key1, value1, etc.

return
an array of property key-value pairs
throws
IOException if an IO error occurs

voidloadProperties()
Loads suite properties from persistent storage into a properties object. If an IOException occurs, simply leaves the properties object empty.

        String[] propertyList;

        properties = new Properties();

        try {
            propertyList = load();
        } catch (IOException ioe) {
            return;
        }

        /*
         * Convert the string pairs into properties.
         * JAD properties are stored before Manifest properties, but according
         * to the MIDP spec, for untrusted applications, if an attribute in
         * the descriptor has the same name as an attribute in the manifest
         * the value from the descriptor must be used and the value from the
         * manifest must be ignored. So bellow we loop through the properties
         * backward to override the properties existing in the manifest.
         */
        for (int i = propertyList.length - 2; i >= 0; i -= 2) {
            properties.setProperty(propertyList[i], propertyList[i+1]);
        }
    
public voidsetTempProperty(java.lang.String key, java.lang.String value)
Replace or add a property to the suite for this run only.

param
key the name of the property
param
value the value of the property
exception
SecurityException if the calling suite does not have internal API permission

        if (properties == null) {
            loadProperties();
        }

        properties.setProperty(key, value);