|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.i18n.client.Dictionary
public final class Dictionary
Provides dynamic string lookup of key/value string pairs defined in a
module's host HTML page. Each unique instance of Dictionary
is
bound to a named JavaScript object that resides in the global namespace of
the host page's window object. The bound JavaScript object is used directly
as an associative array.
For example, suppose you define the following JavaScript object in your host page:
You can then use avar CurrentTheme = { highlightColor: "#FFFFFF", shadowColor: "#808080", errorColor: "#FF0000", errorIconSrc: "stopsign.gif" };
Dictionary
to access the key/value pairs
above:
public void useThemeDictionary() { Dictionary theme = Dictionary.getDictionary("CurrentTheme"); String highlightColor = theme.get("highlightColor"); String shadowColor = theme.get("shadowColor"); applyShadowStyle(highlightColor, shadowColor); String errorColor = theme.get("errorColor"); String errorIconSrc = theme.get("errorIconSrc"); Image errorImg = new Image(errorIconSrc); showError(errorColor, errorImg); }
Unlike the family of interfaces that extend
Localizable
which support static
internationalization, the Dictionary
class is fully dynamic.
As a result, a variety of error conditions (particularly those involving key
mismatches) cannot be caught until runtime. Similarly, the GWT compiler is
unable discard unused dictionary values since the structure cannot be
statically analyzed.
locale
client property. Thus,
Dictionary
is the most flexible of the internationalization
types and may provide the simplest form of integration with existing
localization systems which were not specifically designed to use GWT's
locale
client property.
See Localizable
for background on the
locale
client property.
com.google.gwt.i18n.I18N
.
<!-- --> <!-- Copyright 2007 Google Inc. --> <!-- Licensed under the Apache License, Version 2.0 (the "License"); you --> <!-- may not use this file except in compliance with the License. You may --> <!-- may obtain a copy of the License at --> <!-- --> <!-- http://www.apache.org/licenses/LICENSE-2.0 --> <!-- --> <!-- Unless required by applicable law or agreed to in writing, software --> <!-- distributed under the License is distributed on an "AS IS" BASIS, --> <!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or --> <!-- implied. License for the specific language governing permissions and --> <!-- limitations under the License. --> <module> <!-- other inherited modules, such as com.google.gwt.user.User --> <inherits name="com.google.gwt.i18n.I18N"/> <!-- additional module settings --> </module>
Method Summary | |
---|---|
java.lang.String |
get(java.lang.String key)
Get the value associated with the given Dictionary key. |
static Dictionary |
getDictionary(java.lang.String name)
Returns the Dictionary object associated with the given
name. |
java.util.Set |
keySet()
The set of keys associated with this dictionary. |
java.lang.String |
toString()
|
java.util.Collection |
values()
Collection of values associated with this dictionary. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static Dictionary getDictionary(java.lang.String name)
Dictionary
object associated with the given
name.
name
-
java.util.MissingResourceException
public java.lang.String get(java.lang.String key)
key
- to lookup
java.util.MissingResourceException
- if the value is not foundpublic java.util.Set keySet()
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Collection values()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |