sdsu.html
Class Formatter

java.lang.Object
  |
  +--sdsu.html.Formatter

public class Formatter
extends java.lang.Object
implements HTML

HTML formats text, which contains special tags to indicate various text features (bold, italic, etc). HTML has three special characters (<, >, &) which must be encoded if they are to displayed in a browser. Use the class to format items in HTML. This class escapes the special HTML characters. It is used by other class in sdsu.html to process strings to html. If you wish to generate HTML tags directly use appendHTMLTags(). This will not escape the special characters. The resulting Formatter object can be used correctly by other classes in sdsu.html.

Version:
0.9 6 April 1997
Author:
Roger Whitney (whitney@cs.sdsu.edu)

Constructor Summary
Formatter()
          Create a new Formatter
Formatter(java.lang.String asciiText)
          Create a new Formatter object on the string All special html characters in string asciiText are escaped
 
Method Summary
 void alignCenter()
          Centers the contents of object.
 void alignLeft()
          Left justifies contents of object.
 void alignRight()
          Right justifies the contents of object.
 void append(HTML htmlObject)
          Append the an existing HTML object to the current end of the text.
 void append(java.lang.String asciiText)
          Append the string 'asciiText' to the current end of the text
 void appendBold(java.lang.String asciiText)
          Append the string 'asciiText' to the current end of the text as bold text
 void appendHeading(java.lang.String heading, int headingLevel)
          Append the string heading to the current end of the text as a heading.
 void appendHTMLTags(java.lang.String withHTMLTags)
          Appends the string withHTMLTags without escaping special characters.
 void appendItalic(java.lang.String asciiText)
          Append the string 'asciiText' to the current end of the text as bold text
 void appendLineBreak()
          Appends one HTML line break (or carriage returns) to the current end of the text.
 void appendLink(java.lang.String asciiText, java.lang.String url)
          Append the string 'asciiText' to the current end of the text as linked text.
 void appendMailLink(java.lang.String mailAddress)
          Appends a mailTo reference.
 void makeBlockQuote()
          Sets the current object to be a HTML block quote.
 void makeParagraph()
          Sets the current object to be a HTML paragraph.
 void makePreformatted()
          Sets the current text to preformatted.
 java.lang.String toString()
          Converts the text to an string with proper html tags
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Formatter

public Formatter(java.lang.String asciiText)
Create a new Formatter object on the string All special html characters in string asciiText are escaped

Formatter

public Formatter()
Create a new Formatter
Method Detail

alignCenter

public void alignCenter()
Centers the contents of object.

alignRight

public void alignRight()
Right justifies the contents of object.

alignLeft

public void alignLeft()
Left justifies contents of object.

makePreformatted

public void makePreformatted()
Sets the current text to preformatted. HTML treats tabs and newlines as a space. HTML ignores multiple spaces. In preformated text tabs, newlines and multiple spaces are treated as tabs, newlines and multiple spaces. Here is an example of preformatted text:
This   has    some extra spaces in it


makeParagraph

public void makeParagraph()
Sets the current object to be a HTML paragraph.

makeBlockQuote

public void makeBlockQuote()
Sets the current object to be a HTML block quote.

toString

public java.lang.String toString()
Converts the text to an string with proper html tags
Specified by:
toString in interface HTML
Overrides:
toString in class java.lang.Object

append

public void append(java.lang.String asciiText)
Append the string 'asciiText' to the current end of the text

append

public void append(HTML htmlObject)
Append the an existing HTML object to the current end of the text. Object is converted to html tags immediately, so any changes made to the object later will not be reflected in web page.

appendBold

public void appendBold(java.lang.String asciiText)
Append the string 'asciiText' to the current end of the text as bold text

appendItalic

public void appendItalic(java.lang.String asciiText)
Append the string 'asciiText' to the current end of the text as bold text

appendHeading

public void appendHeading(java.lang.String heading,
                          int headingLevel)
Append the string heading to the current end of the text as a heading. Browser differ on how they render headings. Here are examples to demonstrate how your current renders headings:

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

Parameters:
heading - string added as a heading.
headingLevel - heading level text is set to.

appendHTMLTags

public void appendHTMLTags(java.lang.String withHTMLTags)
Appends the string withHTMLTags without escaping special characters. Use to add strings that contain HTML tags

appendLink

public void appendLink(java.lang.String asciiText,
                       java.lang.String url)
Append the string 'asciiText' to the current end of the text as linked text. An example of a url string for a relative link is notes/index.html An example of a url string for a absolute link is http://www.eli.sdsu.edu/courses/index.html.
Parameters:
asciiText - the string appended
url - the url the string is a link to

appendMailLink

public void appendMailLink(java.lang.String mailAddress)
Appends a mailTo reference. The provided mail address is linked and displayed. If mailAddress is: whitney@cs.sdsu.edu, then the result will be: :whitney@cs.sdsu.edu
Parameters:
mailAddress - string containing a well formed and valid mail address

appendLineBreak

public void appendLineBreak()
Appends one HTML line break (or carriage returns) to the current end of the text.