ResourceHandlerpublic class ResourceHandler extends Object The ResourceHandler class is a system level utility class.
Its purpose is to return system resources as an array of bytes
based on a unique String identifier. All methods in this utility
class should be protected through use of the SecurityToken. |
Methods Summary |
---|
public static byte[] | getAmsResource(com.sun.midp.security.SecurityToken token, java.lang.String resource)Load a resource from the system and return it as a byte array.
This method is used to load AMS icons.
return getResourceImpl(token, File.getStorageRoot(
Constants.INTERNAL_STORAGE_ID) + resource);
| private static byte[] | getResourceImpl(com.sun.midp.security.SecurityToken token, java.lang.String resourceFilename)Load a resource from the system and return it as a byte array.
This method is used to load system level resources, such as
images, sounds, properties, etc.
token.checkIfPermissionAllowed(Permissions.MIDP);
byte[] resourceBuffer = null;
RandomAccessStream stream = new RandomAccessStream(token);
try {
stream.connect(resourceFilename, Connector.READ);
resourceBuffer = new byte[stream.getSizeOf()];
stream.readBytes(resourceBuffer, 0, resourceBuffer.length);
} catch (java.io.IOException e) {
resourceBuffer = null;
} finally {
try {
stream.disconnect();
} catch (java.io.IOException ignored) {
}
}
return resourceBuffer;
| public static byte[] | getSystemImageResource(com.sun.midp.security.SecurityToken token, java.lang.String imageName)Load a system image resource from the system and return it as
a byte array. The images are stored in the configuration
directory ($MIDP_HOME/lib).
byte[] imageData = getAmsResource(token, imageName + ".raw");
if (imageData == null) {
imageData = getAmsResource(token, imageName + ".png");
}
return imageData;
| public static byte[] | getSystemResource(com.sun.midp.security.SecurityToken token, java.lang.String resource)Load a resource from the system and return it as a byte array.
This method is used to load system level resources, such as
images, sounds, properties, etc.
return getResourceImpl(token, File.getConfigRoot(
Constants.INTERNAL_STORAGE_ID) + resource);
|
|