org.zkoss.util.resource.impl
Class LabelLoaderImpl

java.lang.Object
  extended by org.zkoss.util.resource.impl.LabelLoaderImpl
All Implemented Interfaces:
LabelLoader

public class LabelLoaderImpl
extends java.lang.Object
implements LabelLoader

The label loader (implementation only). Used to implement 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
LabelLoaderImpl()
           
 
Method Summary
 java.lang.String getLabel(java.util.Locale locale, java.lang.String key)
          Returns the label of the specified key for the specified locale, or null if not found.
 java.lang.String getLabel(java.lang.String key)
          Returns the label of the specified key for the current locale, or null if not found.
 java.util.Map<java.lang.String,java.lang.Object> getSegmentedLabels()
          Returns a map of segmented labels for the current locale (never null).
 java.util.Map<java.lang.String,java.lang.Object> getSegmentedLabels(java.util.Locale locale)
          Returns a map of segmented labels for the specified locale (never null).
 void register(LabelLocator locator)
          Registers a locator which is used to load the Locale-dependent labels from other resource, such as servlet contexts.
 void register(LabelLocator2 locator)
          Registers a locator which is used to load the Locale-dependent labels from other resource, such as database.
 void reset()
          Resets all cached labels and next call to getLabel(java.lang.String) will cause re-loading the Locale-dependent labels.
 VariableResolver setVariableResolver(VariableResolver resolv)
          Sets the variable resolver, which is used if an EL expression is specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelLoaderImpl

public LabelLoaderImpl()
Method Detail

getLabel

public java.lang.String getLabel(java.lang.String key)
Returns the label of the specified key for the current locale, or null if not found.

Specified by:
getLabel in interface LabelLoader
See Also:
getSegmentedLabels()

getLabel

public java.lang.String getLabel(java.util.Locale locale,
                                 java.lang.String key)
Returns the label of the specified key for the specified locale, or null if not found.

Specified by:
getLabel in interface LabelLoader
Since:
5.0.7

getSegmentedLabels

public java.util.Map<java.lang.String,java.lang.Object> getSegmentedLabels()
Returns a map of segmented labels for the current locale (never null). Unlike getLabel(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=3

This 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:
getSegmentedLabels in interface LabelLoader
Since:
5.0.7

getSegmentedLabels

public java.util.Map<java.lang.String,java.lang.Object> getSegmentedLabels(java.util.Locale locale)
Returns a map of segmented labels for the specified locale (never null). Refer to getSegmentedLabels() for details.

Specified by:
getSegmentedLabels in interface LabelLoader
Since:
5.0.7

setVariableResolver

public VariableResolver setVariableResolver(VariableResolver resolv)
Sets the variable resolver, which is used if an EL expression is specified.

Specified by:
setVariableResolver in interface LabelLoader
Since:
3.0.0

register

public void register(LabelLocator locator)
Registers a locator which is used to load the Locale-dependent labels from other resource, such as servlet contexts.

Specified by:
register in interface LabelLoader

register

public void register(LabelLocator2 locator)
Registers a locator which is used to load the Locale-dependent labels from other resource, such as database.

Specified by:
register in interface LabelLoader
Since:
5.0.5

reset

public void reset()
Resets all cached labels and next call to getLabel(java.lang.String) will cause re-loading the Locale-dependent labels.

Specified by:
reset in interface LabelLoader


Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo