net.sf.mmm.util.text.base
Class AbstractHyphenatorBuilder

java.lang.Object
  extended by net.sf.mmm.util.component.base.AbstractComponent
      extended by net.sf.mmm.util.component.base.AbstractLoggableComponent
          extended by net.sf.mmm.util.text.base.AbstractHyphenatorBuilder
All Implemented Interfaces:
HyphenatorBuilder
Direct Known Subclasses:
HyphenatorBuilderImpl

public abstract class AbstractHyphenatorBuilder
extends AbstractLoggableComponent
implements HyphenatorBuilder

This is the abstract base-implementation of the HyphenatorBuilder interface.
It uses a cache with WeakReferences to the Hyphenators that have already been build. If a Hyphenator is requested several times, it can typically be served from the cache.

Since:
2.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Field Summary
private  ConcurrentHashMap<String,WeakReference<Hyphenator>> hyphenatorCache
          Cache for getHyphenator(Locale).
private  NlsResourceLocator resourceLocator
          The resource locator.
 
Constructor Summary
AbstractHyphenatorBuilder()
          The constructor.
 
Method Summary
protected abstract  Hyphenator createHyphenator(String localeInfix)
          This method creates a new Hyphenator.
protected  void doInitialize()
          This method performs the actual initialization.
 Hyphenator getHyphenator()
          This method gets the Hyphenator for the default locale.
 Hyphenator getHyphenator(Locale locale)
          This method gets the Hyphenator for the given Locale.
protected  NlsResourceLocator getResourceLocator()
           
 void setResourceLocator(NlsResourceLocator resourceLocator)
           
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent
getLogger, setLogger
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractComponent
doInitialized, getInitializationState, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hyphenatorCache

private final ConcurrentHashMap<String,WeakReference<Hyphenator>> hyphenatorCache
Cache for getHyphenator(Locale).


resourceLocator

private NlsResourceLocator resourceLocator
The resource locator.

Constructor Detail

AbstractHyphenatorBuilder

public AbstractHyphenatorBuilder()
The constructor.

Method Detail

doInitialize

protected void doInitialize()
This method performs the actual initialization. It is called when AbstractComponent.initialize() is invoked for the first time.
ATTENTION:
When you override this method from a sub-class you need to do a super.AbstractComponent.doInitialize().

Overrides:
doInitialize in class AbstractLoggableComponent

getHyphenator

public Hyphenator getHyphenator()
This method gets the Hyphenator for the default locale.

Specified by:
getHyphenator in interface HyphenatorBuilder
Returns:
the according Hyphenator.

getHyphenator

public Hyphenator getHyphenator(Locale locale)
This method gets the Hyphenator for the given Locale. If no hyphenation-rules are available for the given Locale, a Hyphenator for a more general Locale is build.

Specified by:
getHyphenator in interface HyphenatorBuilder
Parameters:
locale - is the Locale used to determine the hyphenation-rules for the according country and region.
Returns:
the according Hyphenator.

createHyphenator

protected abstract Hyphenator createHyphenator(String localeInfix)
This method creates a new Hyphenator.

Parameters:
localeInfix - is the locale-infix of the requested Hyphenator.
Returns:
the requested Hyphenator or null if no hyphenation configuration is available for the given localeInfix.
See Also:
getHyphenator(Locale)

getResourceLocator

protected NlsResourceLocator getResourceLocator()
Returns:
the resourceLocator

setResourceLocator

@Inject
public void setResourceLocator(NlsResourceLocator resourceLocator)
Parameters:
resourceLocator - is the resourceLocator to set


Copyright © 2001-2010 mmm-Team. All Rights Reserved.