FileDocCategorySizeDatePackage
RunningMIDletSuiteInfo.javaAPI DocphoneME MR2 API (J2ME)7685Wed May 02 18:00:06 BST 2007com.sun.midp.appmanager

RunningMIDletSuiteInfo

public class RunningMIDletSuiteInfo extends MIDletSuiteInfo
Simple attribute storage for MIDlet suites

Fields Summary
public MIDletProxy
proxy
Proxy if running. It is set from AppManagerUI.java.
public Image
icon
Icon for this suite.
private static Image
multiSuiteIcon
Cache of the suite icon.
private static Image
singleSuiteIcon
Cache of the single suite icon.
Constructors Summary
public RunningMIDletSuiteInfo(int theID)
Constructs a RunningMIDletSuiteInfo object for a suite.

param
theID ID the system has for this suite


                         
       
        super(theID);
    
public RunningMIDletSuiteInfo(int theID, String theMidletToRun, String theDisplayName, boolean isEnabled)
Constructs a RunningMIDletSuiteInfo object for a suite.

param
theID ID the system has for this suite
param
theMidletToRun Class name of the only midlet in the suite
param
theDisplayName Name to display to the user
param
isEnabled true if the suite is enabled

        super(theID, theMidletToRun, theDisplayName, isEnabled);
        icon = getDefaultSingleSuiteIcon();
    
public RunningMIDletSuiteInfo(int theID, MIDletSuiteImpl theMidletSuite, MIDletSuiteStorage mss)
Constructs a RunningMIDletSuiteInfo object for a suite.

param
theID ID the system has for this suite
param
theMidletSuite MIDletSuite information
param
mss the midletSuite storage

        super(theID, theMidletSuite);

        icon = getIcon(theID, theMidletSuite.getProperty("MIDlet-Icon"), mss);
        if (icon == null && numberOfMidlets == 1) {
            MIDletInfo midlet =
                new MIDletInfo(theMidletSuite.getProperty("MIDlet-1"));

            // MIDlet icons are optional, so it the icon may be null
            icon = getIcon(theID, midlet.icon, mss);
        }

        if (icon == null) {
            icon = getDefaultSingleSuiteIcon();
        }
    
public RunningMIDletSuiteInfo(MIDletSuiteInfo info, MIDletSuiteStorage mss)
Constructs a RunningMIDletSuiteInfo from MIDletSuiteInfo.

param
info MIDletSuiteInfo reference
param
mss the midletSuite storage

        super(info.suiteId, info.midletToRun, info.displayName,
              info.enabled);

        storageId = info.storageId;
        numberOfMidlets = info.numberOfMidlets;
        trusted = info.trusted;
        preinstalled = info.preinstalled;
        iconName = info.iconName;

        loadIcon(mss);
    
Methods Summary
public booleanequals(MIDletProxy midlet)
Compares this MIDletSuiteInfo with the passed in MIDletProxy. Returns true if both belong to the same suite and if current proxy or midetToRun points to the same class as in the passed in MIDletProxy.

param
midlet The MIDletProxy to compare with
return
true if The MIDletSuiteInfo points to the same midlet as the MIDletProxy, false - otherwise

        if (suiteId == midlet.getSuiteId()) {
            if (proxy != null) {
                return proxy == midlet;
            }

            if ((numberOfMidlets == 1 ||
                 suiteId == MIDletSuite.INTERNAL_SUITE_ID) &&
                    midletToRun != null) {
                return midletToRun.equals(midlet.getClassName());
            }

            return true;
        }

        return false;
    
private static ImagegetDefaultMultiSuiteIcon()
Gets the MIDlet suite icon from storage.

return
icon image

        if (multiSuiteIcon == null) {
            multiSuiteIcon = GraphicalInstaller.
                getImageFromInternalStorage("_ch_suite");
        }
        return multiSuiteIcon;
    
private static ImagegetDefaultSingleSuiteIcon()
Gets the single MIDlet suite icon from storage.

return
icon image

        if (singleSuiteIcon == null) {
            singleSuiteIcon = GraphicalInstaller.
                getImageFromInternalStorage("_ch_single");
        }
        return singleSuiteIcon;
    
public static ImagegetIcon(int theID, java.lang.String iconName, MIDletSuiteStorage mss)
Gets suite icon either from image cache, or from the suite jar.

param
theID the suite id that system has for this suite
param
iconName the name of the file where the icon is stored in the JAR
param
mss The midletSuite storage
return
Image provided by the application with the passed in iconName

        byte[] iconBytes;

        try {
            iconBytes = mss.getMIDletSuiteIcon(theID, iconName);

            if (iconBytes == null) {
                if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                    Logging.report(Logging.WARNING, LogChannels.LC_AMS,
                        "getIcon: iconBytes == null");
                }
                return null;
            }

            return Image.createImage(iconBytes, 0, iconBytes.length);
        } catch (Throwable t) {
            if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                Logging.report(Logging.WARNING, LogChannels.LC_AMS,
                    "getIcon threw an " + t.getClass());
            }
            return null;
        }
    
public voidloadIcon(MIDletSuiteStorage mss)
Loads an icon for this suite.

param
mss the midletSuite storage

        if (iconName != null) {
            icon = getIcon(suiteId, iconName, mss);
        }

        if (icon == null) {
            if (numberOfMidlets == 1) {
                icon = getDefaultSingleSuiteIcon();
            } else {
                icon = getDefaultMultiSuiteIcon();
            }
        }
    
public java.lang.StringtoString()
Returns a string representation of the MIDletSuiteInfo object. For debug only.

        StringBuffer b = new StringBuffer();
        b.append("id = " + suiteId);
        b.append(", midletToRun = " + midletToRun);
        b.append(", proxy = " + proxy);
        return b.toString();