Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.geotools.resources
Class ResourceBundle  view ResourceBundle download ResourceBundle.java

java.lang.Object
  extended byjava.util.ResourceBundle
      extended byorg.geotools.resources.ResourceBundle

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 .class files and runtime images. Developers still have meaningful labels in their code (e.g. DIMENSION_MISMATCH) 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 java.text.MessageFormat.

Version:
$Id: ResourceBundle.java,v 1.5 2003/02/09 23:38:11 lbruand Exp $

Nested Class Summary
 
Nested classes inherited from class java.util.ResourceBundle
 
Field Summary
static java.lang.String CVSID
           
private  java.lang.String filename
          The resource name of the binary file containing resources.
private  java.text.MessageFormat format
          The object to use for formatting messages.
private  int lastKey
          The key of the last resource requested.
private static int MAX_STRING_LENGTH
          Maximum string length for text inserted into another text.
private  java.lang.String[] values
          The array of resources.
 
Fields inherited from class java.util.ResourceBundle
parent
 
Constructor Summary
protected ResourceBundle(java.lang.String filename)
          Constructs a new resource bundle.
 
Method Summary
private  void ensureLoaded(java.lang.String key)
          Ensures that resource values are loaded.
 java.util.Enumeration getKeys()
          Returns an enumeration of the keys.
 java.lang.String getLabel(int keyID)
          Gets a string for the given key and appends ": " to it.
 java.util.logging.LogRecord getLogRecord(java.util.logging.Level level, int key)
          Get a localized log record.
 java.util.logging.LogRecord getLogRecord(java.util.logging.Level level, int key, java.lang.Object arg0)
          Get a localized log record.
 java.util.logging.LogRecord getLogRecord(java.util.logging.Level level, int key, java.lang.Object arg0, java.lang.Object arg1)
          Get 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)
          Get a localized log record.
 java.lang.String getMenuLabel(int keyID)
          Gets a string for the given key and appends "..." to it.
private  java.lang.String getPackageName()
          Returns the name of the package.
 java.lang.String getString(int keyID)
          Gets a string for the given key from this resource bundle or one of its parents.
 java.lang.String getString(int keyID, java.lang.Object arg0)
          Gets a string for the given key and formats it with the specified argument.
 java.lang.String getString(int keyID, 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 arg0, arg1, etc.
 java.lang.String getString(int keyID, 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 arg0, arg1, etc.
 java.lang.String getString(int keyID, 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 arg0, arg1, etc.
 java.lang.String getString(int keyID, 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 arg0, arg1, 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.
private  void list(java.io.Writer out, int lower, int upper)
          Lists resources to the specified stream.
private static java.lang.String summarize(java.lang.String text, int maxLength)
          Make sure that the text string is not longer than maxLength characters.
private static java.lang.Object[] toArray(java.lang.Object arguments)
          Returns arguments as an array.
 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
 

Field Detail

CVSID

public static final java.lang.String CVSID
See Also:
Constant Field Values

MAX_STRING_LENGTH

private static final int MAX_STRING_LENGTH
Maximum string length for text inserted into another text. This parameter is used by summarize(java.lang.String, int) 55 . Resource strings are never cut to this length. However, text replacing "{0}" in a string like "Parameter name is {0}." will be cut to this length.

See Also:
Constant Field Values

filename

private final java.lang.String filename
The resource name of the binary file containing resources. It is usually a file name, but may also be the name of an entry in a JAR file.


values

private java.lang.String[] values
The array of resources. Keys are an array index. For example, the value for key "14" is values[14]. This array will be loaded only when first needed. We should not load it at construction time, because some ResourceBundle objects will never ask for values. This is particularly the case for ancestor classes of Resources_fr_CA, Resources_en, Resources_de, etc., which will only be used if a key has not been found in the subclass.


format

private transient java.text.MessageFormat format
The object to use for formatting messages. This object will be constructed only when first needed.


lastKey

private transient int lastKey
The key of the last resource requested. If the same resource is requested multiple times, knowing its key allows us to avoid invoking the costly MessageFormat.applyPattern(java.lang.String)>MessageFormat.applyPattern(java.lang.String) 55 method.

Constructor Detail

ResourceBundle

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

Method Detail

getPackageName

private java.lang.String getPackageName()
Returns the name of the package.


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.


list

private void list(java.io.Writer out,
                  int lower,
                  int upper)
           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.


ensureLoaded

private void ensureLoaded(java.lang.String key)
                   throws java.util.MissingResourceException
Ensures that resource values are loaded. If they are not, load them immediately.


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.


summarize

private static java.lang.String summarize(java.lang.String text,
                                          int maxLength)
Make sure that the text string is not longer than maxLength characters. If text is not longer, it is returned unchanged (except for trailing blanks, which are removed). If text is longer, it will be cut somewhere in the middle. This method tries to cut between two words and replace the missing words with "(...)". For example, the following string:
"This sentence given as an example is way too long to be included in a message."
May be "summarized" by something like this:
"This sentence given (...) included in a message."


toArray

private static java.lang.Object[] toArray(java.lang.Object arguments)
Returns arguments as an array. If arguments is already an array, this array or a copy of this array will be returned. If arguments is not an array, it will be placed in an array of length 1. In any case, all the array's elements will be checked for java.lang.String objects. Any strings of length greater than MAX_STRING_LENGTH 55 will be reduced using the summarize(java.lang.String, int) 55 method.


getMenuLabel

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


getLabel

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


getString

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


getString

public final java.lang.String getString(int keyID,
                                        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 java.text.MessageFormat. Calling this method is approximately equivalent to calling:
     String pattern = getString(key);
     Format f = new MessageFormat(pattern);
     return f.format(arg0);
 
If arg0 is not already an array, it will be placed into an array of length 1. Using java.text.MessageFormat, all occurrences of "{0}", "{1}", "{2}" in the resource string will be replaced by arg0[0], arg0[1], arg0[2], etc.


getString

public final java.lang.String getString(int keyID,
                                        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 arg0, arg1, etc.


getString

public final java.lang.String getString(int keyID,
                                        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 arg0, arg1, etc.


getString

public final java.lang.String getString(int keyID,
                                        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 arg0, arg1, etc.


getString

public final java.lang.String getString(int keyID,
                                        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 arg0, arg1, etc.


getLogRecord

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


getLogRecord

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


getLogRecord

public java.util.logging.LogRecord getLogRecord(java.util.logging.Level level,
                                                int key,
                                                java.lang.Object arg0,
                                                java.lang.Object arg1)
Get a localized 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)
Get a localized log record.


toString

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