com.github.dandelion.datatables.core.configuration
Class StandardConfigurationLoader

java.lang.Object
  extended by com.github.dandelion.datatables.core.configuration.StandardConfigurationLoader
All Implemented Interfaces:
ConfigurationLoader

public class StandardConfigurationLoader
extends Object
implements ConfigurationLoader

Default implementation of the ConfigurationLoader.

Note that a custom ConfigurationLoader can be used thanks to the DatatablesConfigurator.

Since:
0.9.0
Author:
Thibault Duchateau
See Also:
DatatablesConfigurator

Field Summary
protected static Properties defaultProperties
           
 
Fields inherited from interface com.github.dandelion.datatables.core.configuration.ConfigurationLoader
DEFAULT_GROUP_NAME, DT_DEFAULT_PROPERTIES, DT_USER_PROPERTIES, DT_USER_PROPERTIES_LOCATION, I18N_LOCALE_RESOLVER, I18N_MESSAGE_RESOLVER, STANDALONE_BUNDLES_TO_EXCLUDE
 
Constructor Summary
StandardConfigurationLoader()
           
 
Method Summary
 Properties loadDefaultConfiguration()
           Load the default configuration from the internal properties file and both: stores the properties inside a class field returns the properties if they need to be used outside of the class
 Properties loadUserConfiguration(Locale locale)
           Load the user configuration which can be localized thanks to the given locale.
 void resolveConfigurations(Map<String,Map<ConfigToken<?>,Object>> map, Locale locale, javax.servlet.http.HttpServletRequest request)
           Resolve configuration groups for the given locale.
 Set<String> resolveGroups(Locale locale)
           Return a set containing all configuration groups.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultProperties

protected static Properties defaultProperties
Constructor Detail

StandardConfigurationLoader

public StandardConfigurationLoader()
Method Detail

loadDefaultConfiguration

public Properties loadDefaultConfiguration()

Load the default configuration from the internal properties file and both:

Specified by:
loadDefaultConfiguration in interface ConfigurationLoader
Returns:
the default properties

loadUserConfiguration

public Properties loadUserConfiguration(Locale locale)

Load the user configuration which can be localized thanks to the given locale.

Once the bundle loaded, it is converted into Properties.

Specified by:
loadUserConfiguration in interface ConfigurationLoader
Parameters:
locale - The current locale used to load the right properties file.
Returns:
the ResourceBundle containing the user configuration.

resolveGroups

public Set<String> resolveGroups(Locale locale)

Return a set containing all configuration groups.

Note that the i18n.locale.resolver is a special property that must not be taken into account because it is group-independent.

Specified by:
resolveGroups in interface ConfigurationLoader
Parameters:
locale - The current locale.
Returns:
the resolved groups.

resolveConfigurations

public void resolveConfigurations(Map<String,Map<ConfigToken<?>,Object>> map,
                                  Locale locale,
                                  javax.servlet.http.HttpServletRequest request)

Resolve configuration groups for the given locale.

The default properties file (datatables-default.properties) already contains the 'global' group: this is the group of configuration that is used for all tables in the application.

Inside the user properties files (datatables_XX.properties), users can:

For example, if the user properties file contains:
group1.i18n.msg.search=My label
group1.i18n.msg.processing=My other label

the ConfigurationLoader must create a group called 'group1' containing all properties present in the 'global' group but where i18n.msg.search and i18n.msg.processing are overriden with the user's ones.

Note that:

Specified by:
resolveConfigurations in interface ConfigurationLoader
Parameters:
map - The map to update after the resolution of the configuration groups.
locale - The current locale used to get the right properties file from the resource bundle.
request - The request sent by the browser.


Copyright © 2013–2014 Dandelion Project. All rights reserved.