prog.utils
Class HTMLWordWrap

java.lang.Object
  |
  +--prog.utils.HTMLWordWrap

public class HTMLWordWrap
extends java.lang.Object

Like WordWrap, this converts a long String into a multi-line String that fits within a specified line length (or default of 80 characters per line). It ignores any HTML tags in the input String and replaces any newline characters with <BR>. It inserts a <BR> at the start of every new line resulting from wrapping.

Author:
John E. Darrow (c) 2000, 2001

Constructor Summary
HTMLWordWrap()
          Sets the column width to 80.
HTMLWordWrap(int lineLength)
          Sets the maximum number of characters in a line to lineLength.
 
Method Summary
 java.lang.String format(java.lang.String str)
          Inserts line breaks and
in str so that there are no morecharacters per line than the default (80) or the than the line length set via constructor.
 java.lang.String format(java.lang.String str, int lineLength)
          Inserts line breaks and
in str so that there are no more characters per line than lineLength.
static void main(java.lang.String[] args)
           
 void setLineLength(int lineLength)
          Sets the line length for word wrap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTMLWordWrap

public HTMLWordWrap()
Sets the column width to 80.

HTMLWordWrap

public HTMLWordWrap(int lineLength)
Sets the maximum number of characters in a line to lineLength.
Parameters:
lineLength - Number of characters to allow in a line before splitting.
Method Detail

format

public java.lang.String format(java.lang.String str)
Inserts line breaks and
in str so that there are no morecharacters per line than the default (80) or the than the line length set via constructor.

format

public java.lang.String format(java.lang.String str,
                               int lineLength)
Inserts line breaks and
in str so that there are no more characters per line than lineLength.

setLineLength

public void setLineLength(int lineLength)
Sets the line length for word wrap.

main

public static void main(java.lang.String[] args)