Java DTV API 1.3
18-Nov-2009

com.sun.dtv.lwuit.util
Class Resources

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

public class Resources
extends Object

Loads resources from the binary resource file generated during the build process. Please see Resource File Specification for details. A resource can be loaded entirely into memory, but other approaches are also possible. In case the resource is loaded entirely into memory, sufficient memory must be made available to accommodate the resource file.


Method Summary
 StaticAnimation getAnimation(String id)
          Returns the animation resource from the file.
 String[] getAnimationResourceNames()
          Returns the names of the animations within this bundle.
 InputStream getData(String id)
          Returns the data resource from the file.
 String[] getDataResourceNames()
          Returns the names of the data resources within this bundle.
 Font getFont(String id)
          Returns the font resource from the file.
 String[] getFontResourceNames()
          Returns the names of the fonts within this bundle.
 Image getImage(String id)
          Returns the image resource from the file.
 String[] getImageResourceNames()
          Returns the names of the images within this bundle.
 Hashtable getL10N(String id, String locale)
          Returns a hashmap containing localized String key/value pairs for the given locale name.
 String[] getL10NResourceNames()
          Returns the names of the localization bundles within this bundle.
 String[] getResourceNames()
          Returns the names of the resources within this bundle.
 Hashtable getTheme(String id)
          Returns the theme resource from the file.
 String[] getThemeResourceNames()
          Returns the names of the images within this bundle.
 boolean isAnimation(String name)
          Returns true if this is an animation resource.
 boolean isData(String name)
          Returns true if this is a data resource.
 boolean isFont(String name)
          Returns true if this is a font resource.
 boolean isImage(String name)
          Returns true if this is an image resource.
 boolean isL10N(String name)
          Returns true if this is a locale resource.
 boolean isTheme(String name)
          Returns true if this is a theme resource.
static Resources open(InputStream resource)
          Creates a resource object from the given input stream.
static Resources open(String resource)
          Creates a resource object from the local JAR resource identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getResourceNames

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

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

getDataResourceNames

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

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

getL10NResourceNames

public 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 String[] getFontResourceNames()
Returns the names of the fonts within this bundle.

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

getThemeResourceNames

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

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

getImageResourceNames

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

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

getAnimationResourceNames

public String[] getAnimationResourceNames()
Returns the names of the animations within this bundle.

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

isL10N

public boolean isL10N(String name)
Returns true if this is a locale resource.

Parameters:
name - the name of the resource
Returns:
true if the resource is a locale resource
Throws:
NullPointerException - if the resource doesn't exist

isTheme

public boolean isTheme(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:
NullPointerException - if the resource doesn't exist

isFont

public boolean isFont(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:
NullPointerException - if the resource doesn't exist

isAnimation

public boolean isAnimation(String name)
Returns true if this is an animation resource.

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

isData

public boolean isData(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:
NullPointerException - if the resource doesn't exist

isImage

public boolean isImage(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:
NullPointerException - if the resource doesn't exist

open

public static Resources open(String resource)
                      throws 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:
IOException - if opening/reading the resource fails

open

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

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

getImage

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

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

getAnimation

public StaticAnimation getAnimation(String id)
Returns the animation resource from the file.

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

getData

public InputStream getData(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 Hashtable getL10N(String id,
                         String locale)
Returns a hashmap containing localized String key/value pairs for the given locale name.

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

getFont

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

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

getTheme

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

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

Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.