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

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

public class HyphenatorImpl
extends AbstractHyphenator

This is the implementation of the Hyphenator interface. It uses a list of rules to determine hyphenation-points.

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

Field Summary
private  Map<String,HyphenationImpl> exceptionMap
          The Map with explicit exceptions.
private  StringHasher hasher
           
private  int maxPatternLength
          The maximum length of the patterns.
private  HyphenationPattern[] patterns
          The patterns.
private  StringUtil stringUtil
           
 
Constructor Summary
HyphenatorImpl(Locale locale, char hyphen, List<String> patternList, List<String> exceptionList, StringHasher hasher, StringUtil stringUtil)
          The constructor.
 
Method Summary
 Hyphenation hyphenate(String word)
          
protected  String normalize(String word)
          This method normalizes the given word.
private static HyphenationPattern[] sortPatterns(HyphenationPattern[] patternArray)
          This method sorts the given patterns according to the length of their word-part.
 String toString()
          
 
Methods inherited from class net.sf.mmm.util.text.base.AbstractHyphenator
getHyphen, getLocale, hyphenate, hyphenate
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent
doInitialize, 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, wait, wait, wait
 

Field Detail

exceptionMap

private final Map<String,HyphenationImpl> exceptionMap
The Map with explicit exceptions.


patterns

private final HyphenationPattern[] patterns
The patterns.


maxPatternLength

private final int maxPatternLength
The maximum length of the patterns.


hasher

private final StringHasher hasher
See Also:
StringHasher

stringUtil

private final StringUtil stringUtil
See Also:
StringUtil
Constructor Detail

HyphenatorImpl

public HyphenatorImpl(Locale locale,
                      char hyphen,
                      List<String> patternList,
                      List<String> exceptionList,
                      StringHasher hasher,
                      StringUtil stringUtil)
The constructor.

Parameters:
locale - is the locale.
hyphen - is the hyphen-character.
patternList - is the List of patterns.
exceptionList - is the list of pre-hyphenated exceptions (e.g. "as-so-ciate").
hasher - is the hash-algorithm. It should be fast.
stringUtil - is the StringUtil to use.
Method Detail

sortPatterns

private static HyphenationPattern[] sortPatterns(HyphenationPattern[] patternArray)
This method sorts the given patterns according to the length of their word-part.

Parameters:
patternArray - are the unsorted patterns.
Returns:
the sorted patterns.

normalize

protected String normalize(String word)
This method normalizes the given word.

Parameters:
word - is the word to normalize.
Returns:
the normalized form of word.

hyphenate

public Hyphenation hyphenate(String word)

Parameters:
word - is the word to hyphenate.
Returns:
the Hyphenation for the given word.
See Also:
Hyphenator.hyphenate(String, int, int)

toString

public String toString()

Overrides:
toString in class Object


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