org.geotools.resources
Class ResourceBundle

java.lang.Object
  extended byjava.util.ResourceBundle
      extended byorg.geotools.resources.ResourceBundle
Direct Known Subclasses:
Descriptions, Errors, Logging, Vocabulary

public class ResourceBundle
extends java.util.ResourceBundle

{link java.util.ResourceBundle} implementation using integers instead of strings for resource keys. Because it doesn't use strings, this implementation avoids adding all those string constants to files and runtime images. Developers still have meaningful labels in their code (e.g. ) through a set of constants defined in interfaces. This approach furthermore gives the benefit of compile-time safety. Because integer constants are inlined right into class files at compile time, the declarative interface is never loaded at run time. This class also provides facilities for string formatting using MessageFormat.

Since:
2.0
Version:
$Id: ResourceBundle.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux

Field Summary
 
Fields inherited from class java.util.ResourceBundle
parent
 
Constructor Summary
protected ResourceBundle()
          Constructs a new resource bundle.
protected ResourceBundle(java.lang.String filename)
          Constructs a new resource bundle.
 
Method Summary
 java.util.Enumeration getKeys()
          Returns an enumeration of the keys.
 java.lang.String getLabel(int key)
          Gets a string for the given key and appends ": " to it.
 java.util.logging.LogRecord getLogRecord(java.util.logging.Level level, int key)
          Gets a localized log record.
 java.util.logging.LogRecord getLogRecord(java.util.logging.Level level, int key, java.lang.Object arg0)
          Gets a localized log record.
 java.util.logging.LogRecord getLogRecord(java.util.logging.Level level, int key, java.lang.Object arg0, java.lang.Object arg1)
          Gets a localized log record.
 java.util.logging.LogRecord getLogRecord(java.util.logging.Level level, int key, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2)
          Gets a localized log record.
 java.util.logging.LogRecord getLogRecord(java.util.logging.Level level, int key, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
          Gets a localized log record.
 java.lang.String getMenuLabel(int key)
          Gets a string for the given key and appends "..." to it.
 java.lang.String getString(int key)
          Gets a string for the given key from this resource bundle or one of its parents.
 java.lang.String getString(int key, java.lang.Object arg0)
          Gets a string for the given key and formats it with the specified argument.
 java.lang.String getString(int key, java.lang.Object arg0, java.lang.Object arg1)
          Gets a string for the given key and replaces all occurrences of "{0}", "{1}", with values of , , etc.
 java.lang.String getString(int key, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2)
          Gets a string for the given key and replaces all occurrences of "{0}", "{1}", with values of , , etc.
 java.lang.String getString(int key, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
          Gets a string for the given key and replaces all occurrences of "{0}", "{1}", with values of , , etc.
 java.lang.String getString(int key, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
          Gets a string for the given key and replaces all occurrences of "{0}", "{1}", with values of , , etc.
protected  java.lang.Object handleGetObject(java.lang.String key)
          Gets an object for the given key from this resource bundle.
 void list(java.io.Writer out)
          Lists resources to the specified stream.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.util.ResourceBundle
getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceBundle

protected ResourceBundle()
Constructs a new resource bundle. The resource filename will be inferred from the fully qualified classname of this subclass.

Since:
2.2

ResourceBundle

protected ResourceBundle(java.lang.String filename)
Constructs a new resource bundle.

Parameters:
filename - The resource name containing resources. It may be a filename or an entry in a JAR file.
Method Detail

list

public final void list(java.io.Writer out)
                throws java.io.IOException
Lists resources to the specified stream. If a resource has more than one line, only the first line will be written. This method is used mostly for debugging purposes.

Parameters:
out - The destination stream.
Throws:
java.io.IOException - if an output operation failed.

getKeys

public final java.util.Enumeration getKeys()
Returns an enumeration of the keys.


handleGetObject

protected final java.lang.Object handleGetObject(java.lang.String key)
Gets an object for the given key from this resource bundle. Returns null if this resource bundle does not contain an object for the given key.

Parameters:
key - the key for the desired object
Returns:
the object for the given key, or null
Throws:
java.lang.NullPointerException - if is

getMenuLabel

public final java.lang.String getMenuLabel(int key)
                                    throws java.util.MissingResourceException
Gets a string for the given key and appends "..." to it. This method is typically used for creating menu items.

Parameters:
key - The key for the desired string.
Returns:
The string for the given key.
Throws:
java.util.MissingResourceException - If no object for the given key can be found.

getLabel

public final java.lang.String getLabel(int key)
                                throws java.util.MissingResourceException
Gets a string for the given key and appends ": " to it. This method is typically used for creating labels.

Parameters:
key - The key for the desired string.
Returns:
The string for the given key.
Throws:
java.util.MissingResourceException - If no object for the given key can be found.

getString

public final java.lang.String getString(int key)
                                 throws java.util.MissingResourceException
Gets a string for the given key from this resource bundle or one of its parents.

Parameters:
key - The key for the desired string.
Returns:
The string for the given key.
Throws:
java.util.MissingResourceException - If no object for the given key can be found.

getString

public final java.lang.String getString(int key,
                                        java.lang.Object arg0)
                                 throws java.util.MissingResourceException
Gets a string for the given key and formats it with the specified argument. The message is formatted using MessageFormat. Calling this method is approximately equivalent to calling:
   String pattern = getString(key);
   Format f = new MessageFormat(pattern);
   return f.format(arg0);
 
If is not already an array, it will be placed into an array of length 1. Using MessageFormat, all occurrences of "{0}", "{1}", "{2}" in the resource string will be replaced by , , , etc.

Parameters:
key - The key for the desired string.
arg0 - A single object or an array of objects to be formatted and substituted.
Returns:
The string for the given key.
Throws:
java.util.MissingResourceException - If no object for the given key can be found.
See Also:
ResourceBundle.getString(String), getString(int,Object,Object), getString(int,Object,Object,Object), MessageFormat

getString

public final java.lang.String getString(int key,
                                        java.lang.Object arg0,
                                        java.lang.Object arg1)
                                 throws java.util.MissingResourceException
Gets a string for the given key and replaces all occurrences of "{0}", "{1}", with values of , , etc.

Parameters:
key - The key for the desired string.
arg0 - Value to substitute for "{0}".
arg1 - Value to substitute for "{1}".
Returns:
The formatted string for the given key.
Throws:
java.util.MissingResourceException - If no object for the given key can be found.

getString

public final java.lang.String getString(int key,
                                        java.lang.Object arg0,
                                        java.lang.Object arg1,
                                        java.lang.Object arg2)
                                 throws java.util.MissingResourceException
Gets a string for the given key and replaces all occurrences of "{0}", "{1}", with values of , , etc.

Parameters:
key - The key for the desired string.
arg0 - Value to substitute for "{0}".
arg1 - Value to substitute for "{1}".
arg2 - Value to substitute for "{2}".
Returns:
The formatted string for the given key.
Throws:
java.util.MissingResourceException - If no object for the given key can be found.

getString

public final java.lang.String getString(int key,
                                        java.lang.Object arg0,
                                        java.lang.Object arg1,
                                        java.lang.Object arg2,
                                        java.lang.Object arg3)
                                 throws java.util.MissingResourceException
Gets a string for the given key and replaces all occurrences of "{0}", "{1}", with values of , , etc.

Parameters:
key - The key for the desired string.
arg0 - Value to substitute for "{0}".
arg1 - Value to substitute for "{1}".
arg2 - Value to substitute for "{2}".
arg3 - Value to substitute for "{3}".
Returns:
The formatted string for the given key.
Throws:
java.util.MissingResourceException - If no object for the given key can be found.

getString

public final java.lang.String getString(int key,
                                        java.lang.Object arg0,
                                        java.lang.Object arg1,
                                        java.lang.Object arg2,
                                        java.lang.Object arg3,
                                        java.lang.Object arg4)
                                 throws java.util.MissingResourceException
Gets a string for the given key and replaces all occurrences of "{0}", "{1}", with values of , , etc.

Parameters:
key - The key for the desired string.
arg0 - Value to substitute for "{0}".
arg1 - Value to substitute for "{1}".
arg2 - Value to substitute for "{2}".
arg3 - Value to substitute for "{3}".
arg4 - Value to substitute for "{4}".
Returns:
The formatted string for the given key.
Throws:
java.util.MissingResourceException - If no object for the given key can be found.

getLogRecord

public java.util.logging.LogRecord getLogRecord(java.util.logging.Level level,
                                                int key)
Gets a localized log record.

Parameters:
level - The log record level.
key - The resource key.
Returns:
The log record.

getLogRecord

public java.util.logging.LogRecord getLogRecord(java.util.logging.Level level,
                                                int key,
                                                java.lang.Object arg0)
Gets a localized log record.

Parameters:
level - The log record level.
key - The resource key.
arg0 - The parameter for the log message, or .
Returns:
The log record.

getLogRecord

public java.util.logging.LogRecord getLogRecord(java.util.logging.Level level,
                                                int key,
                                                java.lang.Object arg0,
                                                java.lang.Object arg1)
Gets a localized log record.

Parameters:
level - The log record level.
key - The resource key.
arg0 - The first parameter.
arg1 - The second parameter.
Returns:
The log record.

getLogRecord

public java.util.logging.LogRecord getLogRecord(java.util.logging.Level level,
                                                int key,
                                                java.lang.Object arg0,
                                                java.lang.Object arg1,
                                                java.lang.Object arg2)
Gets a localized log record.

Parameters:
level - The log record level.
key - The resource key.
arg0 - The first parameter.
arg1 - The second parameter.
arg2 - The third parameter.
Returns:
The log record.

getLogRecord

public java.util.logging.LogRecord getLogRecord(java.util.logging.Level level,
                                                int key,
                                                java.lang.Object arg0,
                                                java.lang.Object arg1,
                                                java.lang.Object arg2,
                                                java.lang.Object arg3)
Gets a localized log record.

Parameters:
level - The log record level.
key - The resource key.
arg0 - The first parameter.
arg1 - The second parameter.
arg2 - The third parameter.
arg3 - The fourth parameter.
Returns:
The log record.

toString

public java.lang.String toString()
Returns a string representation of this object. This method is for debugging purposes only.



Copyright © GeoTools. All Rights Reserved.