org.nuiton.util.decorator
Class DecoratorMulti18nProvider

java.lang.Object
  extended by org.nuiton.util.decorator.DecoratorMulti18nProvider

public abstract class DecoratorMulti18nProvider
extends Object

A decorator provider for multi-i18n locale.

Implements the method loadDecorators(Locale) to fill the decorators availables.

Then can obtain decorator via the methods getDecorator(...)

Since:
2.3
Author:
tchemit

Nested Class Summary
static class DecoratorMulti18nProvider.DecoratorContext<T>
           
 
Field Summary
protected  Map<Locale,Collection<DecoratorMulti18nProvider.DecoratorContext<?>>> decoratorContexts
          Loaded decorators.
 
Constructor Summary
DecoratorMulti18nProvider()
           
 
Method Summary
 void clear()
           
<O> Decorator<O>
getDecorator(Locale locale, O object)
          Obtain a decorator for the given object using the given locale.
<O> Decorator<O>
getDecorator(Locale locale, O object, String name)
          Obtain a decorator given a object and an extra name to qualify the context using the given locale.
<O> Decorator<O>
getDecoratorByType(Locale locale, Class<O> type)
          Obtain a decorator given a type on the given locale.
<O> Decorator<O>
getDecoratorByType(Locale locale, Class<O> type, String name)
          Obtain a decorator given a type and a extra context name on the given locale.
protected
<T> DecoratorMulti18nProvider.DecoratorContext<T>
getDecoratorContext(Locale locale, Class<T> type, String context, boolean doLoad)
           
protected  Map<Locale,Collection<DecoratorMulti18nProvider.DecoratorContext<?>>> getDecoratorContexts()
           
protected  Collection<DecoratorMulti18nProvider.DecoratorContext<?>> getDecoratorContexts(Locale locale, boolean doLoad)
           
protected abstract  void loadDecorators(Locale locale)
          Load all decorators of the provider for the given locale.
protected  void registerDecorator(Locale locale, Decorator<?> decorator)
           
protected
<T> void
registerDecorator(Locale locale, String context, Decorator<T> decorator)
          Register a new decorator in the cache of the provider.
protected  void registerJXPathDecorator(Locale locale, Class<?> klass, String expression)
           
protected  void registerJXPathDecorator(Locale locale, Class<?> klass, String name, String expression)
           
protected  void registerMultiJXPathDecorator(Locale locale, Class<?> klass, String expression, String separator, String separatorReplacement)
           
protected  void registerMultiJXPathDecorator(Locale locale, Class<?> klass, String name, String expression, String separator, String separatorReplacement)
           
protected  void registerPropertyDecorator(Locale locale, Class<?> klass, String expression)
           
protected  void registerPropertyDecorator(Locale locale, Class<?> klass, String name, String expression)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

decoratorContexts

protected Map<Locale,Collection<DecoratorMulti18nProvider.DecoratorContext<?>>> decoratorContexts
Loaded decorators.

This map will be lazy loaded as needed via the method getDecoratorContexts(Locale, boolean).

Constructor Detail

DecoratorMulti18nProvider

public DecoratorMulti18nProvider()
Method Detail

loadDecorators

protected abstract void loadDecorators(Locale locale)
Load all decorators of the provider for the given locale.

Parameters:
locale - the locale to use to load decorators.

getDecorator

public <O> Decorator<O> getDecorator(Locale locale,
                                     O object)
Obtain a decorator for the given object using the given locale.

Type Parameters:
O - object of decorated object
Parameters:
locale - user locale
object - object of decorated object
Returns:
the decorator or null if not found

getDecorator

public <O> Decorator<O> getDecorator(Locale locale,
                                     O object,
                                     String name)
Obtain a decorator given a object and an extra name to qualify the context using the given locale.

Type Parameters:
O - object of decorated object
Parameters:
locale - user locale
object - object of decorated object
name - extra name to qualify the decorator to use
Returns:
the decorator or null if not found

getDecoratorByType

public <O> Decorator<O> getDecoratorByType(Locale locale,
                                           Class<O> type)
Obtain a decorator given a type on the given locale.

Type Parameters:
O - type of decorated object
Parameters:
locale - user locale
type - type of decorated object
Returns:
the decorator or null if not found

getDecoratorByType

public <O> Decorator<O> getDecoratorByType(Locale locale,
                                           Class<O> type,
                                           String name)
Obtain a decorator given a type and a extra context name on the given locale.

Type Parameters:
O - type of decorated object
Parameters:
locale - user locale
type - type of decorated object
name - extra name to qualify the decorator to use
Returns:
the decorator or null if not found

clear

public void clear()

getDecoratorContexts

protected Map<Locale,Collection<DecoratorMulti18nProvider.DecoratorContext<?>>> getDecoratorContexts()

getDecoratorContexts

protected Collection<DecoratorMulti18nProvider.DecoratorContext<?>> getDecoratorContexts(Locale locale,
                                                                                         boolean doLoad)

getDecoratorContext

protected <T> DecoratorMulti18nProvider.DecoratorContext<T> getDecoratorContext(Locale locale,
                                                                                Class<T> type,
                                                                                String context,
                                                                                boolean doLoad)

registerPropertyDecorator

protected void registerPropertyDecorator(Locale locale,
                                         Class<?> klass,
                                         String expression)

registerJXPathDecorator

protected void registerJXPathDecorator(Locale locale,
                                       Class<?> klass,
                                       String expression)

registerMultiJXPathDecorator

protected void registerMultiJXPathDecorator(Locale locale,
                                            Class<?> klass,
                                            String expression,
                                            String separator,
                                            String separatorReplacement)

registerPropertyDecorator

protected void registerPropertyDecorator(Locale locale,
                                         Class<?> klass,
                                         String name,
                                         String expression)

registerJXPathDecorator

protected void registerJXPathDecorator(Locale locale,
                                       Class<?> klass,
                                       String name,
                                       String expression)

registerMultiJXPathDecorator

protected void registerMultiJXPathDecorator(Locale locale,
                                            Class<?> klass,
                                            String name,
                                            String expression,
                                            String separator,
                                            String separatorReplacement)

registerDecorator

protected void registerDecorator(Locale locale,
                                 Decorator<?> decorator)

registerDecorator

protected <T> void registerDecorator(Locale locale,
                                     String context,
                                     Decorator<T> decorator)
Register a new decorator in the cache of the provider.

Type Parameters:
T - type of data decorated
Parameters:
locale - the given locale to use for this decorator
context - the name decorator
decorator - the decorator to register


Copyright © 2004-2011 CodeLutin. All Rights Reserved.