org.jogre.common.util
Class AbstractProperties

java.lang.Object
  extended byorg.jogre.common.util.AbstractProperties
Direct Known Subclasses:
GameLabels, GameProperties, JogreLabels

public abstract class AbstractProperties
extends Object

Abstract class which provides various methods which are common to GameProperties, GameLabels and JogreLabels.

Version:
Alpha 0.2.3
Author:
Bob Marks

Field Summary
protected  ResourceBundle rb
          Resource bundle.
 
Constructor Summary
protected AbstractProperties(String filename)
          Private constructor (Can only be called by the getInstance() method.
 
Method Summary
 String get(String key)
          Return the "value" for a specified "key" inside the resource bundle as a String.
 String get(String key, Object[] arguments)
          Return the "value" for a specified "key" inside the resource bundle as an String value, in case "value" contains "variables".
 String get(String key, String defaultValue)
          Return the "value" for a specified "key" inside the resource bundle as a String.
 boolean getBoolean(String key)
          Return a boolean value from a key.
 boolean getBoolean(String key, boolean defaultValue)
          Return a boolean value from a key.
 int getInt(String key)
          Return the "value" for a specified "key" inside the resource bundle as an int value.
 int getInt(String key, int defaultValue)
          Return the "value" for a specified "key" inside the resource bundle as an int value.
 ResourceBundle getResourceBundle()
           
 void reload()
          Reload all resource bundles (if there has been a
 void reset()
          Recreates ResourceBundle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rb

protected ResourceBundle rb
Resource bundle.

Constructor Detail

AbstractProperties

protected AbstractProperties(String filename)
Private constructor (Can only be called by the getInstance() method.

Parameters:
filename -
Method Detail

reload

public void reload()
Reload all resource bundles (if there has been a


get

public String get(String key)
Return the "value" for a specified "key" inside the resource bundle as a String.

Parameters:
key - Key to get value from.
Returns:
Trimed value from a specified trimmed key.

get

public String get(String key,
                  String defaultValue)
Return the "value" for a specified "key" inside the resource bundle as a String. If the value doesn't

Parameters:
key - Key to get value from.
defaultValue - Default value if key doesn't retrieve a value.
Returns:
String value.

getInt

public int getInt(String key)
Return the "value" for a specified "key" inside the resource bundle as an int value.

Parameters:
key - Key to get value from.
Returns:
String value.

getInt

public int getInt(String key,
                  int defaultValue)
Return the "value" for a specified "key" inside the resource bundle as an int value. If the value doesn't exist then return its defaultValue instead.

Parameters:
key - Key to get value from.
defaultValue - Default integer value if key isn't found.
Returns:
Integer value.

get

public String get(String key,
                  Object[] arguments)
Return the "value" for a specified "key" inside the resource bundle as an String value, in case "value" contains "variables". If the value doesn't exist then return null. instead. Example of use: property.with.five.variables = This property is the {1} and contains this variables: {2},{3},{4} and {5} In java code: ObjectArray[] = {"1",new Integer(2),"-23",new Double(2.34),0} String text = labels.get("property.with.five.variables",ObjectArray) and then text = This property is the 1 and contains this variables: 2,-23,2.34 and 0

Parameters:
key - Key to get value from.
arguments - Arguments
Returns:
String value.

getBoolean

public boolean getBoolean(String key)
Return a boolean value from a key.

Parameters:
key - Key to get value from.
Returns:
Returns true if value="true"

getBoolean

public boolean getBoolean(String key,
                          boolean defaultValue)
Return a boolean value from a key. If the key doesn't exist then return the default value.

Parameters:
key - Key to get value from.
defaultValue - Default boolean value if key isn't found.
Returns:
Returns true if value="true" or default value if not value exists.

reset

public void reset()
Recreates ResourceBundle


getResourceBundle

public ResourceBundle getResourceBundle()