|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bbn.openmap.BasicI18n
public class BasicI18n
Basic implementation of internationalization support.
This class backs the I18n interface by I18n.property files that it expects to find in each package.
This class provides a mechanism for creating the I18n.property files that it expects to use in the application. If the 'i18n.create' flag is set in the Debug class, then this class will track what resource bundle property files were searched for, and what values were returned for requested keys. The dumpCreatedResourceBundles() method will cause the resource bundles to be written out, where they can be modified to change the strings displayed in the GUI. If the 'i18n.default' flag is set, then 'I18N.properties' files will be created. If that flag is not set, then the name of the files will be modified for the locale currently set for the application (i.e. I18N_en_US.properties for the US locale). You can add the I18nFileCreateMenuItem to an application to trigger the dumpCreatedResourceBundles() method.
Field Summary | |
---|---|
protected java.util.Hashtable |
createHash
|
static java.lang.String |
DEBUG
Debug string, 'i18n' |
static java.lang.String |
DEBUG_CREATE
Debug string that causes the BasicI18n class to keep track of resource property files and strings it looks for, as well as their defaults. |
static java.lang.String |
DEBUG_CREATE_DEFAULT
If set, created ResourceBundle files will not have the local suffixes added to them. |
static java.lang.String |
ResourceFileNamePrefix
All properties files containing string should be contained in a file called I18N.properties. |
Fields inherited from interface com.bbn.openmap.I18n |
---|
MNEMONIC, TEXT, TITLE, TOOLTIP |
Constructor Summary | |
---|---|
BasicI18n()
Create a BasicI18n object from the default locale. |
|
BasicI18n(java.util.Locale loc)
Create a BasicI18n object with given locale. |
Method Summary | |
---|---|
void |
dumpCreatedResourceBundles()
If called, will bring up a JFileChooser so you can pick a location to dump the resource files that were searched for, with values that were found or the defaults provided in the code. |
void |
dumpCreatedResourceBundles(java.lang.String location)
Will dump the resource bundle property files searched for by this class, along with the contents that were returned or with the defaults provided by the application. |
void |
fill(java.lang.Object requestor)
Fill in all of the fields of the given object that are of known types (see the set(...) methods of this class) with values obtained from the appropriate ResourceBundle. |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
int type,
java.lang.String defaultString)
Get the string associated with the given class/field/type. |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
int type,
java.lang.String defaultString,
java.lang.Object param1)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
int type,
java.lang.String defaultString,
java.lang.Object[] params)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
int type,
java.lang.String defaultString,
java.lang.Object param1,
java.lang.Object param2)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
java.lang.String defaultString)
Get the string associated with the given class/field (Defaults to TEXT for the type). |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
java.lang.String defaultString,
java.lang.Object param1)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
java.lang.String defaultString,
java.lang.Object[] params)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
java.lang.String defaultString,
java.lang.Object param1,
java.lang.Object param2)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
int type,
java.lang.String defaultString)
Get the string associated with the given object/field/type. |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
int type,
java.lang.String defaultString,
java.lang.Object param1)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
int type,
java.lang.String defaultString,
java.lang.Object[] params)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
int type,
java.lang.String defaultString,
java.lang.Object param1,
java.lang.Object param2)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
java.lang.String defaultString)
Get the string associated with the given object/field (Defaults to TEXT for the type). |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
java.lang.String defaultString,
java.lang.Object param1)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
java.lang.String defaultString,
java.lang.Object[] params)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
java.lang.String defaultString,
java.lang.Object param1,
java.lang.Object param2)
Method to get a parameterized String, as if by MessageFormat. |
protected java.util.Hashtable |
getCreateHash()
|
protected java.lang.String |
getInternal(java.lang.Class requestor,
java.lang.String field,
int type)
Obtain a String from the underlying data for the given class/field/type. |
protected int |
getMNEMONIC(java.lang.Object requestor,
java.lang.String field,
int defaultInt,
boolean verbose)
Get text for the given component. |
protected java.lang.String |
getTEXT(java.lang.Object requestor,
java.lang.String field,
java.lang.String defaultString)
Get text for the given component. |
protected java.lang.String |
getTITLE(java.lang.Object requestor,
java.lang.String field,
java.lang.String defaultString)
Get title for the given component. |
void |
set(java.lang.Object requestor,
java.lang.String field)
Set the textual properties on a Swing component that is a member of a given class, from values in the ResourceBundle associated with that class. |
void |
set(java.lang.Object requestor,
java.lang.String field,
javax.swing.JButton comp)
Set the textual properties from values in the appropriate ResourceBundle. |
void |
set(java.lang.Object requestor,
java.lang.String field,
javax.swing.JComponent comp)
Set the textual properties from values in the appropriate ResourceBundle. |
void |
set(java.lang.Object requestor,
java.lang.String field,
javax.swing.JDialog comp)
Set the textual properties from values in the appropriate ResourceBundle. |
void |
set(java.lang.Object requestor,
java.lang.String field,
javax.swing.JFrame comp)
Set the textual properties from values in the appropriate ResourceBundle. |
void |
set(java.lang.Object requestor,
java.lang.String field,
javax.swing.JLabel comp)
Set the textual properties from values in the appropriate ResourceBundle. |
void |
set(java.lang.Object requestor,
java.lang.String field,
javax.swing.JMenu comp)
Set the textual properties from values in the appropriate ResourceBundle. |
void |
set(java.lang.Object requestor,
java.lang.String field,
javax.swing.JMenuItem comp)
Set the textual properties from values in the appropriate ResourceBundle. |
protected void |
setForBundleCreation(java.lang.Class requestor,
java.lang.String field,
int type,
java.lang.String defaultString)
Obtain a String from the underlying data for the given class/field/type. |
protected void |
setTOOLTIP(java.lang.Object requestor,
java.lang.String field,
javax.swing.JComponent comp)
Set a tooltip on the given component if it has one. |
static java.lang.String |
shortClassName(java.lang.Class c)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEBUG
public static final java.lang.String DEBUG_CREATE
public static final java.lang.String DEBUG_CREATE_DEFAULT
public static final java.lang.String ResourceFileNamePrefix
protected transient java.util.Hashtable createHash
Constructor Detail |
---|
public BasicI18n()
public BasicI18n(java.util.Locale loc)
Method Detail |
---|
public java.lang.String get(java.lang.Object requestor, java.lang.String field, java.lang.String defaultString)
I18n
get
in interface I18n
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the String or the Swing object that
uses the String (like a button or a label).defaultString
- what to use if the resource can't be found.public java.lang.String get(java.lang.Object requestor, java.lang.String field, int type, java.lang.String defaultString)
I18n
get
in interface I18n
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the Swing object that uses the String
(like a button or a label).type
- which specific slot in the Swing object the string
pertains to. One of TEXT, TOOLTIP or MNEMONIC.defaultString
- what to use if the resource can't be found.public java.lang.String get(java.lang.Class requestor, java.lang.String field, java.lang.String defaultString)
I18n
get
in interface I18n
requestor
- the class of the object containing the code
requesting the String (typically Foo.class
field
- the field the String belongs to. Typically this will
be the variable name referring to the String or the Swing object that
uses the String (like a button or a label).defaultString
- what to use if the resource can't be found.public java.lang.String get(java.lang.Class requestor, java.lang.String field, int type, java.lang.String defaultString)
I18n
get
in interface I18n
requestor
- the classof the object containing the code
requesting the String (typically Foo.class
field
- the field the String belongs to. Typically this will
be the variable name referring to the Swing object that uses the String
(like a button or a label).type
- which specific slot in the Swing object the string
pertains to. One of TEXT, TOOLTIP or MNEMONIC.defaultString
- what to use if the resource can't be found.protected java.util.Hashtable getCreateHash()
public java.lang.String get(java.lang.Object requestor, java.lang.String field, java.lang.String defaultString, java.lang.Object param1)
I18n
get
in interface I18n
MessageFormat
public java.lang.String get(java.lang.Object requestor, java.lang.String field, int type, java.lang.String defaultString, java.lang.Object param1)
I18n
get
in interface I18n
MessageFormat
public java.lang.String get(java.lang.Class requestor, java.lang.String field, java.lang.String defaultString, java.lang.Object param1)
I18n
get
in interface I18n
MessageFormat
public java.lang.String get(java.lang.Class requestor, java.lang.String field, int type, java.lang.String defaultString, java.lang.Object param1)
I18n
get
in interface I18n
MessageFormat
public java.lang.String get(java.lang.Object requestor, java.lang.String field, java.lang.String defaultString, java.lang.Object param1, java.lang.Object param2)
I18n
get
in interface I18n
MessageFormat
public java.lang.String get(java.lang.Object requestor, java.lang.String field, int type, java.lang.String defaultString, java.lang.Object param1, java.lang.Object param2)
I18n
get
in interface I18n
MessageFormat
public java.lang.String get(java.lang.Class requestor, java.lang.String field, java.lang.String defaultString, java.lang.Object param1, java.lang.Object param2)
I18n
get
in interface I18n
MessageFormat
public java.lang.String get(java.lang.Class requestor, java.lang.String field, int type, java.lang.String defaultString, java.lang.Object param1, java.lang.Object param2)
I18n
get
in interface I18n
MessageFormat
public java.lang.String get(java.lang.Object requestor, java.lang.String field, java.lang.String defaultString, java.lang.Object[] params)
I18n
get
in interface I18n
MessageFormat
public java.lang.String get(java.lang.Object requestor, java.lang.String field, int type, java.lang.String defaultString, java.lang.Object[] params)
I18n
get
in interface I18n
MessageFormat
public java.lang.String get(java.lang.Class requestor, java.lang.String field, java.lang.String defaultString, java.lang.Object[] params)
I18n
get
in interface I18n
MessageFormat
public java.lang.String get(java.lang.Class requestor, java.lang.String field, int type, java.lang.String defaultString, java.lang.Object[] params)
I18n
get
in interface I18n
MessageFormat
public void set(java.lang.Object requestor, java.lang.String field, javax.swing.JLabel comp)
I18n
set
in interface I18n
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the comp
parameter.comp
- the component whose properties are being set.public void set(java.lang.Object requestor, java.lang.String field, javax.swing.JButton comp)
I18n
set
in interface I18n
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the comp
parameter.comp
- the component whose properties are being set.public void set(java.lang.Object requestor, java.lang.String field, javax.swing.JMenu comp)
I18n
set
in interface I18n
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the comp
parameter.comp
- the component whose properties are being set.public void set(java.lang.Object requestor, java.lang.String field, javax.swing.JMenuItem comp)
I18n
set
in interface I18n
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the comp
parameter.comp
- the component whose properties are being set.public void set(java.lang.Object requestor, java.lang.String field, javax.swing.JDialog comp)
I18n
set
in interface I18n
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the comp
parameter.comp
- the component whose properties are being set.public void set(java.lang.Object requestor, java.lang.String field, javax.swing.JFrame comp)
I18n
set
in interface I18n
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the comp
parameter.comp
- the component whose properties are being set.public void set(java.lang.Object requestor, java.lang.String field, javax.swing.JComponent comp)
I18n
Note: This method just looks for a TitledBorder on the component.
set
in interface I18n
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the comp
parameter.comp
- the component whose properties are being set.public void set(java.lang.Object requestor, java.lang.String field)
I18n
The setting of the values of this field will be accomplished by calling the appropriate set(...) method on this class.
set
in interface I18n
requestor
- object containing the code requesting the
Component setup (typically this
field
- the variable name of the component being setup.public void fill(java.lang.Object requestor)
I18n
The setting of the values of this field will be accomplished by calling the appropriate set(...) method on this class.
fill
in interface I18n
protected void setTOOLTIP(java.lang.Object requestor, java.lang.String field, javax.swing.JComponent comp)
protected java.lang.String getTEXT(java.lang.Object requestor, java.lang.String field, java.lang.String defaultString)
protected java.lang.String getTITLE(java.lang.Object requestor, java.lang.String field, java.lang.String defaultString)
protected int getMNEMONIC(java.lang.Object requestor, java.lang.String field, int defaultInt, boolean verbose)
protected java.lang.String getInternal(java.lang.Class requestor, java.lang.String field, int type)
protected void setForBundleCreation(java.lang.Class requestor, java.lang.String field, int type, java.lang.String defaultString)
public void dumpCreatedResourceBundles()
public void dumpCreatedResourceBundles(java.lang.String location)
location
- directory location to use as the root for resource bundle
file hierarchy.public static java.lang.String shortClassName(java.lang.Class c)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |