de.dante.extex.language.hyphenation.base
Class BaseHyphenationTable

java.lang.Object
  extended byde.dante.extex.language.hyphenation.base.BaseHyphenationTable
All Implemented Interfaces:
Hyphenator, Language, LigatureBuilder, ModifiableLanguage, java.io.Serializable, WordTokenizer
Direct Known Subclasses:
LiangsHyphenationTable

public class BaseHyphenationTable
extends java.lang.Object
implements ModifiableLanguage, java.io.Serializable

This class stores the values for hyphenations and hyphenates words.

Version:
$Revision: 1.19 $
Author:
Gerd Neugebauer, Michael Niedermair
See Also:
Serialized Form

Field Summary
protected static long serialVersionUID
          The constant serialVersionUID contains the id for serialization.
 
Constructor Summary
BaseHyphenationTable()
          Creates a new object.
 
Method Summary
 void addHyphenation(UnicodeCharList word, TypesetterOptions options)
          Add a user-defined hyphenation.
 void addPattern(Tokens pattern)
          Add a pattern to the hyphenation table.
protected static boolean[] createHyphenation(UnicodeCharList pattern, TypesetterOptions context, UnicodeCharList key)
          Create the name for the HyphenationTable.
 int findWord(NodeList nodes, int start, UnicodeCharList word)
          Extract a word from a node list.
 long getLeftHyphenmin()
          Return the value for the minimum number of characters before a hyphenation on the left hand side of a word.
 UnicodeChar getLigature(UnicodeChar c1, UnicodeChar c2, Font f)
          Get a single ligature of to characters.
 java.lang.String getName()
          Getter for the name.
 long getRightHyphenmin()
          Return the value for the minimum number of characters before a hyphenation on the right hand side of a word.
 boolean hyphenate(NodeList nodes, TypesetterOptions context, UnicodeChar hyphen, int start, boolean forall, NodeFactory nodeFactory)
          Insert the hyphenation marks for a horizontal list of nodes.
 boolean hyphenateOne(NodeList nodes, TypesetterOptions context, int start, UnicodeCharList word, CharNode hyphenNode)
          Hyphenate a single word.
 int insertLigatures(NodeList list, int start)
          Take a node list and transform character sequences into ligatures where appropriate.
 void insertShy(NodeList nodes, int insertionPoint, boolean[] spec, CharNode hyphenNode)
          Insert hyphenation points into a list of nodes.
 boolean isHyphenActive()
          Return true, if hyphenation is active, otherwise false;
 UnicodeCharList normalize(UnicodeCharList word, TypesetterOptions options)
          Normalize a word for the lookup.
protected  java.lang.Object readResolve()
          Magic method for deserialization.
 void setHyphenActive(boolean active)
          Activate or deactivate the hyphenation for this language.
 void setLeftHyphenmin(long left)
          Set the value for the minimum number of characters before a hyphenation on the left hand side of a word.
 void setLigatureBuilder(LigatureBuilder builder)
          Setter for the ligature builder.
 void setName(java.lang.String name)
          Setter for name.
 void setRightHyphenmin(long right)
          Set the value for the minimum number of characters before a hyphenation on the right hand side of a word.
 void setWordTokenizer(WordTokenizer wordTokenizer)
          Setter for wordTokenizer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

protected static final long serialVersionUID
The constant serialVersionUID contains the id for serialization.

See Also:
Constant Field Values
Constructor Detail

BaseHyphenationTable

public BaseHyphenationTable()
Creates a new object.

Method Detail

createHyphenation

protected static boolean[] createHyphenation(UnicodeCharList pattern,
                                             TypesetterOptions context,
                                             UnicodeCharList key)
Create the name for the HyphenationTable.

Parameters:
pattern - the pattern
context - the interpreter context
key - the container to store the key in
Returns:
the name

addHyphenation

public void addHyphenation(UnicodeCharList word,
                           TypesetterOptions options)
                    throws HyphenationException
Description copied from interface: Hyphenator
Add a user-defined hyphenation.

The hyphenation template consists of a word of characters. The Unicode soft hyphenation character has a special meaning. This character is used to indicate places where a hyphenation is permitted. The other characters – i.e. normal Unicode characters – are used as-is.

Specified by:
addHyphenation in interface Hyphenator
Parameters:
word - the word with the hyphenation marks
options - the interpreter context
Throws:
HyphenationException - in case of an error
See Also:
Hyphenator.addHyphenation( de.dante.util.UnicodeCharList, de.dante.extex.typesetter.TypesetterOptions)

addPattern

public void addPattern(Tokens pattern)
                throws HyphenationException
Description copied from interface: Hyphenator
Add a pattern to the hyphenation table.

Specified by:
addPattern in interface Hyphenator
Parameters:
pattern - the pattern word with numbers
Throws:
HyphenationException - in case of an error
See Also:
Hyphenator.addPattern( Tokens)

findWord

public int findWord(NodeList nodes,
                    int start,
                    UnicodeCharList word)
             throws HyphenationException
Description copied from interface: WordTokenizer
Extract a word from a node list.

Specified by:
findWord in interface WordTokenizer
Parameters:
nodes - the nodes to extract the word from
start - the start index
word - the target list for the letters of the word
Returns:
the index of the first node beyond the word
Throws:
HyphenationException - in case of an error
See Also:
WordTokenizer.findWord( de.dante.extex.typesetter.type.NodeList, int, de.dante.util.UnicodeCharList)

getLeftHyphenmin

public long getLeftHyphenmin()
                      throws HyphenationException
Description copied from interface: Hyphenator
Return the value for the minimum number of characters before a hyphenation on the left hand side of a word.

Specified by:
getLeftHyphenmin in interface Hyphenator
Returns:
the value \lefthyphenmin
Throws:
HyphenationException - in case of an error
See Also:
Hyphenator.getLeftHyphenmin()

getLigature

public UnicodeChar getLigature(UnicodeChar c1,
                               UnicodeChar c2,
                               Font f)
                        throws HyphenationException
Description copied from interface: LigatureBuilder
Get a single ligature of to characters.

Specified by:
getLigature in interface LigatureBuilder
Parameters:
c1 - the first character
c2 - the second character
f - the current font
Returns:
the ligature of c1 and c2 or null if none exists
Throws:
HyphenationException - in case of an error
See Also:
LigatureBuilder.getLigature( de.dante.util.UnicodeChar, de.dante.util.UnicodeChar, de.dante.extex.interpreter.type.font.Font)

getName

public java.lang.String getName()
Description copied from interface: Language
Getter for the name.

Specified by:
getName in interface Language
Returns:
the name
See Also:
Language.getName()

getRightHyphenmin

public long getRightHyphenmin()
                       throws HyphenationException
Description copied from interface: Hyphenator
Return the value for the minimum number of characters before a hyphenation on the right hand side of a word.

Specified by:
getRightHyphenmin in interface Hyphenator
Returns:
the value \righthyphenmin
Throws:
HyphenationException - in case of an error
See Also:
Hyphenator.getRightHyphenmin()

hyphenate

public boolean hyphenate(NodeList nodes,
                         TypesetterOptions context,
                         UnicodeChar hyphen,
                         int start,
                         boolean forall,
                         NodeFactory nodeFactory)
                  throws HyphenationException
Description copied from interface: Hyphenator
Insert the hyphenation marks for a horizontal list of nodes. The hyphenation marks are made up of discretionary nodes.

Specified by:
hyphenate in interface Hyphenator
Parameters:
nodes - the horizontal node list
context - the context
hyphen - the tokens to be inserted for hyphens
start - the start index
forall - the indicator that all words to the end should be processed. if false then only the next word is hyphenated.
nodeFactory - the node factory
Returns:
true iff the hyphenator is responsible for this word. Usually this means that some hyphenation marks have been inserted.
Throws:
HyphenationException - in case of an error
See Also:
Hyphenator.hyphenate( de.dante.extex.typesetter.type.NodeList, de.dante.extex.typesetter.TypesetterOptions, de.dante.util.UnicodeChar, int, boolean, de.dante.extex.typesetter.type.node.factory.NodeFactory)

hyphenateOne

public boolean hyphenateOne(NodeList nodes,
                            TypesetterOptions context,
                            int start,
                            UnicodeCharList word,
                            CharNode hyphenNode)
                     throws HyphenationException
Hyphenate a single word.

Parameters:
nodes - the node list to consider
context - the options to use
start - the start index in the nodes
word - the word to hyphenate
hyphenNode - the node to use as hyphen
Returns:
true iff the the word has been found
Throws:
HyphenationException - in case of an error

insertLigatures

public int insertLigatures(NodeList list,
                           int start)
                    throws HyphenationException
Description copied from interface: LigatureBuilder
Take a node list and transform character sequences into ligatures where appropriate. The processing should extend over all characters with the same font and non-character nodes. It should return the control to the caller as soon as a character node with another font is found.

Specified by:
insertLigatures in interface LigatureBuilder
Parameters:
list - the node list to create ligatures for
start - the index in the list to start processing
Returns:
the index after last node processed
Throws:
HyphenationException - in case of an error
See Also:
LigatureBuilder.insertLigatures( de.dante.extex.typesetter.type.NodeList, int)

insertShy

public void insertShy(NodeList nodes,
                      int insertionPoint,
                      boolean[] spec,
                      CharNode hyphenNode)
               throws HyphenationException
Description copied from interface: WordTokenizer
Insert hyphenation points into a list of nodes.

Specified by:
insertShy in interface WordTokenizer
Parameters:
nodes - the node list to modify
insertionPoint - the index to insert something into the nodes
spec - the specification where to insert hyphenation marks. If spec[i] is true then a hyphen needs to be inserted before the ith character at or after insertionPoint in nodes
hyphenNode - the hyphen as node
Throws:
HyphenationException - in case of an error
See Also:
WordTokenizer.insertShy( de.dante.extex.typesetter.type.NodeList, int, boolean[], de.dante.extex.typesetter.type.node.CharNode)

isHyphenActive

public boolean isHyphenActive()
                       throws HyphenationException
Description copied from interface: Hyphenator
Return true, if hyphenation is active, otherwise false;

Specified by:
isHyphenActive in interface Hyphenator
Returns:
true iff the hyphenation for this language is enabled
Throws:
HyphenationException - in case of an error
See Also:
Hyphenator.isHyphenActive()

normalize

public UnicodeCharList normalize(UnicodeCharList word,
                                 TypesetterOptions options)
                          throws HyphenationException
Description copied from interface: WordTokenizer
Normalize a word for the lookup.

Specified by:
normalize in interface WordTokenizer
Parameters:
word - the word to normalize
options - the options to use
Returns:
the normalized word
Throws:
HyphenationException - in case of an error
See Also:
WordTokenizer.normalize( de.dante.util.UnicodeCharList, de.dante.extex.typesetter.TypesetterOptions)

readResolve

protected java.lang.Object readResolve()
                                throws java.io.ObjectStreamException
Magic method for deserialization.

Returns:
the reconnection result
Throws:
java.io.ObjectStreamException - in case of an error

setHyphenActive

public void setHyphenActive(boolean active)
                     throws HyphenationException
Description copied from interface: Hyphenator
Activate or deactivate the hyphenation for this language. If the hyphenation is deactivated then no hyphenation should be added automatically.

Specified by:
setHyphenActive in interface Hyphenator
Parameters:
active - the indicator that the hyphenation is activated
Throws:
HyphenationException - in case of an error
See Also:
Hyphenator.setHyphenActive(boolean)

setLeftHyphenmin

public void setLeftHyphenmin(long left)
                      throws HyphenationException
Description copied from interface: Hyphenator
Set the value for the minimum number of characters before a hyphenation on the left hand side of a word.

Specified by:
setLeftHyphenmin in interface Hyphenator
Parameters:
left - the new value
Throws:
HyphenationException - in case of an error
See Also:
Hyphenator.setLeftHyphenmin(long)

setLigatureBuilder

public void setLigatureBuilder(LigatureBuilder builder)
Description copied from interface: ModifiableLanguage
Setter for the ligature builder.

Specified by:
setLigatureBuilder in interface ModifiableLanguage
Parameters:
builder - the ligature builder
See Also:
ModifiableLanguage.setLigatureBuilder( de.dante.extex.language.ligature.LigatureBuilder)

setName

public void setName(java.lang.String name)
Setter for name.

Specified by:
setName in interface Language
Parameters:
name - the name to set

setRightHyphenmin

public void setRightHyphenmin(long right)
                       throws HyphenationException
Description copied from interface: Hyphenator
Set the value for the minimum number of characters before a hyphenation on the right hand side of a word.

Specified by:
setRightHyphenmin in interface Hyphenator
Parameters:
right - the new value
Throws:
HyphenationException - in case of an error
See Also:
Hyphenator.setRightHyphenmin(long)

setWordTokenizer

public void setWordTokenizer(WordTokenizer wordTokenizer)
Setter for wordTokenizer.

Specified by:
setWordTokenizer in interface ModifiableLanguage
Parameters:
wordTokenizer - the wordTokenizer to set