FileDocCategorySizeDatePackage
AutoSuiteStorageImpl.javaAPI DocphoneME MR2 API (J2ME)4736Wed May 02 18:00:08 BST 2007com.sun.midp.automation

AutoSuiteStorageImpl

public final class AutoSuiteStorageImpl extends AutoSuiteStorage
AutoSuiteStorage implementation

Fields Summary
private MIDletSuiteStorage
storage
Suites storage
private Installer
installer
Suites installer
private Vector
installedSuites
Vector containing decriptors of installed suites
private static AutoSuiteStorageImpl
instance
The one and only class instance
Constructors Summary
private AutoSuiteStorageImpl()
Private constructor: this class is singleton



               
      
        storage = MIDletSuiteStorage.getMIDletSuiteStorage();
        installedSuites = new Vector();
    
Methods Summary
public java.util.VectorgetInstalledSuites()
Gets a vector of installed suites.

return
vector with suites descriptors

        updateInstalledSuites();

        /** copy vector of installed suites into new vector */
        int totalSuites = installedSuites.size();
        Vector suites = new Vector(totalSuites);

        for (int i = 0; i < totalSuites; i++) {
            Object o = installedSuites.elementAt(i);
            suites.addElement(o);
        }

        return suites;
    
static synchronized com.sun.midp.automation.AutoSuiteStorageImplgetInstance()
Gets class instance

return
single AutoSuiteStorage instance

        if (instance == null) {
            instance = new AutoSuiteStorageImpl();
        }

        return instance;
    
public AutoSuiteDescriptorinstallSuite(java.lang.String location)
Installs suite from specified location.

param
location URI pointing to suite jad/jar
return
AutoSuiteDescriptor representing installed suit


        AutoSuiteDescriptor suite = null;
        int suiteID;

        installer = AutoGetInstallerTunnel.getInstaller(location);
        suiteID = installer.installJad(location, Constants.INTERNAL_STORAGE_ID,
            true, true, null);
        suite = AutoSuiteDescriptorImpl.getInstanceBySuiteID(suiteID,
                storage);

        return suite;
    
public voiduninstallSuite(AutoSuiteDescriptor suite)
Uninstalls specified suite.

param
suite suite to uninstall


        AutoSuiteDescriptorImpl suiteImpl = (AutoSuiteDescriptorImpl)suite;
        suiteImpl.guaranteeSuiteValid("uninstallSuite");

        if (suiteImpl.isExternalSuite()) {
            int suiteID = suiteImpl.getSuiteID();
            storage.remove(suiteID);
        }

        /** uninstalling suite makes it invalid */
        suiteImpl.invalidate();
    
private voidupdateInstalledSuites()
Updates vector of installed suites

        int[] suiteIDs;

        suiteIDs = storage.getListOfSuites();
        installedSuites = new Vector(suiteIDs.length);

        for (int i = 0; i < suiteIDs.length; i++) {
            AutoSuiteDescriptor suite;
            try {
                suite = AutoSuiteDescriptorImpl.getInstanceBySuiteID(
                        suiteIDs[i], storage);
                installedSuites.addElement(suite);
            } catch (Exception e) {
                // ignore and move to next suite
            }
        }