net.davidashen.text
Class Hyphenator

java.lang.Object
  |
  +--net.davidashen.text.Hyphenator

public class Hyphenator
extends java.lang.Object

insert soft hyphens at all allowed locations uses TeX hyphenation tables


Constructor Summary
Hyphenator()
          creates an uninitialized instance of Hyphenator.
 
Method Summary
 java.lang.String hyphenate(java.lang.String phrase)
          performs hyphenation
 java.lang.String hyphenate(java.lang.String phrase, int remain_count, int push_count)
          performs hyphenation
 void loadTable(java.io.InputStream in)
          loads hyphenation table
 void loadTable(java.io.InputStream in, int[] codelist)
          loads hyphenation table and code list for non-ucs encoding
static void main(java.lang.String[] args)
          simple command-line invocation -- serves as example
 void setErrorHandler(net.davidashen.util.ErrorHandler eh)
          installs error handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Hyphenator

public Hyphenator()
creates an uninitialized instance of Hyphenator. The same instance can be reused for different hyphenation tables.
Method Detail

setErrorHandler

public void setErrorHandler(net.davidashen.util.ErrorHandler eh)
installs error handler.
Parameters:
eh - ErrorHandler used while parsing and hyphenating
See Also:
ErrorHandler

loadTable

public void loadTable(java.io.InputStream in)
               throws java.io.IOException
loads hyphenation table
Parameters:
in - hyphenation table
Throws:
java.io.IOException -  

loadTable

public void loadTable(java.io.InputStream in,
                      int[] codelist)
               throws java.io.IOException
loads hyphenation table and code list for non-ucs encoding
Parameters:
in - hyphenation table
codelist - an array of 256 elements. maps one-byte codes to UTF codes
Throws:
java.io.IOException -  

hyphenate

public java.lang.String hyphenate(java.lang.String phrase)
performs hyphenation
Parameters:
phrase - string to hyphenate
Returns:
the string with soft hyphens inserted

hyphenate

public java.lang.String hyphenate(java.lang.String phrase,
                                  int remain_count,
                                  int push_count)
performs hyphenation
Parameters:
phrase - string to hyphenate
push_count - unbreakable characters at the end of the string
remain_count - unbreakable characters at the beginning of the string
Returns:
the string with soft hyphens inserted

main

public static void main(java.lang.String[] args)
simple command-line invocation -- serves as example