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

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
              extended by net.sf.mmm.util.text.base.HyphenatorBuilderImpl
All Implemented Interfaces:
HyphenatorBuilder

@Singleton
@Named
public class HyphenatorBuilderImpl
extends AbstractHyphenatorBuilder

The implementation of the HyphenatorBuilder interface.

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

Field Summary
static String HYPHENATION_XML_CONFIG_PREFIX
           
static String HYPHENATION_XML_CONFIG_SUFFIX
           
private static HyphenatorBuilder instance
           
private  StaxUtil staxUtil
           
private  StringHasher stringHasher
           
private  StringUtil stringUtil
           
private static QName XML_ATR_HYPHEN
          The XML attribute: .
private static QName XML_TAG_EXCEPTION
          The XML tag: .
private static QName XML_TAG_EXCEPTION_LIST
          The XML tag: .
private static QName XML_TAG_HYPHENATION
          The XML root tag: .
private static QName XML_TAG_PATTERN
          The XML tag: .
private static QName XML_TAG_PATTERN_LIST
          The XML tag: .
 
Constructor Summary
HyphenatorBuilderImpl()
          The constructor.
 
Method Summary
protected  Hyphenator createHyphenator(Locale locale, DataResource resource)
          This method creates a new Hyphenator instance from the XML-configuration identified by the given DataResource.
protected  Hyphenator createHyphenator(String localeInfix)
          This method creates a new Hyphenator.
protected  void doInitialize()
          This method performs the actual initialization.
static HyphenatorBuilder getInstance()
          This method gets the singleton instance of this HyphenatorBuilderImpl.
protected  StaxUtil getStaxUtil()
           
protected  StringHasher getStringHasher()
           
protected  StringUtil getStringUtil()
           
private  List<String> parseStringList(javax.xml.stream.XMLEventReader reader, QName elementName)
          This method parses a list of strings enclosed by elements with the given elementName until the current element ends.
 void setStaxUtil(StaxUtil staxUtil)
           
 void setStringHasher(StringHasher stringHasher)
           
 void setStringUtil(StringUtil stringUtil)
           
 
Methods inherited from class net.sf.mmm.util.text.base.AbstractHyphenatorBuilder
getHyphenator, getHyphenator, getResourceLocator, setResourceLocator
 
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

HYPHENATION_XML_CONFIG_PREFIX

public static final String HYPHENATION_XML_CONFIG_PREFIX
See Also:
createHyphenator(String), Constant Field Values

HYPHENATION_XML_CONFIG_SUFFIX

public static final String HYPHENATION_XML_CONFIG_SUFFIX
See Also:
createHyphenator(String), Constant Field Values

XML_TAG_HYPHENATION

private static final QName XML_TAG_HYPHENATION
The XML root tag: .


XML_ATR_HYPHEN

private static final QName XML_ATR_HYPHEN
The XML attribute: .


XML_TAG_EXCEPTION_LIST

private static final QName XML_TAG_EXCEPTION_LIST
The XML tag: .


XML_TAG_PATTERN_LIST

private static final QName XML_TAG_PATTERN_LIST
The XML tag: .


XML_TAG_EXCEPTION

private static final QName XML_TAG_EXCEPTION
The XML tag: .


XML_TAG_PATTERN

private static final QName XML_TAG_PATTERN
The XML tag: .


instance

private static HyphenatorBuilder instance
See Also:
getInstance()

staxUtil

private StaxUtil staxUtil
See Also:
getStaxUtil()

stringUtil

private StringUtil stringUtil
See Also:
getStringUtil()

stringHasher

private StringHasher stringHasher
See Also:
getStringHasher()
Constructor Detail

HyphenatorBuilderImpl

public HyphenatorBuilderImpl()
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 AbstractHyphenatorBuilder

getInstance

public static HyphenatorBuilder getInstance()
This method gets the singleton instance of this HyphenatorBuilderImpl.
This design is the best compromise between easy access (via this indirection you have direct, static access to all offered functionality) and IoC-style design which allows extension and customization.
For IoC usage, simply ignore all static getInstance() methods and construct new instances via the container-framework of your choice (like plexus, pico, springframework, etc.). To wire up the dependent components everything is properly annotated using common-annotations (JSR-250). If your container does NOT support this, you should consider using a better one.

Returns:
the singleton instance.

createHyphenator

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

Specified by:
createHyphenator in class AbstractHyphenatorBuilder
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:
AbstractHyphenatorBuilder.getHyphenator(Locale)

createHyphenator

protected Hyphenator createHyphenator(Locale locale,
                                      DataResource resource)
This method creates a new Hyphenator instance from the XML-configuration identified by the given DataResource.

Parameters:
locale - is the locale.
resource - is the DataResource with the XML-configuration.
Returns:
the Hyphenator instance.

parseStringList

private List<String> parseStringList(javax.xml.stream.XMLEventReader reader,
                                     QName elementName)
                              throws javax.xml.stream.XMLStreamException
This method parses a list of strings enclosed by elements with the given elementName until the current element ends. E.g. if you have this XML:
 <foo>
   <bar>text1</bar>
   <bar>text2</bar>
   <bar>text3</bar>
 </foo>
 
And your XML-reader is pointing after the opening <foo> and you call this method, you will get a list with "text1", "text2", and "text3".

Parameters:
reader - is the XMLEventReader pointing after the StartElement of the surrounding element.
elementName - is the name of the element containing a single string.
Returns:
the List of strings encountered until the surrounding element was closed.
Throws:
javax.xml.stream.XMLStreamException - if caused by the reader.

getStaxUtil

protected StaxUtil getStaxUtil()
Returns:
the staxUtil

setStaxUtil

@Inject
public void setStaxUtil(StaxUtil staxUtil)
Parameters:
staxUtil - is the staxUtil to set

getStringUtil

protected StringUtil getStringUtil()
Returns:
the stringUtil

setStringUtil

@Inject
public void setStringUtil(StringUtil stringUtil)
Parameters:
stringUtil - is the stringUtil to set

getStringHasher

protected StringHasher getStringHasher()
Returns:
the stringHasher

setStringHasher

public void setStringHasher(StringHasher stringHasher)
Parameters:
stringHasher - is the stringHasher to set


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