net.sf.tomp.xtcl.command
Class Do

java.lang.Object
  extended by net.sf.tomp.xtcl.command.AbstractCommand
      extended by net.sf.tomp.xtcl.command.VarCommand
          extended by net.sf.tomp.xtcl.command.AbstractParametrizedVarCommand
              extended by net.sf.tomp.xtcl.command.Do
All Implemented Interfaces:
Parametrized, Command, ParametrizedCommand

public class Do
extends AbstractParametrizedVarCommand

Do a template.

Author:
tomp

Field Summary
 
Fields inherited from class net.sf.tomp.xtcl.command.VarCommand
var
 
Constructor Summary
Do()
           
 
Method Summary
 int execute(Context context)
          Do a template.
 java.lang.String getTemplateName()
           
protected  java.lang.String removeNonsubstituted(java.lang.String body)
          Removes parameter references that were not replaced by new values.
 void setParameter(java.lang.String k, java.lang.Object v)
          Sets the (formal, real) parameter pair
 void setTemplateName(java.lang.String p)
          Set the template name
protected  java.lang.String substitute(java.lang.String body)
          Find and Replace param references in the template body.
 java.lang.String toString()
          String repre of DO-TEMPLATE
 
Methods inherited from class net.sf.tomp.xtcl.command.AbstractParametrizedVarCommand
addParameterPropertiesReference, propertiesToParameters
 
Methods inherited from class net.sf.tomp.xtcl.command.VarCommand
setVar
 
Methods inherited from class net.sf.tomp.xtcl.command.AbstractCommand
done, initParameters, listArray, listList, listMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Do

public Do()
Method Detail

getTemplateName

public java.lang.String getTemplateName()
Returns:
Returns the name.

execute

public int execute(Context context)
            throws java.lang.Exception
Do a template. If templatename starts with @, template is loaded from file 'templatename' otherwise, template is taken from the Context

Specified by:
execute in interface Command
Overrides:
execute in class AbstractCommand
Parameters:
context - Context to get, compile and execute the commands in the template
Returns:
result of the execution
Throws:
java.lang.Exception

substitute

protected java.lang.String substitute(java.lang.String body)
Find and Replace param references in the template body.

Parameters:
body - original template body
Returns:
substituted template body

removeNonsubstituted

protected java.lang.String removeNonsubstituted(java.lang.String body)
Removes parameter references that were not replaced by new values.

Parameters:
body -
Returns:
body w/removed refs

setParameter

public void setParameter(java.lang.String k,
                         java.lang.Object v)
Sets the (formal, real) parameter pair

Specified by:
setParameter in interface Parametrized
Specified by:
setParameter in class AbstractParametrizedVarCommand
Parameters:
k - Parameter name (key) - formal param. name
v - Parameter value - real param. name
See Also:
Parametrized.setParameter(java.lang.String, java.lang.Object)

setTemplateName

public void setTemplateName(java.lang.String p)
Set the template name

Parameters:
p - template name

toString

public java.lang.String toString()
String repre of DO-TEMPLATE

Overrides:
toString in class java.lang.Object
Returns:
"DO-TEMPLATE " + templateName + " {" + listMap(params) + "}";


Copyright © 2004-2005 Masaryk University in Brno, Faculty of Informatics, Czech Republic. All Rights Reserved.