java.lang.Object | +--com.ibm.commerce.usermanagement.commands.PropertyResourceBundleReader
/**
The PropertyResourceBundleReader is used by ResourceBundleDataBean and Member Subsystem command to find property file and reoganize the information of property files to diferent formats. To find a property file, three parameters are needed:
After these parameters are set and data bean is actived the informaiton in property file can be get using the follwong methods:
public PropertyResourceBundle
getPropertyResourceBundle()
public SortedMap getPropertySortedMap()
This method is used to read from the property file with the following format
and return results as a SortedMap.
For example:
If you have a property file named UserRegistration_en_US.properties, which
contains the following content (The number can be anything as long as they
following the ascendent order): . . . 100.Name=children 100.Label=Number
Of Children 100.Displayed=yes 100.Required=no 100.Size=5 105.Name=age
105.Label=Age 105.Displayed=yes 105.Required=no 105.Options=0;Not
Provided|1;10-19 years|2;20-29 years|3;30-39 years|4;40-49 years|5;50-59
years|6;60 years or older 110.Name=gender 110.Label=Gender 110.Displayed=yes
110.Required=no 110.Options=N;Not Provided|M;Male|F;Female
Note:
| -- Default Delimiter (You can use setDelimiter(String) method to set a
different Delimiter)
; -- Default Separator (You can use setSeparator(String) method to set a
different Separator)
public Hashtable getPropertyHashtable()
This method is used to read from the property file with the following format
and return results as a Hashtable. The Hashtable contains many field Hastables
(each field corresponding to one small hashtable).
For example:
If you have a property file named UserRegistration_en_US.properties, which
contains the following content: . . . children.Label=Number Of Children
children.Displayed=yes children.Required=no age.Label=Age age.Displayed=yes
age.Required=no age.Options=0;Not Available|1;10-19 years|2;20-29 years|3;30-39
years|4;40-49 years|5;50-59 years|6;60 years or older age.Operators=>;Older
than|<;Yonger than|!=;Not equal to gender.Label=Gender gender.Displayed=yes
gender.Required=no gender.Options=Male|Female
. . .
Field Summary | |
---|---|
static java.lang.String |
CLASSNAME The full qualified class name. |
static java.lang.String |
COPYRIGHT IBM copyright. |
static java.util.Locale |
DEFALUT_LOCALE The default locale used to find property file. |
static java.lang.String |
DEFAULT_DELIMITER The deault delimiter used to separate different options. |
static java.lang.String |
DEFAULT_PATH_SEPARATOR The default separator used to separate resource property file name and its path. |
static java.lang.String |
DEFAULT_SEPARATOR The default separator used to separate internal value and display value in a option. |
Constructor Summary | |
---|---|
PropertyResourceBundleReader() |
Method Summary | |
---|---|
CommandContext |
getCommandContext() Gets the command context. |
java.lang.String |
getDelimiter() Gets the delimiter for the property file. |
java.lang.String |
getFoundPropertyFilePath() Gets the found property file path. |
java.util.Locale |
getLocale() Gets the Locale. |
java.lang.String |
getPathSeparator() Gets the path separator. |
java.lang.String |
getPropertyFileName() Gets the name of property file |
java.util.Hashtable |
getPropertyHashtable() Gets the reading result of the property file as a Hashtable . |
java.util.PropertyResourceBundle |
getPropertyResourceBundle() Gets the reading result of the property file as a PropertyResourceBundle object. |
java.util.SortedMap |
getPropertySortedMap() Gets the reading result of the property file as a SortedMap . |
java.lang.String |
getSeparator() Gets the separator for the property file. |
java.lang.String |
getStoreDirectory() Gets the name of the store directory, which is used for finding property files belong to this store. |
java.util.PropertyResourceBundle |
getTextPropertyResourceBundle() Gets the reading result of the text property file as a PropertyResourceBundle object. |
void |
read() Gets the SortedMap from the properties file using the specified property file name, store directory, command context, locale, delimiter and separater. |
static java.util.Hashtable |
readProperties(java.lang.String astrPropertyFileName) Gets the Hashtable from the properties file using the specified property file name. |
static java.util.Hashtable |
readProperties(java.lang.String astrPropertyFileName,
java.util.Locale alcLocale) Gets the Hashtable from the properties file using the specified property file name and locale. |
static java.util.Hashtable |
readProperties(java.lang.String astrPropertyFileName,
java.util.Locale alcLocale, java.lang.String astrDelimiter,
java.lang.String astrSeparator) Gets the Hashtable from the properties file using the specified property file name, locale, delimiter and separater. |
static java.util.SortedMap |
readSortedProperties(java.lang.String astrPropertyFileName) Gets the SortedMap from the properties file using the specified property file name. |
static java.util.SortedMap |
readSortedProperties(java.lang.String astrPropertyFileName,
java.util.Locale alcLocale) Gets the SortedMap from the properties file using the specified property file name and locale. |
static java.util.SortedMap |
readSortedProperties(java.lang.String astrPropertyFileName,
java.util.Locale alcLocale, java.lang.String astrDelimiter,
java.lang.String astrSeparator) Gets the SortedMap from the properties file using the specified property file name, locale, delimiter and separater. |
void |
setCommandContext(
CommandContext acommandContext) Sets the command context. |
void |
setDelimiter(java.lang.String astrDelimiter) Sets the delimiter for the property file. |
void |
setLocale(java.util.Locale alcLocale) Set the Locale. |
void |
setPathSeparator(java.lang.String astrPathSeparator) Sets the path separator. |
void |
setPropertyFileName(java.lang.String astrPropertyFileName) Sets the name of property file. |
void |
setSeparator(java.lang.String astrSeparator) Sets the separator for the property file. |
void |
setStoreDirectory(java.lang.String astrStoreDirectory) Sets the name of store directory, which is used as the path to the find the property file. |
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 COPYRIGHT
public static final java.lang.String CLASSNAME
public static final java.lang.String DEFAULT_PATH_SEPARATOR
public static final java.lang.String DEFAULT_DELIMITER
age.Options=0;Not Available|1;10-19
years|2;20-29 years
"|" is the delimitor. If no delimiter is
set, this default one will be used.
public static final java.lang.String DEFAULT_SEPARATOR
age.Options=0;Not Available|1;10-19 years|2;20-29 years
"1;10-19 years" is a option, ";" is the separator. If no
separator is set, this default one will be used.
public static final java.util.Locale DEFALUT_LOCALE
Constructor Detail |
---|
public PropertyResourceBundleReader()
Method Detail |
---|
public void setPropertyFileName(java.lang.String astrPropertyFileName)
astrPropertyFileName
- The name of property
filepublic java.lang.String getPropertyFileName()
public void setStoreDirectory(java.lang.String astrStoreDirectory)
astrStoreDirectory
- The name of store
directorypublic java.lang.String getStoreDirectory()
public void setLocale(java.util.Locale alcLocale)
alcLocale
- The Localepublic java.util.Locale getLocale()
public void setCommandContext(CommandContext acommandContext)
acommandContext
- The command context.public CommandContext getCommandContext()
public void setDelimiter(java.lang.String astrDelimiter)
age.Options=0;Not Available|1;10-19 years|2;20-29
years
"|" is the delimitor. If no Delimiter is set, the
databean will use the default one: "|".
astrDelimiter
- The delimiter for the property
filepublic java.lang.String getDelimiter()
age.Options=0;Not Available|1;10-19 years|2;20-29
years
"|" is the delimitor.
public void setSeparator(java.lang.String astrSeparator)
age.Options=0;Not
Available|1;10-19 years|2;20-29 years
"1;10-19 years" is a
option, ";" is the separator. If no separator is set, the databean
will use the default one: ";".
astrSeparator
- The separator for the property
filepublic java.lang.String getSeparator()
age.Options=0;Not
Available|1;10-19 years|2;20-29 years
"1;10-19 years" is a
option, ";" is the separator. If no separator is set, the databean
will use the default one: ";".
public void setPathSeparator(java.lang.String astrPathSeparator)
"store1/UserRegistration"
"/" is the path
separator.
If path separator is not set, the databean will use the default one:
"/" (working under Windows platform).
astrPathSeparator
- The path separatorpublic java.lang.String getPathSeparator()
"store1/UserRegistration"
"/" is the path
separator.
public void read()
Locale.US
.
SortedMap
contains the parsed inforamtion of the property
file. The structure of the SortedMap
is described in the Java Doc
of this class.public java.lang.String getFoundPropertyFilePath()
public java.util.PropertyResourceBundle getPropertyResourceBundle()
PropertyResourceBundle
object.
public java.util.PropertyResourceBundle getTextPropertyResourceBundle()
PropertyResourceBundle
object. The name of text property file is
the name of the property file plus "Text" suffix. For example, if the
name of the property file is "UserRegistration", then the name of the
text property file is "UserRegistrationText".
public java.util.SortedMap getPropertySortedMap()
SortedMap
.
The key of the SortedMap
is the ordering number of the field. The
value is a Hashtable
contains attribute names and values of the
field.
SortedMap
which contains informaiton of the property
file.public java.util.Hashtable getPropertyHashtable()
Hashtable
.
The key of the Hashtable
is the name of the field. The value is a
Hashtable
contains attribute names and values of the field.
SortedMap
which contains informaiton of the property
file.public static java.util.Hashtable readProperties(java.lang.String astrPropertyFileName)
astrPropertyFileName
- The property file name.public static java.util.Hashtable readProperties(java.lang.String astrPropertyFileName, java.util.Locale alcLocale)
astrPropertyFileName
- The base name of the property
file.alcLocale
- The Locale used to find the property file.public static java.util.Hashtable readProperties(java.lang.String astrPropertyFileName, java.util.Locale alcLocale, java.lang.String astrDelimiter, java.lang.String astrSeparator)
astrPropertyFileName
- The base name of the property
file.alcLocale
- The Locale used to find the property file.astrDelimiter
- The delimiter used to pasrse the property
file.astrSeparator
- The separator used to parse the property
file.public static java.util.SortedMap readSortedProperties(java.lang.String astrPropertyFileName)
astrPropertyFileName
- The base name of the property
file.public static java.util.SortedMap readSortedProperties(java.lang.String astrPropertyFileName, java.util.Locale alcLocale)
astrPropertyFileName
- The base name of the property
file.alcLocale
- The Locale used to find the property file.public static java.util.SortedMap readSortedProperties(java.lang.String astrPropertyFileName, java.util.Locale alcLocale, java.lang.String astrDelimiter, java.lang.String astrSeparator)
astrPropertyFileName
- The base name of the property
file.alcLocale
- The Locale used to find the property file.astrDelimiter
- The delimiter used to pasrse the property
file.astrSeparator
- The separator used to parse the property
file.