Class ResourceHash

java.lang.Object
   |
   +----ResourceHash

public class ResourceHash
extends Object
A class that allows a good maintenance of a set of constants. It basically does nothing more than storing a vector of strings representing the names of the resources and another vector representing the values of the same resources.

Written: Radu Sion
Version: 0.14
Source: ResourceHash.java


Constructor Index

 o ResourceHash(Vector, Vector)
Creates a new object.

Method Index

 o getBoolean(String)
Returns the first occurence of a resource value interpreted as a boolean.
 o getDouble(String)
Returns the first occurence of a resource value interpreted as a double.
 o getDoubleValue(String)
Returns a double representing the value of the above .getDouble() returned Double object.
 o getLong(String)
Returns the first occurence of a resource value interpreted as a Long.
 o getLongValue(String)
Returns a long representing the value of the above .getLong() returned Long object.
 o getString(String)
Returns the first occurence of a resource value treated as a string with the given name.
 o size()
Returns the size of this structure, actually the length of the internal arrays that hold the resources.

Constructors

 o ResourceHash
 public ResourceHash(Vector names,
                     Vector values)
Creates a new object. The sizes of the parameters should be the same although no parameter checkings are performed.

Parameters:
names - A Vector containing the resource names as String objects
values - A Vector containing the resource string values as String objects

Methods

 o size
 public int size()
Returns the size of this structure, actually the length of the internal arrays that hold the resources.

 o getString
 public String getString(String resname)
Returns the first occurence of a resource value treated as a string with the given name.

Parameters:
resname - Resource name to consider (case senzitive)
Returns:
The resource value or null if nonexistent or error.
 o getBoolean
 public int getBoolean(String resname)
Returns the first occurence of a resource value interpreted as a boolean. A boolean may have the following string values meaning true or false:
 true: ok, enabled, true, on
 false: disabled, false, off
 

Parameters:
resname - Resource name to consider (case senzitive)
Returns:
1 if resource interpreted as true, 0 if false, -1 if error
 o getLong
 public Long getLong(String resname)
Returns the first occurence of a resource value interpreted as a Long.

Parameters:
resname - Resource name to consider (case senzitive)
Returns:
The value interpreted, null if error
 o getLongValue
 public long getLongValue(String resname)
Returns a long representing the value of the above .getLong() returned Long object.
NOTE: If .getLong() returns null then this method returns 0 !!!
Error tracking is difficult.

Parameters:
resname - Resource name to consider
Returns:
A long or 0 if error (may be zero also if no error !!!)
 o getDouble
 public Double getDouble(String resname)
Returns the first occurence of a resource value interpreted as a double.

Parameters:
resname - Resource name to consider (case senzitive)
Returns:
The value interpreted, null if error
 o getDoubleValue
 public double getDoubleValue(String resname)
Returns a double representing the value of the above .getDouble() returned Double object.
NOTE: If .getDouble() returns null then this method returns 0 !!! Error tracking is difficult !!!

Parameters:
resname - Resource name to consider
Returns:
A double or 0 if error (may be zero also if no error !!!)