de.dante.extex.language.impl
Class FutureLanguage

java.lang.Object
  extended byde.dante.extex.language.impl.FutureLanguage
All Implemented Interfaces:
Hyphenator, Language, LigatureBuilder, ManagedLanguage, java.io.Serializable, WordTokenizer

public class FutureLanguage
extends java.lang.Object
implements ManagedLanguage, java.io.Serializable

This class implements the future pattern for a language object. The real object creation or loading is delayed until it is clear whether the loading or the creation should be performed.

Version:
$Revision: 1.14 $
Author:
Gerd Neugebauer
See Also:
Serialized Form

Field Summary
protected static long serialVersionUID
          The constant serialVersionUID contains the id for serialization.
 
Constructor Summary
FutureLanguage(java.lang.String index, LanguageCreator creator)
          Creates a new object.
 
Method Summary
 void addHyphenation(UnicodeCharList word, TypesetterOptions context)
          Add a user-defined hyphenation.
 void addPattern(Tokens pattern)
          Add a pattern to the hyphenation table.
 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 nodelist, TypesetterOptions context, UnicodeChar hyphen, int start, boolean forall, NodeFactory nodeFactory)
          Insert the hyphenation marks for a horizontal list of nodes.
 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 setCreator(LanguageCreator creator)
          Setter for the creator.
 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 setName(java.lang.String name)
          Setter for the 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.
 
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

FutureLanguage

public FutureLanguage(java.lang.String index,
                      LanguageCreator creator)
Creates a new object.

Parameters:
index - the name of the language for the creator
creator - the creator which should be contacted to perform the real task
Method Detail

addHyphenation

public void addHyphenation(UnicodeCharList word,
                           TypesetterOptions context)
                    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
context - 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( de.dante.extex.interpreter.type.tokens.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 nodelist,
                         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:
nodelist - 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)

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

setCreator

public void setCreator(LanguageCreator creator)
Description copied from interface: ManagedLanguage
Setter for the creator.

Specified by:
setCreator in interface ManagedLanguage
Parameters:
creator - the manager
See Also:
de.dante.extex.language.impl.ManagedLanguage#setCreator( de.dante.extex.language.LanguageManager)

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)

setName

public void setName(java.lang.String name)
Description copied from interface: Language
Setter for the name.

Specified by:
setName in interface Language
Parameters:
name - the name
See Also:
Language.setName(java.lang.String)

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)