com.sun.lwuit.util
Class Resources

java.lang.Object
  extended by com.sun.lwuit.util.Resources

public class Resources
extends java.lang.Object

Loads resources from the binary resource file generated during the build process or via the LWUIT Designer. A resource is loaded entirely into memory since random file access is not supported in Java ME, any other approach would be inefficient. This means that memory must be made available to accommodate the resource file.


Method Summary
 StaticAnimation getAnimation(java.lang.String id)
          Deprecated. use getImage(String) instead
 java.io.InputStream getData(java.lang.String id)
          Returns the data resource from the file
 java.lang.String[] getDataResourceNames()
          Returns the names of the data resources within this bundle
 Font getFont(java.lang.String id)
          Returns the font resource from the file
 java.lang.String[] getFontResourceNames()
          Returns the names of the fonts within this bundle
 Image getImage(java.lang.String id)
          Returns the image resource from the file
 java.lang.String[] getImageResourceNames()
          Returns the names of the images within this bundle
 java.util.Hashtable getL10N(java.lang.String id, java.lang.String locale)
          Returns a hashmap containing localized String key/value pairs for the given locale name
 java.lang.String[] getL10NResourceNames()
          Returns the names of the localization bundles within this bundle
 int getMajorVersion()
          Returns the version number for this resource file.
 java.lang.String[] getMetaData()
          Returns optional meta-data associated with the resource file
 int getMinorVersion()
          Returns the minor version number for this resource file This value relates to the value from the header defined by the resource file specification.
 java.lang.String[] getResourceNames()
          Returns the names of the resources within this bundle
 java.util.Hashtable getTheme(java.lang.String id)
          Returns the theme resource from the file
 java.lang.String[] getThemeResourceNames()
          Returns the names of the images within this bundle
 java.lang.String[] getUIResourceNames()
          Returns the names of the ui resources within this bundle
 boolean isAnimation(java.lang.String name)
          Deprecated. animations are no longer distinguished from images in the resource file, use Image.isAnimation instead
 boolean isData(java.lang.String name)
          Returns true if this is a data resource
 boolean isFont(java.lang.String name)
          Returns true if this is a font resource
 boolean isImage(java.lang.String name)
          Returns true if this is an image resource
 boolean isL10N(java.lang.String name)
          Returns true if this is a generic data resource
 boolean isTheme(java.lang.String name)
          Returns true if this is a theme resource
 boolean isUI(java.lang.String name)
          Returns true if this is a UI resource
 java.util.Enumeration listL10NLocales(java.lang.String id)
          Returns an enumration of the locales supported by this resource id
static Resources open(java.io.InputStream resource)
          Creates a resource object from the given input stream
static Resources open(java.lang.String resource)
          Creates a resource object from the local JAR resource identifier
static void setPassword(java.lang.String password)
          Sets the password to use for password protected resource files
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setPassword

public static void setPassword(java.lang.String password)
Sets the password to use for password protected resource files

Parameters:
password - the password or null to clear the password

getMajorVersion

public int getMajorVersion()
Returns the version number for this resource file. This value relates to the value from the header defined by the resource file specification. 0 is returned for legacy versions of the resource file format.

Returns:
major version number for the resource file

getMinorVersion

public int getMinorVersion()
Returns the minor version number for this resource file This value relates to the value from the header defined by the resource file specification.

Returns:
minor version number for the resource file

getMetaData

public java.lang.String[] getMetaData()
Returns optional meta-data associated with the resource file

Returns:
optional meta-data associated with the file

getResourceNames

public java.lang.String[] getResourceNames()
Returns the names of the resources within this bundle

Returns:
array of names of all the resources in this bundle

getDataResourceNames

public java.lang.String[] getDataResourceNames()
Returns the names of the data resources within this bundle

Returns:
array of names of the data resources in this bundle

getUIResourceNames

public java.lang.String[] getUIResourceNames()
Returns the names of the ui resources within this bundle

Returns:
array of names of the ui resources in this bundle

getL10NResourceNames

public java.lang.String[] getL10NResourceNames()
Returns the names of the localization bundles within this bundle

Returns:
array of names of the localization resources in this bundle

getFontResourceNames

public java.lang.String[] getFontResourceNames()
Returns the names of the fonts within this bundle

Returns:
array of names of the font resources in this bundle

getThemeResourceNames

public java.lang.String[] getThemeResourceNames()
Returns the names of the images within this bundle

Returns:
array of names of the image resources in this bundle

getImageResourceNames

public java.lang.String[] getImageResourceNames()
Returns the names of the images within this bundle

Returns:
array of names of the image resources in this bundle

isL10N

public boolean isL10N(java.lang.String name)
Returns true if this is a generic data resource

Parameters:
name - the name of the resource
Returns:
true if the resource is a data resource
Throws:
java.lang.NullPointerException - if the resource doesn't exist

isTheme

public boolean isTheme(java.lang.String name)
Returns true if this is a theme resource

Parameters:
name - the name of the resource
Returns:
true if the resource is a theme
Throws:
java.lang.NullPointerException - if the resource doesn't exist

isFont

public boolean isFont(java.lang.String name)
Returns true if this is a font resource

Parameters:
name - the name of the resource
Returns:
true if the resource is a font
Throws:
java.lang.NullPointerException - if the resource doesn't exist

isAnimation

public boolean isAnimation(java.lang.String name)
Deprecated. animations are no longer distinguished from images in the resource file, use Image.isAnimation instead

Returns true if this is an animation resource

Parameters:
name - the name of the resource
Returns:
true if the resource is an animation
Throws:
java.lang.NullPointerException - if the resource doesn't exist

isData

public boolean isData(java.lang.String name)
Returns true if this is a data resource

Parameters:
name - the name of the resource
Returns:
true if the resource is a data resource
Throws:
java.lang.NullPointerException - if the resource doesn't exist

isUI

public boolean isUI(java.lang.String name)
Returns true if this is a UI resource

Parameters:
name - the name of the resource
Returns:
true if the resource is a UI resource
Throws:
java.lang.NullPointerException - if the resource doesn't exist

isImage

public boolean isImage(java.lang.String name)
Returns true if this is an image resource

Parameters:
name - the name of the resource
Returns:
true if the resource is an image
Throws:
java.lang.NullPointerException - if the resource doesn't exist

open

public static Resources open(java.lang.String resource)
                      throws java.io.IOException
Creates a resource object from the local JAR resource identifier

Parameters:
resource - a local reference to a resource using the syntax of Class.getResourceAsStream(String)
Returns:
a resource object
Throws:
java.io.IOException - if opening/reading the resource fails

open

public static Resources open(java.io.InputStream resource)
                      throws java.io.IOException
Creates a resource object from the given input stream

Parameters:
resource - stream from which to read the resource
Returns:
a resource object
Throws:
java.io.IOException - if opening/reading the resource fails

getImage

public Image getImage(java.lang.String id)
Returns the image resource from the file

Parameters:
id - name of the image resource
Returns:
cached image instance

getAnimation

public StaticAnimation getAnimation(java.lang.String id)
Deprecated. use getImage(String) instead

Returns the animation resource from the file

Parameters:
id - name of the animation resource
Returns:
cached image instance

getData

public java.io.InputStream getData(java.lang.String id)
Returns the data resource from the file

Parameters:
id - name of the data resource
Returns:
newly created input stream that allows reading the data of the resource

getL10N

public java.util.Hashtable getL10N(java.lang.String id,
                                   java.lang.String locale)
Returns a hashmap containing localized String key/value pairs for the given locale name

Parameters:
id - the name of the locale resource
locale - name of the locale resource
Returns:
Hashtable containing key value pairs for localized data

listL10NLocales

public java.util.Enumeration listL10NLocales(java.lang.String id)
Returns an enumration of the locales supported by this resource id

Parameters:
id - the name of the locale resource
Returns:
enumeration of strings containing bundle names

getFont

public Font getFont(java.lang.String id)
Returns the font resource from the file

Parameters:
id - name of the font resource
Returns:
cached font instance

getTheme

public java.util.Hashtable getTheme(java.lang.String id)
Returns the theme resource from the file

Parameters:
id - name of the theme resource
Returns:
cached theme instance