net.sf.mmm.util.text.api
Interface Hyphenator

All Known Implementing Classes:
AbstractHyphenator, HyphenatorImpl

public interface Hyphenator

A Hyphenator is used to hyphenate words. If a word is to long to fit at the end of a line of text, it may be hyphenated according to the locale.
An implementation has to be thread-safe.

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

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 word)
           
 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.
 

Method Detail

hyphenate

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

hyphenate

Hyphenation hyphenate(String text,
                      int start)
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:
hyphenate(String, int, int)

hyphenate

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.

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

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.

Returns:
the Locale.
See Also:
HyphenatorBuilder.getHyphenator(Locale)

getHyphen

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.

Returns:
the hyphen character.


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