001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.midp.midletsuite;
028:
029: import com.sun.midp.main.*;
030:
031: import com.sun.midp.configurator.Constants;
032:
033: /** Simple attribute storage for MIDlet suites */
034: public class MIDletSuiteInfo {
035: /** ID of the MIDlet suite. */
036: public int suiteId;
037: /** ID of the storage where the MIDlet is installed. */
038: public int storageId = Constants.INTERNAL_STORAGE_ID;
039: /** Display name of the MIDlet suite. */
040: public String displayName = null;
041: /** Name of the MIDlet to run. */
042: public String midletToRun = null;
043: /** Is this single MIDlet MIDlet suite. */
044: public int numberOfMidlets = 0;
045: /** Is this suite enabled. */
046: public boolean enabled = false;
047: /** Is this suite trusted. */
048: public boolean trusted = false;
049: /** Is this suite preinstalled. */
050: public boolean preinstalled = false;
051: /** Icon's name for this suite. */
052: public String iconName = null;
053:
054: /**
055: * Constructs a MIDletSuiteInfo object for a suite.
056: *
057: * @param theID ID the system has for this suite
058: */
059: public MIDletSuiteInfo(int theID) {
060: suiteId = theID;
061: }
062:
063: /**
064: * Constructs a MIDletSuiteInfo object for a suite.
065: *
066: * @param theID ID the system has for this suite
067: * @param theMidletToRun Class name of the only midlet in the suite
068: * @param theDisplayName Name to display to the user
069: * @param isEnabled true if the suite is enabled
070: */
071: public MIDletSuiteInfo(int theID, String theMidletToRun,
072: String theDisplayName, boolean isEnabled) {
073: suiteId = theID;
074: midletToRun = theMidletToRun;
075: displayName = theDisplayName;
076: enabled = isEnabled;
077: }
078:
079: /**
080: * Constructs a MIDletSuiteInfo object for a suite.
081: *
082: * @param theID ID the system has for this suite
083: * @param theMidletSuite MIDletSuite information
084: */
085: public MIDletSuiteInfo(int theID, MIDletSuiteImpl theMidletSuite) {
086: init(theID, theMidletSuite);
087:
088: numberOfMidlets = theMidletSuite.getNumberOfMIDlets();
089:
090: if (numberOfMidlets == 1) {
091: MIDletInfo midlet = new MIDletInfo(theMidletSuite
092: .getProperty("MIDlet-1"));
093:
094: midletToRun = midlet.classname;
095: }
096: }
097:
098: /**
099: * Initializes MIDletSuiteInfo object.
100: *
101: * @param theID ID the system has for this suite
102: * @param theMidletSuite MIDletSuite information
103: */
104: void init(int theID, MIDletSuiteImpl theMidletSuite) {
105: displayName = theMidletSuite
106: .getProperty(MIDletSuiteImpl.SUITE_NAME_PROP);
107:
108: if (displayName == null) {
109: displayName = String.valueOf(theID);
110: }
111:
112: suiteId = theID;
113:
114: enabled = theMidletSuite.isEnabled();
115: }
116:
117: /**
118: * Checks if the midlet suite contains single or multiple midlets.
119: *
120: * @return true is this midlet suite contains only one midlet,
121: * false otherwise
122: */
123: public boolean hasSingleMidlet() {
124: return (numberOfMidlets == 1);
125: }
126:
127: /**
128: * Returns a string representation of the MIDletSuiteInfo object.
129: * For debug only.
130: */
131: public String toString() {
132: StringBuffer b = new StringBuffer();
133: b.append("id = " + suiteId);
134: b.append(", midletToRun = " + midletToRun);
135: return b.toString();
136: }
137: }
|