ResourceManager Class

ResourceManager Class

This Package | All Packages

public final class ResourceManager

Manages resource data. Resource data can be stored and retrieved in a locale- specific manner. This enables the creation of localizable applications.

Fields
Name Description
EXTENSION Extension given to all resource files.

Constructors
Name Description
ResourceManager(IResourceLoader loader, String baseName) Creates a ResourceManager.

Methods
Name Description
flush() Releases any cached resource data.
getBoolean(String name) Retrieves a boolean for the specified property that is valid for the current locale.
getBoolean(Locale locale, String name) Retrieves the boolean for the specified property that is valid for the specified locale.
getByte(String name) Retrieves a byte for the specified property that is valid for the current locale.
getByte(Locale locale, String name) Retrieves the byte for the specified property that is valid for the specified locale.
getChar(String name) Retrieves a character for the specified property that is valid for the current locale.
getChar(Locale locale, String name) Retrieves the character for the specified property that is valid for the specified locale.
getDouble(String name) Retrieves a double for the specified property that is valid for the current locale.
getDouble(Locale locale, String name) Retrieves the double for the specified property that is valid for the specified locale.
getFloat(String name) Retrieves a float for the specified property that is valid for the current locale.
getFloat(Locale locale, String name) Retrieves the float for the specified property that is valid for the specified locale.
getInt(String name) Retrieves a integer for the specified property that is valid for the current locale.
getInt(Locale locale, String name) Retrieves the integer for the specified property that is valid for the specified locale.
getLocaleFileName(Locale locale) Retrieves the file name for the specified locale.
getLocaleFileNameFromBase(Locale locale, String baseName) Computes the localized file name given the specified locale and baseName.
getLong(String name) Retrieves a long for the specified property that is valid for the current locale.
getLong(Locale locale, String name) Retrieves the long for the specified property that is valid for the specified locale.
getNames() Retrieves all the property names for the current locale.
getNames(Locale locale) Retrieves all the property names for the specified locale.
getObject(String name) Retrieves an object for the specified property that is valid for the current locale.
getObject(Locale locale, String name) Retrieves the object for the specified property that is valid for the specified locale.
getObjects() Retrieves all the property values for the current locale.
getObjects(Locale locale) Retrieves all the property values for the current locale.
getShort(String name) Retrieves a short for the specified property that is valid for the current locale.
getShort(Locale locale, String name) Retrieves the short for the specified property that is valid for the specified locale.
getString(String name) Retrieves a string for the specified property that is valid for the current locale.
getString(Locale locale, String name) Retrieves the string for the specified property that is valid for the specified locale.
getValidData(Object value) Retrieves true if the specified value can be stored as a resource property.
loadResourceAsStream(Class src, String name) Loads an arbitrary binary resource file for the specified class.
setBoolean(Locale locale, String name, boolean value) Sets the value for a property for the specified locale.
setByte(Locale locale, String name, byte value) Sets the value for a property for the specified locale.
setChar(Locale locale, String name, char value) Sets the value for a property for the specified locale.
setDouble(Locale locale, String name, double value) Sets the value for a property for the specified locale.
setFloat(Locale locale, String name, float value) Sets the value for a property for the specified locale.
setInt(Locale locale, String name, int value) Sets the value for a property for the specified locale.
setLong(Locale locale, String name, long value) Sets the value for a property for the specified locale.
setObject(Locale locale, String name, Object value) Sets the value for a property for the specified locale.
setShort(Locale locale, String name, short value) Sets the value for a property for the specified locale.
setString(Locale locale, String name, String value) Sets the value for a property for the specified locale.

Fields

ResourceManager.EXTENSION

Syntax
public static final String EXTENSION;
Description
Extension given to all resource files.

Constructors

ResourceManager.ResourceManager

Syntax
public ResourceManager( IResourceLoader loader, String baseName );
Parameters
component
The component to get resources for.
baseName
The base file name.
Description

Creates a ResourceManager. The resource manager gets data relative to the specified component that has the baseName specified. The baseName should be the root name of the resource files. For example, the base name for the files "MyResource_enu.resources" and "MyResource_jpn.resources" is "MyResource".

Methods

ResourceManager.flush

Syntax
public void flush();
Description

Releases any cached resource data.

ResourceManager.getBoolean

Syntax 1
public boolean getBoolean( String name );
Parameters
name
the name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves a boolean for the specified property that is valid for the current locale.



Syntax 2
public boolean getBoolean( Locale locale, String name );
Parameters
locale
The locale to get the property for.
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves the boolean for the specified property that is valid for the specified locale.

ResourceManager.getByte

Syntax 1
public byte getByte( String name );
Parameters
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves a byte for the specified property that is valid for the current locale.



Syntax 2
public byte getByte( Locale locale, String name );
Parameters
locale
The locale to get the property for.
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves the byte for the specified property that is valid for the specified locale.

ResourceManager.getChar

Syntax 1
public char getChar( String name );
Parameters
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves a character for the specified property that is valid for the current locale.



Syntax 2
public char getChar( Locale locale, String name );
Parameters
locale
The locale to get the property for.
name
The Name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves the character for the specified property that is valid for the specified locale.

ResourceManager.getDouble

Syntax 1
public double getDouble( String name );
Parameters
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves a double for the specified property that is valid for the current locale.



Syntax 2
public double getDouble( Locale locale, String name );
Parameters
locale
The locale to get the property for.
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves the double for the specified property that is valid for the specified locale.

ResourceManager.getFloat

Syntax 1
public float getFloat( String name );
Parameters
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves a float for the specified property that is valid for the current locale.



Syntax 2
public float getFloat( Locale locale, String name );
Parameters
locale
The locale to get the property for.
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves the float for the specified property that is valid for the specified locale.

ResourceManager.getInt

Syntax 1
public int getInt( String name );
Parameters
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves a integer for the specified property that is valid for the current locale.



Syntax 2
public int getInt( Locale locale, String name );
Parameters
locale
The locale to get the property for.
name
The name of the property to retrieve.
Return Value

Returns property value.

Description

Retrieves the integer for the specified property that is valid for the specified locale.

ResourceManager.getLocaleFileName

Syntax
public String getLocaleFileName( Locale locale );
Parameters
locale
The locale to use.
Return Value

Returns the localized file name.

Description

Retrieves the file name for the specified locale.

ResourceManager.getLocaleFileNameFromBase

Syntax
public static String getLocaleFileNameFromBase( Locale locale, String baseName );
Parameters
locale
The locale to use.
baseName
The base resource file name.
Return Value

Returns the localized file name.

Description

Computes the localized file name given the specified locale and baseName.

ResourceManager.getLong

Syntax 1
public long getLong( String name );
Parameters
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves a long for the specified property that is valid for the current locale.



Syntax 2
public long getLong( Locale locale, String name );
Parameters
locale
The locale to get the property for.
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves the long for the specified property that is valid for the specified locale.

ResourceManager.getNames

Syntax 1
public String[] getNames();
Return Value

Returns a string array containing all the names for properties.

Description

Retrieves all the property names for the current locale.



Syntax 2
public String[] getNames( Locale locale );
Parameters
locale
The locale to retrieve names for.
Return Value

Returns a string array containing all the names for properties.

Description

Retrieves all the property names for the specified locale.

ResourceManager.getObject

Syntax 1
public Object getObject( String name );
Parameters
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves an object for the specified property that is valid for the current locale.



Syntax 2
public Object getObject( Locale locale, String name );
Parameters
locale
The locale to get the property for.
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves the object for the specified property that is valid for the specified locale.

ResourceManager.getObjects

Syntax 1
public Object[] getObjects();
Return Value

Returns an object array containing all the values for properties.

Description

Retrieves all the property values for the current locale.



Syntax 2
public Object[] getObjects( Locale locale );
Parameters
locale
The locale to retrieve values for.
Return Value

Returns an object array containing all the values for properties.

Description

Retrieves all the property values for the current locale.

ResourceManager.getShort

Syntax 1
public short getShort( String name );
Parameters
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves a short for the specified property that is valid for the current locale.



Syntax 2
public short getShort( Locale locale, String name );
Parameters
locale
The locale to get the property for.
name
the name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves the short for the specified property that is valid for the specified locale.

ResourceManager.getString

Syntax 1
public String getString( String name );
Parameters
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves a string for the specified property that is valid for the current locale.



Syntax 2
public String getString( Locale locale, String name );
Parameters
locale
The locale to get the property for.
name
The name of the property to retrieve.
Return Value

Returns the property value.

Description

Retrieves the string for the specified property that is valid for the specified locale.

ResourceManager.getValidData

Syntax
public static boolean getValidData( Object value );
Parameters
value
The value to check.
Return Value

Returns true if the value can be stored in a resource file.

Description

Retrieves true if the specified value can be stored as a resource property.

ResourceManager.loadResourceAsStream

Syntax
public static IDataStream loadResourceAsStream( Class src, String name );
Parameters
src
The class to load the resource for.
name
The name of the resource to load.
Return Value

Returns the IDataStream for the specified resource.

Description

Loads an arbitrary binary resource file for the specified class. This does not load a resource property file. It is a standalone binary file that is a resource for the specified class.

ResourceManager.setBoolean

Syntax
public void setBoolean( Locale locale, String name, boolean value );
Parameters
locale
The locale the property is for.
name
The name of the property.
value
The value to assign to that property.
Description

Sets the value for a property for the specified locale.

ResourceManager.setByte

Syntax
public void setByte( Locale locale, String name, byte value );
Parameters
locale
The locale the property is for.
name
The name of the property.
value
The value to assign to that property.
Description

Sets the value for a property for the specified locale.

ResourceManager.setChar

Syntax
public void setChar( Locale locale, String name, char value );
Parameters
locale
The locale the property is for.
name
The name of the property.
value
The value to assign to that property.
Description

Sets the value for a property for the specified locale.

ResourceManager.setDouble

Syntax
public void setDouble( Locale locale, String name, double value );
Parameters
locale
The locale the property is for.
name
The name of the property.
value
The value to assign to that property.
Description

Sets the value for a property for the specified locale.

ResourceManager.setFloat

Syntax
public void setFloat( Locale locale, String name, float value );
Parameters
locale
The locale the property is for.
name
The name of the property.
value
The value to assign to that property.
Description

Sets the value for a property for the specified locale.

ResourceManager.setInt

Syntax
public void setInt( Locale locale, String name, int value );
Parameters
locale
The locale the property is for.
name
The name of the property.
value
The value to assign to that property.
Description

Sets the value for a property for the specified locale.

ResourceManager.setLong

Syntax
public void setLong( Locale locale, String name, long value );
Parameters
locale
The locale the property is for.
name
The name of the property.
value
The value to assign to that property.
Description

Sets the value for a property for the specified locale.

ResourceManager.setObject

Syntax
public void setObject( Locale locale, String name, Object value );
Parameters
locale
The locale the property is for.
name
The name of the property.
value
The value to assign to that property.
Description

Sets the value for a property for the specified locale.

ResourceManager.setShort

Syntax
public void setShort( Locale locale, String name, short value );
Parameters
locale
The locale the property is for.
name
The name of the property.
value
The value to assign to that property.
Description

Sets the value for a property for the specified locale.

ResourceManager.setString

Syntax
public void setString( Locale locale, String name, String value );
Parameters
locale
The locale the property is for.
name
The name of the property.
value
The value to assign to that property.
Description

Sets the value for a property for the specified locale.