com.mkaz.htmllib API Documenation v0.74


com.mkaz
Class htmllib

java.lang.Object
  |
  +--com.mkaz.htmllib

public class htmllib
extends java.lang.Object

com.mkaz.htmllib is a java library which provides shortcut methods to ease the development of html documents (code). This can be compared to CGI.pm for Perl. Many of the commands and shortcuts available in CGI.pm are (or will be) available here.

Example Usage:


      htmllib html = new htmllib();	
 
      // create a link
      out.println(html.link("web blazonry","http://blazonry.com/"));
 


Constructor Summary
htmllib()
          Main Constructor.
 
Method Summary
 java.lang.String b(java.lang.String str)
          Creates a bold piece of text
 java.lang.String endftable()
          Creates an end table tag for fancy table
 java.lang.String endtable()
          Creates an end table tag.
 java.lang.String form(java.lang.String action, java.lang.String method)
          Creates a form tag with action url and method
 java.lang.String ftable(java.lang.String color1, java.lang.String color2, java.lang.String width)
          Creates a fancy table tag with color1 border and color2 background (padding=4 spacing=0)
 java.lang.String h1(java.lang.String str)
          Creates an HTML H1
 java.lang.String h2(java.lang.String str)
          Creates an HTML H2
 java.lang.String h3(java.lang.String str)
          Creates an HTML H3
 java.lang.String h4(java.lang.String str)
          Creates an HTML H4
 java.lang.String h5(java.lang.String str)
          Creates an HTML H5
 java.lang.String h6(java.lang.String str)
          Creates an HTML H6
 java.lang.String header(java.lang.String title)
          Creates a complete HTML header with DOCTYPE 4.0T, HTML, HEAD, TITLE and BODY tags.
 java.lang.String header(java.lang.String title, java.lang.String bgcolor)
          Creates a complete HTML header with DOCTYPE 4.0T, HTML, HEAD, TITLE and BODY tags.
 java.lang.String hfrow(java.lang.String[] col, java.lang.String bgcolor)
          Creates a table header row from an array
 java.lang.String hfrow(java.lang.String col1, java.lang.String col2, java.lang.String bgcolor)
          Creates a two col table header row
 java.lang.String hfrow(java.lang.String col1, java.lang.String col2, java.lang.String col3, java.lang.String bgcolor)
          Creates a three col table header row.
 java.lang.String hfrow(java.lang.String col1, java.lang.String col2, java.lang.String col3, java.lang.String col4, java.lang.String bgcolor)
          Creates a four col table header row
 java.lang.String hidden(java.lang.String name, java.lang.String value)
          Creates a hidden form element with name, value
 java.lang.String hrow(java.lang.String[] col)
          Creates a table header row from an array
 java.lang.String hrow(java.lang.String col1, java.lang.String col2)
          Creates a two col table header row
 java.lang.String hrow(java.lang.String col1, java.lang.String col2, java.lang.String col3)
          Creates a three col table header row.
 java.lang.String hrow(java.lang.String col1, java.lang.String col2, java.lang.String col3, java.lang.String col4)
          Creates a four col table header row
 java.lang.String i(java.lang.String str)
          Creates an italic piece of text
 java.lang.String img(java.lang.String image, int width, int height, java.lang.String alt)
          Creates an image tag with width, height, and alternate text
 java.lang.String img(java.lang.String image, java.lang.String alt)
          Creates an image tag
 java.lang.String link(java.lang.String desc, java.lang.String url)
          Creates an HTML A HREF link.
 java.lang.String password(java.lang.String name, int size, int maxlength)
          Creates a password form element with name, size, maxlength
 java.lang.String row(java.lang.String[] col)
          Creates a table row from an array
 java.lang.String row(java.lang.String col1, java.lang.String col2)
          Creates a two col table row
 java.lang.String row(java.lang.String col1, java.lang.String col2, java.lang.String col3)
          Creates a three col table row.
 java.lang.String row(java.lang.String col1, java.lang.String col2, java.lang.String col3, java.lang.String col4)
          Creates a four col table row
 java.lang.String selectfield(java.lang.String fieldname, java.util.Hashtable options)
          Creates a select field with options
 java.lang.String submit(java.lang.String value)
          Creates a submit button form element with value
 java.lang.String table()
          Create a "blank" table tag.
 java.lang.String table(int padding, int spacing, int border)
          Creates a table tag with padding, spacing and border
 java.lang.String table(int padding, int spacing, int border, java.lang.String width)
          Creates a table tag with padding, spacing, border and width
 java.lang.String text(java.lang.String name, java.lang.String value, int size, int maxlength)
          Creates a text form element with name, value, size, maxlength
 java.lang.String textarea(java.lang.String name, java.lang.String value, int rows, int cols)
          Creates a textarea form element with name, value, rows, cols (wrap on)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

htmllib

public htmllib()
Main Constructor. You need to create an htmllib object to use the rest of the functions.

Example: htmllib html = new htmllib();

Method Detail

header

public java.lang.String header(java.lang.String title)
Creates a complete HTML header with DOCTYPE 4.0T, HTML, HEAD, TITLE and BODY tags. Default background color is white.
Parameters:
title - title of the HTML page (string)
Returns:
HTML header as a string

header

public java.lang.String header(java.lang.String title,
                               java.lang.String bgcolor)
Creates a complete HTML header with DOCTYPE 4.0T, HTML, HEAD, TITLE and BODY tags.
Parameters:
title - title of the HTML page (string)
bgcolor - HTML color hex (with #), or color name for background
Returns:
HTML header as a string

h1

public java.lang.String h1(java.lang.String str)
Creates an HTML H1
Parameters:
string - text to be H1
Returns:
string with H1 tags added

h2

public java.lang.String h2(java.lang.String str)
Creates an HTML H2
Parameters:
string - text to be H2
Returns:
string with H2 tags added

h3

public java.lang.String h3(java.lang.String str)
Creates an HTML H3
Parameters:
string - text to be H3
Returns:
string with H3 tags added

h4

public java.lang.String h4(java.lang.String str)
Creates an HTML H4
Parameters:
string - text to be H4
Returns:
string with H4 tags added

h5

public java.lang.String h5(java.lang.String str)
Creates an HTML H5
Parameters:
string - text to be H5
Returns:
string with H5 tags added

h6

public java.lang.String h6(java.lang.String str)
Creates an HTML H6
Parameters:
string - text to be H6
Returns:
string with H6 tags added

b

public java.lang.String b(java.lang.String str)
Creates a bold piece of text
Parameters:
string - text to be bolded
Returns:
string with bold tags added

i

public java.lang.String i(java.lang.String str)
Creates an italic piece of text
Parameters:
string - text to be italic
Returns:
string with italic tags added

link

public java.lang.String link(java.lang.String desc,
                             java.lang.String url)
Creates an HTML A HREF link.
Parameters:
desc - the description of the link, ie. the (blue) part that shows up on screen.
url - the URL to set the link to
Returns:
string <A HREF="url">desc</A>

table

public java.lang.String table()
Create a "blank" table tag.
Returns:
string "blank" starting table tag

endtable

public java.lang.String endtable()
Creates an end table tag.
Returns:
string ending table tag

table

public java.lang.String table(int padding,
                              int spacing,
                              int border)
Creates a table tag with padding, spacing and border
Parameters:
padding - int CELLPADDING for table
spacing - int CELLSPACING for table
border - int BORDER width for table
Returns:
string table with padding, spacing and border

table

public java.lang.String table(int padding,
                              int spacing,
                              int border,
                              java.lang.String width)
Creates a table tag with padding, spacing, border and width
Parameters:
padding - int CELLPADDING for table
spacing - int CELLSPACING for table
border - int BORDER width for table
width - string width of table (% or px)
Returns:
string table with padding, spacing, border and width

hrow

public java.lang.String hrow(java.lang.String col1,
                             java.lang.String col2)
Creates a two col table header row
Parameters:
col1 - string contents for col1
col2 - string contents for col2
Returns:
html table header row with two cols as a string

hrow

public java.lang.String hrow(java.lang.String col1,
                             java.lang.String col2,
                             java.lang.String col3)
Creates a three col table header row.
Parameters:
col1 - string contents for col1
col2 - string contents for col2
col3 - string contents for col3
Returns:
html table header row with three cols as a string

hrow

public java.lang.String hrow(java.lang.String col1,
                             java.lang.String col2,
                             java.lang.String col3,
                             java.lang.String col4)
Creates a four col table header row
Parameters:
col1 - string contents for col1
col2 - string contents for col2
col3 - string contents for col3
col4 - string contents for col4
Returns:
html table header row with four cols as a string

hrow

public java.lang.String hrow(java.lang.String[] col)
Creates a table header row from an array
Parameters:
col - string array of columns
Returns:
html table header row with array length columns

row

public java.lang.String row(java.lang.String col1,
                            java.lang.String col2)
Creates a two col table row
Parameters:
col1 - string contents for col1
col2 - string contents for col2
Returns:
html table row with two cols as a string

row

public java.lang.String row(java.lang.String col1,
                            java.lang.String col2,
                            java.lang.String col3)
Creates a three col table row.
Parameters:
col1 - string contents for col1
col2 - string contents for col2
col3 - string contents for col3
Returns:
html table row with three cols as a string

row

public java.lang.String row(java.lang.String col1,
                            java.lang.String col2,
                            java.lang.String col3,
                            java.lang.String col4)
Creates a four col table row
Parameters:
col1 - string contents for col1
col2 - string contents for col2
col3 - string contents for col3
col4 - string contents for col4
Returns:
html table row with four cols as a string

row

public java.lang.String row(java.lang.String[] col)
Creates a table row from an array
Parameters:
col - string array of columns
Returns:
html table row with array length columns

endftable

public java.lang.String endftable()
Creates an end table tag for fancy table
Returns:
string ending table tag

ftable

public java.lang.String ftable(java.lang.String color1,
                               java.lang.String color2,
                               java.lang.String width)
Creates a fancy table tag with color1 border and color2 background (padding=4 spacing=0)
Parameters:
color1 - String BORDER color for fancy table
color2 - String BACKGROUND for fancy table
width - String WIDTH of the fancy table
Returns:
string fancy table start tags

hfrow

public java.lang.String hfrow(java.lang.String col1,
                              java.lang.String col2,
                              java.lang.String bgcolor)
Creates a two col table header row
Parameters:
col1 - string contents for col1
col2 - string contents for col2
bgcolor - string background color
Returns:
html table header row with two cols as a string and background color

hfrow

public java.lang.String hfrow(java.lang.String col1,
                              java.lang.String col2,
                              java.lang.String col3,
                              java.lang.String bgcolor)
Creates a three col table header row.
Parameters:
col1 - string contents for col1
col2 - string contents for col2
col3 - string contents for col3
bgcolor - string background color
Returns:
html table header row with three cols as a string and background color

hfrow

public java.lang.String hfrow(java.lang.String col1,
                              java.lang.String col2,
                              java.lang.String col3,
                              java.lang.String col4,
                              java.lang.String bgcolor)
Creates a four col table header row
Parameters:
col1 - string contents for col1
col2 - string contents for col2
col3 - string contents for col3
col4 - string contents for col4
bgcolor - string background color
Returns:
html table header row with four cols as a string and background color

hfrow

public java.lang.String hfrow(java.lang.String[] col,
                              java.lang.String bgcolor)
Creates a table header row from an array
Parameters:
col - string array of columns
bgcolor - string background color
Returns:
html table header row with array length columns

img

public java.lang.String img(java.lang.String image,
                            java.lang.String alt)
Creates an image tag
Parameters:
image - string link to image
alt - string alternate text
Returns:
html image tag

img

public java.lang.String img(java.lang.String image,
                            int width,
                            int height,
                            java.lang.String alt)
Creates an image tag with width, height, and alternate text
Parameters:
image - string link to image
width - int width of image
height - int height of image
alt - string alternate text
Returns:
html image tag

form

public java.lang.String form(java.lang.String action,
                             java.lang.String method)
Creates a form tag with action url and method
Parameters:
action - url to submit the form to, action field in form
method - GET or POST
Returns:
String html start form tag

hidden

public java.lang.String hidden(java.lang.String name,
                               java.lang.String value)
Creates a hidden form element with name, value
Parameters:
name - String hidden field name
value - String hidden field value
Returns:
String html hidden form element

submit

public java.lang.String submit(java.lang.String value)
Creates a submit button form element with value
Parameters:
value - string text displayed on the button
Returns:
String html form submit button

text

public java.lang.String text(java.lang.String name,
                             java.lang.String value,
                             int size,
                             int maxlength)
Creates a text form element with name, value, size, maxlength
Parameters:
name - string text field name
value - string text field default value
size - int text field width
maxlength - int text field maximum length
Returns:
String html text form element

password

public java.lang.String password(java.lang.String name,
                                 int size,
                                 int maxlength)
Creates a password form element with name, size, maxlength
Parameters:
name - string text field name
size - int text field width
maxlength - int text field maximum length
Returns:
String html password form element

textarea

public java.lang.String textarea(java.lang.String name,
                                 java.lang.String value,
                                 int rows,
                                 int cols)
Creates a textarea form element with name, value, rows, cols (wrap on)
Parameters:
name - String textarea field name
value - String textarea field default value
rows - int number of rows in textarea
cols - int number of columns in textarea
Returns:
String html textarea form element

selectfield

public java.lang.String selectfield(java.lang.String fieldname,
                                    java.util.Hashtable options)
Creates a select field with options
Parameters:
fieldname - name of the select field
options - Hashtable of options with the option value set to the hashkey, and the display value set to the hashvalue
Returns:
String html select field and option tags form elements