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

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
All Implemented Interfaces:
Hyphenator
Direct Known Subclasses:
HyphenatorImpl

public abstract class AbstractHyphenator
extends AbstractLoggableComponent
implements Hyphenator

This is the abstract base implementation of the Hyphenator interface.

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

Field Summary
private  char hyphen
           
private  Locale locale
           
 
Constructor Summary
AbstractHyphenator(Locale locale, char hyphen)
          The constructor.
 
Method Summary
 char getHyphen()
          This method gets the character used to separate the hyphenated parts of a word.
 Locale getLocale()
          This method gets the Locale this Hyphenator works for.
 Hyphenation hyphenate(String text, int start)
          
 Hyphenation hyphenate(String text, int start, int end)
          This method hyphenates the word from the given text from start to end.
 
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, toString, wait, wait, wait
 
Methods inherited from interface net.sf.mmm.util.text.api.Hyphenator
hyphenate
 

Field Detail

locale

private final Locale locale
See Also:
getLocale()

hyphen

private final char hyphen
See Also:
getHyphen()
Constructor Detail

AbstractHyphenator

public AbstractHyphenator(Locale locale,
                          char hyphen)
The constructor.

Parameters:
locale - is the locale.
hyphen - is the hyphen-character.
Method Detail

hyphenate

public Hyphenation hyphenate(String text,
                             int start)

Specified by:
hyphenate in interface Hyphenator
Parameters:
text - is the text ending with the word to hyphenate.
start - is the index of the words first character.
Returns:
the Hyphenation for the word given by text.substring(start)
See Also:
Hyphenator.hyphenate(String, int, int)

hyphenate

public Hyphenation hyphenate(String text,
                             int start,
                             int end)
This method hyphenates the word from the given text from start to end.
ATTENTION:
To ensure correct results you need to invoke this method for a single word of text. Please also note that word detection is far from trivial for specific languages such as Thai. You should use BreakIterator.getWordInstance(Locale) for word-separation.

Specified by:
hyphenate in interface Hyphenator
Parameters:
text - is the text containing the word to hyphenate.
start - is the index of the words first character.
end - is the exclusive end-index. The index of the words last character is end - 1.
Returns:
the Hyphenation for the word given by text.substring(start, end)

getLocale

public Locale getLocale()
This method gets the Locale this Hyphenator works for. It may differ from (be more general than) the Locale this Hyphenator was requested for.

Specified by:
getLocale in interface Hyphenator
Returns:
the Locale.
See Also:
HyphenatorBuilder.getHyphenator(Locale)

getHyphen

public char getHyphen()
This method gets the character used to separate the hyphenated parts of a word. This is typically the character '-'. However it may differ for specific Locales.

Specified by:
getHyphen in interface Hyphenator
Returns:
the hyphen character.


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