Class AbstractHyphenator
- java.lang.Object
-
- org.teichert.databaseexplorer.hyphen.AbstractHyphenator
-
- All Implemented Interfaces:
Hyphenator
- Direct Known Subclasses:
EscapingHyphenator
,TextHyphenator
public abstract class AbstractHyphenator extends Object implements Hyphenator
Abstract Hyphenator.It contains the algorithm to split text into words, HTML-Tags, punctuation and other strings like
"90³/h"
. These segments are then send to the methodsappendWord(java.lang.StringBuilder, java.lang.StringBuilder)
,appendTag(java.lang.StringBuilder, java.lang.StringBuilder)
orappendHyphenatedWord(java.lang.StringBuilder, java.lang.StringBuilder, java.lang.String)
which must be implemented by the subclass to do the actual work.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
pushCharCount
protected int
remainCharCount
protected HyphenationTree
tree
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractHyphenator(HyphenationTree tree)
protected
AbstractHyphenator(HyphenationTree tree, int remainCharCount, int pushCharCount)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
appendHyphenatedWord(StringBuilder result, StringBuilder wordBuffer, String hyphen)
Appends the content of wordBuffer to result and truncates the wordBuffer.protected abstract void
appendTag(StringBuilder result, StringBuilder wordBuffer)
Appends the content of wordBuffer to result and truncates the wordBuffer.protected abstract void
appendWord(StringBuilder result, StringBuilder wordBuffer)
Appends the content of wordBuffer to result and truncates the wordBuffer.CharSequence
hyphenateText(CharSequence text, String hyphen)
-
-
-
Field Detail
-
tree
protected final HyphenationTree tree
-
remainCharCount
protected final int remainCharCount
-
pushCharCount
protected final int pushCharCount
-
-
Constructor Detail
-
AbstractHyphenator
protected AbstractHyphenator(HyphenationTree tree)
-
AbstractHyphenator
protected AbstractHyphenator(HyphenationTree tree, int remainCharCount, int pushCharCount)
-
-
Method Detail
-
hyphenateText
public CharSequence hyphenateText(CharSequence text, String hyphen)
- Specified by:
hyphenateText
in interfaceHyphenator
-
appendWord
protected abstract void appendWord(StringBuilder result, StringBuilder wordBuffer)
Appends the content of wordBuffer to result and truncates the wordBuffer. The implementing method may modify the content.- Parameters:
result
- output bufferwordBuffer
- buffered word
-
appendTag
protected abstract void appendTag(StringBuilder result, StringBuilder wordBuffer)
Appends the content of wordBuffer to result and truncates the wordBuffer. The implementing method should not modify the content.- Parameters:
result
- output bufferwordBuffer
- buffered word
-
appendHyphenatedWord
protected abstract void appendHyphenatedWord(StringBuilder result, StringBuilder wordBuffer, String hyphen)
Appends the content of wordBuffer to result and truncates the wordBuffer.- Parameters:
result
- output bufferwordBuffer
- buffered wordhyphen
- hyphen String eg."-"
or""
-
-