com.ccg.macros.at
Class Html

java.lang.Object
  extended by com.ccg.macros.at.Base
      extended by com.ccg.macros.at.Html

public class Html
extends Base

Macros related to the generation of HTML documents.

Set of @macros which provide handy functions when generating HTML output. Developers don't typically make use of these methods, but end users who write HTML documents will.

Since:
1.0
Version:
$Revision: 1.1.1.1 $
Author:
$Author: pkb $

Constructor Summary
Html()
          Constructs the object and readies it for installation.
 
Method Summary
 void encodeFormParam(Output out, Vector args)
          @encodeFormParam(TEXT) - escape paramters passed as form values in a URL string.
 void htmlEscape(Output out, Vector args)
          @htmlEscape(TEXT) - escape special HTML characters '<', '>' and '&'.
static void main(String[] args)
          Main entry point into the application.
 void tableRow(Output out, Vector args)
          @tableRow(COL0,COL1,...) generate single row in HTML table.
 void urlJoin(Output out, Vector args)
          @urlJoin(ROOT[,SUB0[,SUB1 ...]) - do a "smart" join of strings when forming URL(s).
 
Methods inherited from class com.ccg.macros.at.Base
getAtMacros, getDoubleParameter, getIntParameter, getLongParameter, getStringParameter, install
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Html

public Html()
Constructs the object and readies it for installation.

Since:
1.0
See Also:
Base.install(com.ccg.macros.AtMacros)
Method Detail

htmlEscape

public void htmlEscape(Output out,
                       Vector args)
                throws IOException,
                       InterpretException
@htmlEscape(TEXT) - escape special HTML characters '<', '>' and '&'.

This should probably be relocated to a special HTML version of the At class. However, I needed something that would translate '<' into "<", '>' into ">" and '&' into "&" so that HTML examples would appear as the expected when viewed by a browser.

This macro simply replaces HTML special characters, with the HTML escape codes.

Parameters:
out - The output device to write the results of processing the argument to.
args - A vector of arguments which were passed to the macro.
Throws:
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
Since:
1.0

encodeFormParam

public void encodeFormParam(Output out,
                            Vector args)
                     throws IOException,
                            InterpretException
@encodeFormParam(TEXT) - escape paramters passed as form values in a URL string.

This macro simply replaces some characters that might need special escaping to be included in a URL. For example:

 @link("http://mysite.com/post.py?name=@encodeFormParam("Paul Blankenbaker")")
 

Parameters:
out - The output device to write the results of processing the argument to.
args - A vector of arguments which were passed to the macro.
Throws:
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
Since:
1.0

urlJoin

public void urlJoin(Output out,
                    Vector args)
             throws IOException,
                    InterpretException
@urlJoin(ROOT[,SUB0[,SUB1 ...]) - do a "smart" join of strings when forming URL(s).

It is common to form URLs by "joining" together one or more strings. For example, consider the following:

 @define("rootUrl","http://joe.com/")
 @define("subDir","local/")
 @define("fileName","joe.html")
 @rootUrl()@subDir()@fileName
 

 

The above would work, and result in the string "http://joe.com/local/joe.html".

However, the above form requires the user to worry about slashes ("/"), at the start or end. If the "rootUrl" had been defined as "http://joe.com", it would have come out as "http://joe.comlocal/joe.html" which is probably not what you want.

This takes the "worry" out of this situation, it sticks a slash ("/") between strings (or removes an extra one). So, using this makes life much easier. As an example ALL of the following will expand to the same URL ("http://joe.comlocal/joe.html").

 @urlJoin("http://joe.com/local","joe.html")
 @urlJoin("http://joe.com","local","joe.html")
 @urlJoin("http://joe.com/","/local/","/joe.html")
 @urlJoin("http://joe.com","/local","joe.html")
 

 

You can pass as many (or as few parameters) as you wish, we just keep joining them all together for you.

Parameters:
out - The output device to write the results of processing the argument to.
args - A vector of arguments which were passed to the macro.
Throws:
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
Since:
1.0

tableRow

public void tableRow(Output out,
                     Vector args)
              throws IOException,
                     InterpretException
@tableRow(COL0,COL1,...) generate single row in HTML table.

This macro looks at all of the parameters, evaluates them and then puts them insides the proper HTML tags for the purpose of buiding a table. Here is an example usage:

 @tableBegin(2,"My Table")
 @tableRow("Paul","Blankenbaker")
 @tableRow("Megan","Brown")
 @tableRow("Erik","Blankenbaker")
 @tableRow("Scott",Blankenbaker")
 @tableEnd()
 

Parameters:
out - The output device to write the results of processing the argument to.
args - A vector of arguments which were passed to the macro.
Throws:
IOException - If there is a problem writing to the output device
InterpretException - If a problem is encountered interpretting the arguments passed.
Since:
1.0

main

public static void main(String[] args)
Main entry point into the application.

Parameters:
args - Array of command line arguments.


Copyright 1998-1998-2006 null. All Rights Reserved.