All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sdsu.html.Formatter

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

public class Formatter
extends 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 Index

 o Formatter()
Create a new Formatter
 o Formatter(String)
Create a new Formatter object on the string All special html characters in string asciiText are escaped

Method Index

 o alignCenter()
Centers the contents of object.
 o alignLeft()
Left justifies contents of object.
 o alignRight()
Right justifies the contents of object.
 o append(HTML)
Append the an existing HTML object to the current end of the text.
 o append(String)
Append the string 'asciiText' to the current end of the text
 o appendBold(String)
Append the string 'asciiText' to the current end of the text as bold text
 o appendHeading(String, int)
Append the string heading to the current end of the text as a heading.
 o appendHTMLTags(String)
Appends the string withHTMLTags without escaping special characters.
 o appendItalic(String)
Append the string 'asciiText' to the current end of the text as bold text
 o appendLineBreak()
Appends one HTML line break (or carriage returns) to the current end of the text.
 o appendLink(String, String)
Append the string 'asciiText' to the current end of the text as linked text.
 o appendMailLink(String)
Appends a mailTo reference.
 o makeBlockQuote()
Sets the current object to be a HTML block quote.
 o makeParagraph()
Sets the current object to be a HTML paragraph.
 o makePreformatted()
Sets the current text to preformatted.
 o toString()
Converts the text to an string with proper html tags

Constructors

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

 o Formatter
 public Formatter()
Create a new Formatter

Methods

 o alignCenter
 public void alignCenter()
Centers the contents of object.

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

 o alignLeft
 public void alignLeft()
Left justifies contents of object.

 o 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

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

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

 o toString
 public String toString()
Converts the text to an string with proper html tags

Overrides:
toString in class Object
 o append
 public void append(String asciiText)
Append the string 'asciiText' to the current end of the text

 o 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.

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

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

 o appendHeading
 public void appendHeading(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.
 o appendHTMLTags
 public void appendHTMLTags(String withHTMLTags)
Appends the string withHTMLTags without escaping special characters. Use to add strings that contain HTML tags

 o appendLink
 public void appendLink(String asciiText,
                        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
 o appendMailLink
 public void appendMailLink(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
 o appendLineBreak
 public void appendLineBreak()
Appends one HTML line break (or carriage returns) to the current end of the text.


All Packages  Class Hierarchy  This Package  Previous  Next  Index