|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpmp.AbstractMacro
public abstract class AbstractMacro
Abstract superclass for all macros.
Title: PMP: Macroprocessor
Description: Java macroprocessor
Copyright: Copyright (c) 2005
Field Summary | |
---|---|
protected int |
PARAMS_REQUIRED
Number of required parameters. |
Constructor Summary | |
---|---|
AbstractMacro()
Instances of macros are instantiated using nullary constructors. |
Method Summary | |
---|---|
int |
getRequiredParams()
Number of required parameters. |
abstract java.lang.String |
run(Macroprocessor mp,
java.lang.String[] args)
Main method of macro. |
java.lang.String |
toString()
Returns string representation of macro. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int PARAMS_REQUIRED
Constructor Detail |
---|
public AbstractMacro()
Method Detail |
---|
public abstract java.lang.String run(Macroprocessor mp, java.lang.String[] args)
mp
- reference to Macroprocessorargs
- parameters of macro. In args[0] is stored name of macro.
Subclasses are free to modify this array.
public final int getRequiredParams()
Number of required parameters. Before invoking run method, macroprocessor
checks the number of passed parameters and appends empty strings (""
)
to the end of args
array if necessary.
This method obtains number of parameters from field
PARAMS_REQUIRED
.
Value is number of formal parameters of macro. I.e.: it doesn't include name of macro, which is passed as parameter with index 0. So if your macro requires two parameters, this field should be set to 2, like this:
public static final int PARAMS_REQUIRED = 2;
This field allows you to omit length-checking of args
array in run(Macroprocessor,String[])
method. (But you still
have to perform test for empty string if your macro requires non-empty
parameters.
public java.lang.String toString()
Returns string representation of macro. This method is used by
defn
macro. If you want reimplement this method, you must
make sure it will not return null
.
For user-defined macros it should return definition and for builtin ones empty string unless it has some meaning.
toString
in class java.lang.Object
Defn
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |