au.id.pbw.hyfo.hyph
Class HyphenBreak

java.lang.Object
  extended by au.id.pbw.hyfo.hyph.HyphenBreak
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
HyphenInhibitor

public class HyphenBreak
extends Object
implements Serializable

This class represents a possible hyphenation break. It includes a Modifier object, akin to the discretionary break of TeX, and a weight. If the weight is an odd number between 1 and 9 inclusive, it is an hyphenation opportunity. If the weight is an even number between 2 and 8 inclusive, it inhibits hyphenation, and if it is 0, it is neutral with respect to hyphenation.

Consequently, only odd weight values need have an associated Modifier, although this is not enforced, as modifiers on even-numbered weights are simply ignored.

Author:
Peter B. West
See Also:
Serialized Form

Field Summary
 boolean check_nobreak_text
          Flags this HyphenBreak as one which may have a complex break with text replacement.
static byte DEFAULT_WEIGHT
          The default weight for a HyphenBreak.
static byte NEUTRAL_WEIGHT
          The weight for a neutral break; that is, a point which neither supports nor inhibits hyphenation.
 String nobreak
          The text before line-breaking.
 String post_brkpt
          The post-break text of this HyphenBreak.
 String pre_brkpt
          The pre-break text of this HyphenBreak.
 String replace_post_brkpt
          The replacement text following the hyphen position that replaces the post_brkpt text.
 String replace_pre_brkpt
          The replacement text preceding the hyphen position that replaces the pre_brkpt text.
 byte weight
          The weight of this HyphenBreak.
 
Constructor Summary
HyphenBreak(Alphabet alphabet)
          Constructs a HyphenBreak with the default weight and default Modifier values.
HyphenBreak(byte weight, Alphabet alphabet)
          Constructs a HyphenBreak with the given weight and default Modifier values.
HyphenBreak(char ch, Alphabet alphabet)
          Constructs a HyphenBreak with a weight derived from the given character, and default Modifier values.
HyphenBreak(Modifier modifier)
          Constructs a HyphenBreak with the given Modifier.
 
Method Summary
 Byte get_weight()
          Gets the weight of this HyphenBreak.
 String make_key()
          Constructs a String key from the HyphenBreak.
 String toString()
          Gets a string representation of the HyphenBreak.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nobreak

public final String nobreak
The text before line-breaking.


pre_brkpt

public final String pre_brkpt
The pre-break text of this HyphenBreak. When hyphenation changes the text being hyphenated, the no-break text is replaced by pre-break text HYPHEN new-line post-break text; in this replacement, the pre_brkpt text is replaced by the pre-break text.


post_brkpt

public final String post_brkpt
The post-break text of this HyphenBreak. When hyphenation changes the text being hyphenated, the no-break text is replaced by pre-break text HYPHEN new-line post-break text; in this replacement, the post_brkpt text is replaced by the post-break text.


replace_pre_brkpt

public final String replace_pre_brkpt
The replacement text preceding the hyphen position that replaces the pre_brkpt text.


replace_post_brkpt

public final String replace_post_brkpt
The replacement text following the hyphen position that replaces the post_brkpt text.


check_nobreak_text

public boolean check_nobreak_text
Flags this HyphenBreak as one which may have a complex break with text replacement.


weight

public final byte weight
The weight of this HyphenBreak.


NEUTRAL_WEIGHT

public static final byte NEUTRAL_WEIGHT
The weight for a neutral break; that is, a point which neither supports nor inhibits hyphenation. Hyphenation never occurs at a point marked by a neutral HyphenBreak.

See Also:
Constant Field Values

DEFAULT_WEIGHT

public static final byte DEFAULT_WEIGHT
The default weight for a HyphenBreak.

See Also:
Constant Field Values
Constructor Detail

HyphenBreak

public HyphenBreak(Alphabet alphabet)
Constructs a HyphenBreak with the default weight and default Modifier values.

Parameters:
alphabet - the Alphabet applyin.g to this HyphenBreak.

HyphenBreak

public HyphenBreak(byte weight,
                   Alphabet alphabet)
            throws HyphenationException
Constructs a HyphenBreak with the given weight and default Modifier values.

Parameters:
alphabet - the Alphabet applyin.g to this HyphenBreak.
weight - the weight of this HyphenBreak.
Throws:
HyphenationException - if the weight is not between 0 and 9, inclusive.

HyphenBreak

public HyphenBreak(Modifier modifier)
            throws HyphenationException
Constructs a HyphenBreak with the given Modifier. The weight is derived from the no-break text of the Modifier.

Parameters:
modifier - the Modifier.
Throws:
HyphenationException - if a single valid weight cannot be derived from the no-break text of the Modifier.

HyphenBreak

public HyphenBreak(char ch,
                   Alphabet alphabet)
            throws HyphenationException
Constructs a HyphenBreak with a weight derived from the given character, and default Modifier values.

Parameters:
alphabet - the Alphabet applyin.g to this HyphenBreak.
ch - the character from which to derive the weight.
Throws:
HyphenationException - if a valid weight cannot be derived from the character.
Method Detail

get_weight

public Byte get_weight()
Gets the weight of this HyphenBreak.

Returns:
the weight.

make_key

public String make_key()
Constructs a String key from the HyphenBreak. The key is used in caching HyphenBreak instances in the HyphenationTree.

Returns:
the constructed key.

toString

public String toString()
Gets a string representation of the HyphenBreak.

Overrides:
toString in class Object
Returns:
the string representation of this object.


Copyright © 2005-2006 Peter B. West.