com.github.dandelion.datatables.core.processor
Class AbstractConfigurationProcessor

java.lang.Object
  extended by com.github.dandelion.datatables.core.processor.AbstractConfigurationProcessor
All Implemented Interfaces:
ConfigurationProcessor
Direct Known Subclasses:
AjaxPipeliningProcessor, AjaxReloadFunctionProcessor, AjaxReloadProcessor, AjaxServerSideProcessor, AjaxSourceProcessor, BooleanProcessor, CssStripeClassesProcessor, CssThemeOptionProcessor, CssThemeProcessor, EmptyStringProcessor, ExportEnabledFormatProcessor, ExportFormatProcessor, FeatureAppearProcessor, FeatureFilterPlaceholderProcessor, FeatureFilterSelectorProcessor, FeatureLengthMenuProcessor, FeaturePaginationTypeProcessor, FilterableProcessor, FilterTypeProcessor, IntegerProcessor, MainExtensionNamesProcessor, MessageProcessor, SortDirectionProcessor, SortTypeProcessor, StringBuilderProcessor, StringProcessor

public abstract class AbstractConfigurationProcessor
extends Object
implements ConfigurationProcessor

Abstract superclass for all configuration processors, table and column.

Basically, a processor processes a value then stores the processed value in the passed TableConfiguration or ColumnConfiguration instance.

Some processors may need to access a wider context, e.g. to register an Extension depending on the presence of other attributes. That's why some other objects are also passed to the process method.

Finally, some processors accept a special syntax allowing to load one or more Dandelion bundles to the current HttpServletRequest. This syntax will be processed only if bundleAware, which is passed in the constructor of the processor, is set to true.

Since:
0.10.0
Author:
Thibault Duchateau
See Also:
TableConfig, ColumnConfig

Field Summary
protected  boolean bundleAware
           
protected  ColumnConfiguration columnConfiguration
           
protected  Map.Entry<ConfigToken<?>,Object> configEntry
           
protected  javax.servlet.http.HttpServletRequest request
           
protected  Map<ConfigToken<?>,Object> stagingConf
           
protected  Map<ConfigToken<?>,Extension> stagingExtensions
           
protected  String stringifiedValue
           
protected  TableConfiguration tableConfiguration
           
 
Constructor Summary
AbstractConfigurationProcessor()
           
AbstractConfigurationProcessor(boolean bundleAware)
           
 
Method Summary
protected  void addColumnEntry(ConfigToken<?> configToken, Object value)
           Add a new entry to the staging configuration map of the current ColumnConfiguration instance.
protected  void addTableEntry(ConfigToken<?> configToken, Object value)
           Add a new entry to the staging configuration map of the current TableConfiguration instance.
protected abstract  void doProcess()
           Processes the configuration value stored in stringifiedValue.
protected  boolean isColumnEntryPresent(ConfigToken<?> configToken)
           Test whether the passed ConfigToken is already present in the configuration map.
protected  boolean isTableEntryPresent(ConfigToken<?> configToken)
           Test whether the passed ConfigToken is already present in the configuration map.
 void process(Map.Entry<ConfigToken<?>,Object> configEntry, ColumnConfiguration columnConfiguration, TableConfiguration tableConfiguration)
           Processes the passed entry which is a ConfigToken from ColumnConfig.
 void process(Map.Entry<ConfigToken<?>,Object> configEntry, TableConfiguration tableConfiguration)
           Processes the passed entry which is a ConfigToken from TableConfig.
protected  void registerExtension(Extension extension)
           Utility method used to register an extension to the current TableConfiguration instance.
protected  void updateEntry(Object value)
           Update the entry using with the new value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

request

protected javax.servlet.http.HttpServletRequest request

tableConfiguration

protected TableConfiguration tableConfiguration

columnConfiguration

protected ColumnConfiguration columnConfiguration

stagingConf

protected Map<ConfigToken<?>,Object> stagingConf

stagingExtensions

protected Map<ConfigToken<?>,Extension> stagingExtensions

configEntry

protected Map.Entry<ConfigToken<?>,Object> configEntry

stringifiedValue

protected String stringifiedValue

bundleAware

protected boolean bundleAware
Constructor Detail

AbstractConfigurationProcessor

public AbstractConfigurationProcessor()

AbstractConfigurationProcessor

public AbstractConfigurationProcessor(boolean bundleAware)
Method Detail

process

public void process(Map.Entry<ConfigToken<?>,Object> configEntry,
                    TableConfiguration tableConfiguration)

Processes the passed entry which is a ConfigToken from TableConfig. The value stored in the entry will be updated depending on the processor declared in the ConfigToken.

If new entries are to be added, they will be added in the stagingConfigurations field of the passed TableConfiguration instance.

Specified by:
process in interface ConfigurationProcessor
Parameters:
configEntry - The map entry to update.
tableConfiguration - The table configuration to be updated.

process

public void process(Map.Entry<ConfigToken<?>,Object> configEntry,
                    ColumnConfiguration columnConfiguration,
                    TableConfiguration tableConfiguration)

Processes the passed entry which is a ConfigToken from ColumnConfig. The value stored in the entry will be updated depending on the processor declared in the ConfigToken.

If new entries are to be added, they will be added in the stagingConfigurations field of the passed ColumnConfiguration instance.

Specified by:
process in interface ConfigurationProcessor
Parameters:
configEntry - The map entry to update.
columnConfiguration - The column configuration to be updated.
tableConfiguration - The table configuration to be updated.

doProcess

protected abstract void doProcess()

Processes the configuration value stored in stringifiedValue.


registerExtension

protected void registerExtension(Extension extension)

Utility method used to register an extension to the current TableConfiguration instance.

Parameters:
extension - The extension to register.

updateEntry

protected void updateEntry(Object value)

Update the entry using with the new value.

Note that Map.Entry.setValue(Object) must be used because the configuration map is being iterated on.

Parameters:
value - The new typed value to set in the entry.

addTableEntry

protected void addTableEntry(ConfigToken<?> configToken,
                             Object value)

Add a new entry to the staging configuration map of the current TableConfiguration instance.

The new entry cannot be directly added to the configuration map because this map is being iterated on (ConcurrentModificationException).

The staging configuration map will be merged in the final map just after the end of the loop. See the TableConfig.processConfiguration(com.github.dandelion.datatables.core.html.HtmlTable) method.

Parameters:
configToken - The new ConfigToken to add.
value - The value associated with the ConfigToken.

isTableEntryPresent

protected boolean isTableEntryPresent(ConfigToken<?> configToken)

Test whether the passed ConfigToken is already present in the configuration map.

In most of the cases, this is useful to initialize a entry with a default value.

Parameters:
configToken -
Returns:
true if present, otherwise false.

addColumnEntry

protected void addColumnEntry(ConfigToken<?> configToken,
                              Object value)

Add a new entry to the staging configuration map of the current ColumnConfiguration instance.

The new entry cannot be directly added to the configuration map because this map is being iterated on (ConcurrentModificationException).

The staging configuration map will be merged in the final map just after the end of the loop. See the ColumnConfig.processConfiguration(com.github.dandelion.datatables.core.html.HtmlColumn, com.github.dandelion.datatables.core.html.HtmlTable) method.

Parameters:
configToken - The new ConfigToken to add.
value - The value associated with the ConfigToken.

isColumnEntryPresent

protected boolean isColumnEntryPresent(ConfigToken<?> configToken)

Test whether the passed ConfigToken is already present in the configuration map.

In most of the cases, this is useful to initialize a entry with a default value.

Parameters:
configToken -
Returns:
true if present, otherwise false.


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