Class LabelLoaderImpl
- All Implemented Interfaces:
LabelLoader
Labels.
Notice that the encoding of the Locale dependent file (*.properties) is assumed to be UTF-8. If it is not the case, please refer to ZK Configuration Reference for more information.
Specify the library property of org.zkoss.util.resource.LabelLoader.class
in zk.xml to provide a customized label loader for debugging purpose. (since 7.0.1)
- Author:
- tomyeh
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the label of the specified key for the current locale, or null if not found.Returns the label of the specified key for the specified locale, or null if not found.Returns a map of segmented labels for the current locale (never null).getSegmentedLabels(Locale locale) Returns a map of segmented labels for the specified locale (never null).protected ObjecthandleMissingLabel(Object key) Handles the missing label.voidregister(LabelLocator locator) Registers a locator which is used to load the Locale-dependent labels from other resource, such as servlet contexts.voidregister(LabelLocator2 locator) Registers a locator which is used to load the Locale-dependent labels from other resource, such as database.voidreset()Resets all cached labels and next call togetLabel(java.lang.String)will cause re-loading the Locale-dependent labels.setVariableResolver(VariableResolver resolv) Sets the variable resolver, which is used if an EL expression is specified.
-
Constructor Details
-
LabelLoaderImpl
public LabelLoaderImpl()
-
-
Method Details
-
handleMissingLabel
Handles the missing label. The default action is logging a message.- Parameters:
key- the specified key- Returns:
- the fallback value, or null if no fallback value available
- Since:
- 8.6.0
-
getLabel
Returns the label of the specified key for the current locale, or null if not found.- Specified by:
getLabelin interfaceLabelLoader- See Also:
-
getLabel
Returns the label of the specified key for the specified locale, or null if not found.- Specified by:
getLabelin interfaceLabelLoader- Since:
- 5.0.7
-
getSegmentedLabels
Returns a map of segmented labels for the current locale (never null). UnlikegetLabel(java.lang.String), if a key of the label contains dot, it will be split into multiple keys and then grouped into map. It is so-called segmented.For example, the following property file will parsed into a couple of maps, and
getSegmentedLabels()returns a map containing a single entry. The entry's key is"a"and the value is another map with two entries"b"and"c". And, the value for"b"is another two-entries map (containing"c"and"d").a.b.c=1 a.b.d=2 a.e=3This method is designed to make labels easier to be accessed in EL expressions.
On the other hand,
getLabel(java.lang.String)does not split them, and you could access them by, say,getLabel("a.b.d").- Specified by:
getSegmentedLabelsin interfaceLabelLoader- Since:
- 5.0.7
-
getSegmentedLabels
Returns a map of segmented labels for the specified locale (never null). Refer togetSegmentedLabels()for details.- Specified by:
getSegmentedLabelsin interfaceLabelLoader- Since:
- 5.0.7
-
setVariableResolver
Sets the variable resolver, which is used if an EL expression is specified.- Specified by:
setVariableResolverin interfaceLabelLoader- Since:
- 3.0.0
-
register
Registers a locator which is used to load the Locale-dependent labels from other resource, such as servlet contexts.- Specified by:
registerin interfaceLabelLoader
-
register
Registers a locator which is used to load the Locale-dependent labels from other resource, such as database.- Specified by:
registerin interfaceLabelLoader- Since:
- 5.0.5
-
reset
public void reset()Resets all cached labels and next call togetLabel(java.lang.String)will cause re-loading the Locale-dependent labels.- Specified by:
resetin interfaceLabelLoader
-