DevResourceManagerpublic class DevResourceManager extends AppResourceManager This class represents a resource manager for accessing device resources.
It reuses the application resource manager implementation but makes use of
specific DevResourceBundleReader for accessing resources in a
platform-specific way. |
Fields Summary |
---|
private static final String | classnameClass name | public static final byte | TYPE_NUMBER_FORMAT_SYMBOLSConstant for NumberFormatSymbols type. | public static final byte | TYPE_DATETIME_FORMAT_SYMBOLSConstant for DateFormatSymbols type. |
Constructors Summary |
---|
public DevResourceManager(String[] locales, ResourceBundleReader[] readers, ResourceCache resourceCache)Creates a new instance of DevResourceManager . The new
instance can be used to get device resources of the given locale. The
resource files will be accessed through the given resource bundle
reader.
super(DEVICE, locales, readers, resourceCache);
|
Methods Summary |
---|
protected java.lang.Object | cloneResource(java.lang.Object resource)The method clones resource.
Object clon = super.cloneResource(resource);
if (resource instanceof NumberFormatSymbols ||
resource instanceof DateFormatSymbols) {
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_JSR238,
classname + ": clone resource");
}
SerializableResource sr = (SerializableResource)resource;
clon = sr.clone();
}
return clon;
| protected java.lang.Object | convertToResourceType(int resourceID, byte type, ResourceBundleReader reader)Check if it is known resource type by this manager. Convert it to the
expected object. It recognizes {@link #TYPE_STRING},
{@link #TYPE_BINARY},
{@link #TYPE_NUMBER_FORMAT_SYMBOLS},
{@link #TYPE_DATETIME_FORMAT_SYMBOLS}.
DevResourceBundleReader devReader = (DevResourceBundleReader) reader;
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_JSR238,
classname + ": converting resource id = \"" +
resourceID + "\" to object type :\"" + type +
"\" with reader : " + reader);
}
byte[] data = reader.getRawResourceData(resourceID);
if (type == TYPE_STRING) {
try {
Object o = getUTF8(data);
return o;
} catch (IllegalArgumentException iae) {
throw new IOException("Cannot convert string to UTF8\n" +
iae.getMessage());
}
}
if (type == TYPE_BINARY) {
return data;
}
if (type == TYPE_NUMBER_FORMAT_SYMBOLS) {
NumberFormatSymbols nfs = new NumberFormatSymbols();
ByteArrayInputStream bais = new ByteArrayInputStream(data);
nfs.read(bais);
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_JSR238,
classname + ": " +
"Resource type is NUMBER_FORMAT_SYMBOLS");
}
return nfs;
}
if (type == TYPE_DATETIME_FORMAT_SYMBOLS) {
DateFormatSymbols dfs = new DateFormatSymbols();
ByteArrayInputStream bais = new ByteArrayInputStream(data);
dfs.read(bais);
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_JSR238,
classname + ": " +
"Resource type is DATETIME_FORMAT_SYMBOLS");
}
return dfs;
}
return null;
|
|