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

AutoSuiteDescriptorImpl

public abstract class AutoSuiteDescriptorImpl extends AutoSuiteDescriptor
Base class for AutoSuiteDescriptor implementation

Fields Summary
protected MIDletSuiteImpl
midletSuite
Internal representation of MIDlet suite
protected Vector
suiteMIDlets
Vector containing descriptors of suite's MIDlets
protected int
totalMIDlets
Number of MIDlets in the suite
protected String
suiteName
Name of the suite
protected boolean
isValid
Flag indicating whether this suite valid or not
Constructors Summary
protected AutoSuiteDescriptorImpl(MIDletSuiteImpl midletSuite)
Constructor

param
midletSuite internal representation of MIDlet suite



                 
       
        this.midletSuite = midletSuite;
        this.isValid = true;
        this.totalMIDlets = midletSuite.getNumberOfMIDlets();
        this.suiteName = midletSuite.getProperty(
                MIDletSuiteImpl.SUITE_NAME_PROP);

        updateMIDletsList();
    
Methods Summary
public AutoMIDletDescriptorgetInitialMIDlet()
Gets MIDlet which should be started by default for this suite, if any.

return
AutoMIDletDescriptor representing default MIDlet

        guaranteeSuiteValid("getDefaultMIDlet");
        return (AutoMIDletDescriptor)suiteMIDlets.elementAt(0);
    
static final AutoSuiteDescriptorgetInstanceByClassName(java.lang.String className)
Factory method: constructs suite descriptor from MIDlet's class name

param
className class name of internal MIDlet
return
suite decriptor


        AutoSuiteDescriptor suite = null;
        MIDletSuiteImpl suiteImpl = null;
        try {
            // create internal suite representation
            suiteImpl = (MIDletSuiteImpl)InternalMIDletSuiteImpl.create(
                className, AutoInternalSuiteDescriptorImpl.INTERNAL_SUITE_ID);

            suite = new AutoInternalSuiteDescriptorImpl(className, suiteImpl);
        } finally {
            if (suiteImpl != null) {
                suiteImpl.close();
            }
        }

        return suite;
    
static final AutoSuiteDescriptorgetInstanceBySuiteID(int suiteID, MIDletSuiteStorage storage)
Factory method: constructs suite descriptor from suite ID

param
suiteID ID ot the suite
param
storage suite's storage
return
suite descriptor


        AutoSuiteDescriptor suite = null;
        MIDletSuiteImpl suiteImpl = null;
        try {
            // get internal suite representation from storage
            suiteImpl = storage.getMIDletSuite(suiteID, false);
            if (suiteImpl == null) {
                throw new IllegalArgumentException("Invalid suite ID");
            }
            suite = new AutoExternalSuiteDescriptorImpl(suiteID, suiteImpl);
        } finally {
            if (suiteImpl != null) {
                suiteImpl.close();
            }
        }

        return suite;
    
abstract intgetSuiteID()
Gets suite ID

return
suite ID as String

public java.util.VectorgetSuiteMIDlets()
Gets suite's MIDlets.

return
vector of AutoMIDletDescriptor objects representing suite's MIDlets, null if there is no default MIDlet for this suite

        guaranteeSuiteValid("getSuiteMIDlets");

        // copy suite's MIDlets vector into another
        Vector midlets = new Vector(totalMIDlets);

        for (int i = 0; i < totalMIDlets; i++) {
            Object o = suiteMIDlets.elementAt(i);
            midlets.addElement(o);
        }

        return midlets;
    
public java.lang.StringgetSuiteName()
Gets name of the suite.

return
name of the suite as specified in jar/jad

        guaranteeSuiteValid("getSuiteName");
        return suiteName;
    
final voidguaranteeSuiteValid(java.lang.String s)
Guarantees suite validness: if suite is not valid, exception is thrown

param
s error string


        if (!isValid) {
            throw new IllegalStateException(s);
        }
    
final voidinvalidate()
Invalidates suite

        midletSuite = null;
        suiteMIDlets = null;
        totalMIDlets = 0;

        isValid = false;
    
abstract booleanisExternalSuite()
Tests if this suite is external

return
true, if this suite is internal

public AutoMIDletstart(java.lang.String[] args)
Starts this suite's initial MIDlet.

param
args MIDlet's arguments
return
AutoMIDlet representing started MIDlet

        AutoMIDletDescriptor midlet = getInitialMIDlet();
        return midlet.start(args);
    
abstract voidupdateMIDletsList()
Updates list of suite's MIDlets