org.extex.unit.tex.hyphen
Class HyphenationPrimitive

java.lang.Object
  extended by org.extex.interpreter.type.AbstractCode
      extended by org.extex.unit.tex.hyphen.AbstractHyphenationCode
          extended by org.extex.unit.tex.hyphen.HyphenationPrimitive
All Implemented Interfaces:
java.io.Serializable, Code
Direct Known Subclasses:
Hyphenation

public class HyphenationPrimitive
extends AbstractHyphenationCode

This class provides an implementation for the primitive \hyphenation.

The Primitive \hyphenation

The primitive \hyphenation can be used to add hyphenation exceptions to the current language. The argument is a list of whitespace separated words enclosed in braces. The hyphenation points are indicated by including a hyphen character (-) at the appropriate places.

When paragraph breaking needs to insert additional break points these hyphenation points are translated into discretionaries. The exceptions specified with the primitive \hyphenation have precedence before the hyphenation points found with the help of hyphenation patterns.

One example which make use of this precedence is the hyphenation exception without any hyphen characters. This can be used to suppress any hyphenation in a single word.

Syntax

    ⟨hyphenation⟩
     → \hyphenation {...} 

Example:

   \hyphenation{as-so-ciate as-so-ciates}  

Version:
$Revision: 4770 $
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
HyphenationPrimitive(CodeToken token)
          Creates a new object.
 
Method Summary
protected  UnicodeCharList collectWord(Context context, TokenSource source, Token token)
          Collect all characters that make up a word.
 void execute(Flags prefix, Context context, TokenSource source, Typesetter typesetter)
          This method takes the first token and executes it. The result is placed on the stack. This operation might have side effects. To execute a token it might be necessary to consume further tokens.
protected  boolean isWordConstituent(Token t, Context context)
          This method checks that the given token is a word constituent.
 
Methods inherited from class org.extex.unit.tex.hyphen.AbstractHyphenationCode
getHyphenationTable
 
Methods inherited from class org.extex.interpreter.type.AbstractCode
getLocalizer, getName, getToken, isIf, isOuter, readResolve, toString, toText, toText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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

HyphenationPrimitive

public HyphenationPrimitive(CodeToken token)
Creates a new object.

Parameters:
token - the initial token for the primitive
Method Detail

collectWord

protected UnicodeCharList collectWord(Context context,
                                      TokenSource source,
                                      Token token)
                               throws HelpingException,
                                      CatcodeException
Collect all characters that make up a word.

Parameters:
context - the interpreter context
source - the source for new tokens
token - the first token already read
Returns:
the first character not included into the word
Throws:
HelpingException - in case of an error
CatcodeException - in case of an exception in token creation

execute

public void execute(Flags prefix,
                    Context context,
                    TokenSource source,
                    Typesetter typesetter)
             throws HelpingException,
                    MissingLeftBraceException,
                    NoHelpException
This method takes the first token and executes it. The result is placed on the stack. This operation might have side effects. To execute a token it might be necessary to consume further tokens.

Specified by:
execute in interface Code
Overrides:
execute in class AbstractCode
Parameters:
prefix - the prefix controlling the execution
context - the interpreter context
source - the token source
typesetter - the typesetter
Throws:
HelpingException - in case of an error
MissingLeftBraceException
NoHelpException
See Also:
AbstractCode.execute( org.extex.interpreter.Flags, org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

isWordConstituent

protected boolean isWordConstituent(Token t,
                                    Context context)
                             throws HelpingException
This method checks that the given token is a word constituent. This means that the token is either

Parameters:
t - the token to analyze
context - the interpreter context
Returns:
true iff the token is
Throws:
HelpingException - in case of an error