Class sdsu.html.Formater
All Packages Class Hierarchy This Package Previous Next Index
Class sdsu.html.Formater
java.lang.Object
|
+----sdsu.html.Formater
- public class Formater
- 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
Formater object can be used correctly by other classes in sdsu.html.
- Author:
- Roger Whitney (whitney@cs.sdsu.edu)
-
Formater()
- Create a new Formater
-
Formater(String)
- Create a new Formater object on the string
All special html characters in string asciiText are escaped
-
alignCenter()
- Centers the contents of object.
-
alignLeft()
- Left justifies contents of object.
-
alignRight()
- Right justifies the contents of object.
-
append(HTML)
- Append the an existing HTML object to the current end of the text.
-
append(String)
- Append the string 'asciiText' to the current end of the text
-
appendBold(String)
- Append the string 'asciiText' to the current end of the text
as bold text
-
appendHeading(String, int)
- Append the string heading to the current end of the text
as a heading.
-
appendHTMLTags(String)
- Appends the string withHTMLTags without escaping special
characters.
-
appendItalic(String)
- Append the string 'asciiText' to the current end of the text
as bold text
-
appendLineBreak()
- Appends one HTML line break (or carriage returns)
to the current end of the text.
-
appendLink(String, String)
- Append the string 'asciiText' to the current end of the text
as linked text.
-
appendMailLink(String)
- Appends a mailTo reference.
-
makeBlockQuote()
- Sets the current object to be a
HTML block quote.
-
makeParagraph()
- Sets the current object to be a
HTML paragraph.
-
makePreformatted()
- Sets the current text to preformatted.
-
toString()
- Converts the text to an string with proper html tags
Formater
public Formater(String asciiText)
- Create a new Formater object on the string
All special html characters in string asciiText are escaped
Formater
public Formater()
- Create a new Formater
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 String toString()
- Converts the text to an string with proper html tags
- Overrides:
- toString in class Object
append
public void append(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(String asciiText)
- Append the string 'asciiText' to the current end of the text
as bold text
appendItalic
public void appendItalic(String asciiText)
- Append the string 'asciiText' to the current end of the text
as bold text
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.
appendHTMLTags
public void appendHTMLTags(String withHTMLTags)
- Appends the string withHTMLTags without escaping special
characters. Use to add strings that contain HTML tags
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. That is the url string should
not start with ''.
- Parameters:
- asciiText - the string appended
- url - the url the string is a link to
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
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