|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.ResourceBundle
org.deegree_impl.model.resources.ResourceBundle
{link java.util.ResourceBundle} implementation using integers instead of strings for
resource keys. Because it doesn't use strings, this implementation avoid adding all
those string constants to .class
files and runtime images. Developpers
still have meaningful labels in their code (e.g. DIMENSION_MISMATCH
)
through a set of constants defined in interfaces. This approach furthermore give the
benefict 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
.
Nested Class Summary |
Nested classes inherited from class java.util.ResourceBundle |
|
Field Summary | |
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
Maximal string length for text inserted into an other text. |
protected java.lang.String[] |
values
The array of resources. |
Fields inherited from class java.util.ResourceBundle |
parent |
Constructor Summary | |
protected |
ResourceBundle(java.lang.String filename)
Construct a new resource bundle. |
Method Summary | |
private void |
ensureLoaded(java.lang.String key)
Ensure 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 append ": " to it. |
protected java.lang.String |
getLoggerName()
Returns the name of the logger to use. |
java.lang.String |
getMenuLabel(int keyID)
Gets a string for the given key and append "..." to it. |
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 format 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 are replace all occurence 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 are replace all occurence 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 are replace all occurence 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 are replace all occurence 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)
List resources to the specified stream. |
private void |
list(java.io.Writer out,
int lower,
int upper)
List resources to the specified stream. |
private static java.lang.String |
summarize(java.lang.String text,
int maxLength)
Make sure that the text string is no 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 |
private static final int MAX_STRING_LENGTH
summarize(java.lang.String, int)
. 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.
private final java.lang.String filename
protected java.lang.String[] values
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
case especially for ancestor classes of Resources_fr_CA
,
Resources_en
, Resources_de
, etc., which will
be used only if a key has not been found in the subclasse.
private transient java.text.MessageFormat format
private transient int lastKey
MessageFormat.applyPattern(java.lang.String)
method.
Constructor Detail |
protected ResourceBundle(java.lang.String filename)
filename
- The resource name containing resources. It is
usually a filename, but may also be an entry in a JAR file.Method Detail |
protected java.lang.String getLoggerName()
public final void list(java.io.Writer out) throws java.io.IOException
out
- The destination stream.
java.io.IOException
- if an output operation failed.private void list(java.io.Writer out, int lower, int upper) throws java.io.IOException
out
- The destination stream.lower
- The beginning index (inclusive).upper
- The ending index (exclusive).
java.io.IOException
- if an output operation failed.private void ensureLoaded(java.lang.String key) throws java.util.MissingResourceException
key
- Key for the requested resource, or null
if all resources are requested. This key is used mostly
for constructing messages.
java.util.MissingResourceException
- if this method failed to load resources.public final java.util.Enumeration getKeys()
protected final java.lang.Object handleGetObject(java.lang.String key)
key
- the key for the desired object
java.lang.NullPointerException
- if key
is null
private static java.lang.String summarize(java.lang.String text, int maxLength)
text
string is no longer than maxLength
characters. If text
is not longer, it is returned unchanged (except for
trailing blancks, which are removed). If text
is longer, it will be cut
somewhere in the middle. This method try 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."
text
- The sentence to summarize if it is too long.maxLength
- The maximal length allowed for text
.
If text
is longer, it will summarized.
text
.private static java.lang.Object[] toArray(java.lang.Object arguments)
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 wrapped in an array of length 1. In all case, all array's
elements will be checked for String
objects. Any strings of length greater than
MAX_STRING_LENGTH
will be reduced using the summarize(java.lang.String, int)
method.
arguments
- The object to check.
arguments
as an array.public final java.lang.String getMenuLabel(int keyID) throws java.util.MissingResourceException
keyID
- The key for the desired string.
java.util.MissingResourceException
- If no object for the given key can be found.public final java.lang.String getLabel(int keyID) throws java.util.MissingResourceException
keyID
- The key for the desired string.
java.util.MissingResourceException
- If no object for the given key can be found.public final java.lang.String getString(int keyID) throws java.util.MissingResourceException
keyID
- The key for the desired string.
java.util.MissingResourceException
- If no object for the given key can be found.public final java.lang.String getString(int keyID, java.lang.Object arg0) throws java.util.MissingResourceException
MessageFormat
. Calling his method is
approximatively equivalent to calling:
IfString pattern = getString(key); Format f = new MessageFormat(pattern); return f.format(arg0);
arg0
is not already an array, it will be wrapped into an array
of length 1. Using MessageFormat
, all occurence of "{0}", "{1}", "{2}"
in the resource string will be replaced by arg0[0]
, arg0[1]
,
arg0[2]
, etc.
keyID
- The key for the desired string.arg0
- A single object or an array of objects to be formatted and substituted.
java.util.MissingResourceException
- If no object for the given key can be found.MessageFormat
public final java.lang.String getString(int keyID, java.lang.Object arg0, java.lang.Object arg1) throws java.util.MissingResourceException
arg0
, arg1
, etc.
keyID
- The key for the desired string.arg0
- Value to substitute to "{0}".arg1
- Value to substitute to "{1}".
java.util.MissingResourceException
- If no object for the given key can be found.public final java.lang.String getString(int keyID, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2) throws java.util.MissingResourceException
arg0
, arg1
, etc.
keyID
- The key for the desired string.arg0
- Value to substitute to "{0}".arg1
- Value to substitute to "{1}".arg2
- Value to substitute to "{2}".
java.util.MissingResourceException
- If no object for the given key can be found.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
arg0
, arg1
, etc.
keyID
- The key for the desired string.arg0
- Value to substitute to "{0}".arg1
- Value to substitute to "{1}".arg2
- Value to substitute to "{2}".arg3
- Value to substitute to "{3}".
java.util.MissingResourceException
- If no object for the given key can be found.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
arg0
, arg1
, etc.
keyID
- The key for the desired string.arg0
- Value to substitute to "{0}".arg1
- Value to substitute to "{1}".arg2
- Value to substitute to "{2}".arg3
- Value to substitute to "{3}".arg4
- Value to substitute to "{4}".
java.util.MissingResourceException
- If no object for the given key can be found.public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |