com.ccg.macros.at
Class Base

java.lang.Object
  extended by com.ccg.macros.at.Base
Direct Known Subclasses:
Core, Html, Script, Strings

public class Base
extends Object

Base class for specialized @macro handlers.

This class is used to build specialized macro handlers. It provides common methods which derived classes will find useful (allowing them to concentrate on their specific macro definitions).

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

Constructor Summary
protected Base(boolean hasFile)
          Construct the object and optionally interpret a initialization file.
 
Method Summary
protected  AtMacros getAtMacros()
          Get the associated AtMacros processor.
 double getDoubleParameter(Vector args, int i, double def)
          Safely retrieve and interpret a parameter and get the double value.
 int getIntParameter(Vector args, int i, int def)
          Safely retrieve and interpret a parameter and get the integer value.
 long getLongParameter(Vector args, int i, long def)
          Safely retrieve and interpret a parameter and get the integer value.
 String getStringParameter(Vector args, int i)
          Safely retrieve and interpret a parameter.
 void install(AtMacros at)
          Register's all of the method macros AND loads the predefined property macros for the class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base

protected Base(boolean hasFile)
Construct the object and optionally interpret a initialization file.

Parameters:
hasFile - Set to true if there is a associated initialization file. The initialization file must be found in the same manner as the class file - except that it will end with ".At" instead of ".class". For example, the "/com/ccg/macros/at/Html" class has a "/com/ccg/macros/at/Html.At" file associated with it.
Since:
1.0
Method Detail

install

public void install(AtMacros at)
Register's all of the method macros AND loads the predefined property macros for the class.

First, this method installs all of the "macro handler" methods (see AtMacros.addMacros(Object) for information on macro handler methods) of the class.

If the class also has a associated macro resource file, the resource file will then be interpretted by the macro processor (to load simple text style macros). During this "loading" phase, no output will be generated (unless the associated property file tries really hard to generate some).

Parameters:
am - The AtMacros object to register all of the macros with. Must not be null.
Since:
1.0

getStringParameter

public final String getStringParameter(Vector args,
                                       int i)
                                throws IOException,
                                       InterpretException
Safely retrieve and interpret a parameter.

Many times a macro isn't picky about the string value of a parameter passed to the macro - it just wants to make sure it isn't passed a null. This method will fetch the desired parameter which was passed to your macro, interpret it and return the string representation.

It never returns null, but it may return a zero length string.

It will throw an exception if interpretation of the parameter was required but failed.

Parameters:
args - A vector of arguments which were passed to the macro.
i - Index of the argument you want (0 corresponds to first entry).
Returns:
String representation of the parameter to the macro (after interpretation). Returns "" if parameter omitted or index out of range (never returns null).
Throws:
InterpretException - If a internal (or macro error) is encountered while processing.
IOException - If interpretation of parameter involved output that triggered a I/O error.
Since:
1.0

getIntParameter

public final int getIntParameter(Vector args,
                                 int i,
                                 int def)
                          throws IOException,
                                 InterpretException
Safely retrieve and interpret a parameter and get the integer value.

Many times a macro isn't picky about the string value of a parameter passed to the macro - it just wants to make sure it isn't passed a null. This method will fetch the desired parameter which was passed to your macro, interpret it and return the string representation.

It will throw an exception if interpretation of the parameter was required but failed.

Parameters:
args - A vector of arguments which were passed to the macro.
i - Index of the argument you want (0 corresponds to first entry).
def - Default value to return if argument omitted or doesn't evaluate properly.
Returns:
Integer value of the specified parameter (or your default value if we could not convert it).
Throws:
InterpretException - If a internal (or macro error) is encountered while processing.
IOException - If interpretation of parameter involved output that triggered a I/O error.
Since:
1.0

getLongParameter

public final long getLongParameter(Vector args,
                                   int i,
                                   long def)
                            throws IOException,
                                   InterpretException
Safely retrieve and interpret a parameter and get the integer value.

Many times a macro isn't picky about the string value of a parameter passed to the macro - it just wants to make sure it isn't passed a null. This method will fetch the desired parameter which was passed to your macro, interpret it and return the string representation.

It will throw an exception if interpretation of the parameter was required but failed.

Parameters:
args - A vector of arguments which were passed to the macro.
i - Index of the argument you want (0 corresponds to first entry).
def - Default value to return if argument omitted or doesn't evaluate properly.
Returns:
Integer value of the specified parameter (or your default value if we could not convert it).
Throws:
InterpretException - If a internal (or macro error) is encountered while processing.
IOException - If interpretation of parameter involved output that triggered a I/O error.
Since:
1.0

getDoubleParameter

public final double getDoubleParameter(Vector args,
                                       int i,
                                       double def)
                                throws IOException,
                                       InterpretException
Safely retrieve and interpret a parameter and get the double value.

Many times a macro isn't picky about the string value of a parameter passed to the macro - it just wants to make sure it isn't passed a null. This method will fetch the desired parameter which was passed to your macro, interpret it and return the string representation.

It will throw an exception if interpretation of the parameter was required but failed.

Parameters:
args - A vector of arguments which were passed to the macro.
i - Index of the argument you want (0 corresponds to first entry).
def - Default value to return if argument omitted or doesn't evaluate properly.
Returns:
Double value of the specified parameter (or your default value if we could not convert it).
Throws:
InterpretException - If a internal (or macro error) is encountered while processing.
IOException - If interpretation of parameter involved output that triggered a I/O error.
Since:
1.0

getAtMacros

protected AtMacros getAtMacros()
Get the associated AtMacros processor.

This method allows derived classes to get access to the macro processor which they are working for. It corresponds to the last registered AtMacros which was installed.

Returns:
Current AtMacros value assigned during last install.


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