Java Reference
In-Depth Information
array, the JSRsView.detectAPIs() method tries to load a Java class
whose name is stored in the ApiInfo.mainClass member:
// The user view of the JSRs Detector MIDlet
public class JSRsView extends Form implements CommandListener {
private Command exit = new Command("Exit", Command.EXIT, 0);
private Command detect = new Command("Detect", Command.OK, 0);
private JSRsDetectorMIDlet midlet;
// CommandListener implementation
public void commandAction(Command cmd, Displayable disp)
{
if (cmd == exit) {
midlet.notifyDestroyed();
}
{
else if (cmd == detect)
detectAPIs();
}
} // Detect supported APIs
private void detectAPIs() {
resetUl();
ApiInfo[] detectedApis = midlet.getApiInfoArray();
for (int i = 0; i < detectedApis.length; i++)
{
try {
Class.forName(detectedApis[i].mainClass);
// class loaded successfully - API is supported
append(detectedApis[i].name + ": Yes \ n");
}
catch (ClassNotFoundException cnfe) {
// class not loaded- API is NOT supported
append(detectedApis[i].name + ": No \ n");
}
}
}
}
The default input to JSRsDetectorMIDlet can be read from the JAD
file by calling the MIDlet's getAppProperty() method sequentially
until NULL is returned. The following JAD properties are loaded and
parsed by the MIDlet to create the array of ApiInfo objects:
JSR1: JSR-139 CLDC 1.1, java.lang.Float
JSR2: JSR-118MIDP 2.0, javax.microedition.lcdui.Custom-
Item
JSR3: JSR-75 PIM, javax.microedition.pim.PIM
JSR4: JSR-75 FileConnection, javax.microedition.io.file.
FileConnection
JSR5: JSR-82 Bluetooth, javax.bluetooth.LocalDevice
JSR6: JSR-135 MMAPI, javax.microedition.media.Manager
JSR7: JSR-172 WS, javax.xml.rpc.JAXRPCException
 
Search WWH ::




Custom Search