//Source file: H:\\TEMP\\generated\\ispuml\\mdaTransformation\\rules\\codeGenerator\\VelocityTemplateDirectives.java
package modTransf.rules.codeGenerator;
import java.util.Collection;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.Arrays;
import modTransf.engine.RuleContext;
import modTransf.engine.TransformationException;
import modTransf.engine.Arguments;
import modTransf.engine.ArrayArguments;
/**
* The directives or methods available from within velocity templates.
* This class extends the VelocityContext in order to be able to access (get)
* the current RuleContext.
* @todo Implements the callRule method.
*/
public class VelocityTemplateDirectives extends VelocityContext
{
/**
* Constructor.
* @param bean
* @param request
*/
public VelocityTemplateDirectives(RuleContext request)
{
super(request);
}
/**
* Call a specified rule.
* @param args
*/
public void callRule(Object args, String ruleName )
//throws TransformationException
{
RuleContext request = getRuleContext();
System.out.println("generate.callRule(" + args + ", " + ruleName + ")" );
// try
// {
// //System.out.println("Translated args " + getModelConcepts(args) + ")" );
// request.engineContext.getEngine().transform( getModelConcepts(args),
// request,
// null,
// ruleName,
// MappingRuleEngine.AUTO_TRANSFORMATION );
// }
// catch( TransformationException ex )
// {
// System.out.println("generate exception:");
// ex.printStackTrace();
// //throw ex;
// }
// catch( Exception ex )
// {
// System.out.println("generate exception:");
// ex.printStackTrace();
// //throw ex;
// }
}
/**
* Get the properties from the String args.
* @param arg
* @return
*/
protected Object getModelConcepts( Object arg )
throws TransformationException
{
// if( arg.getClass().isArray() )
// {
// PropertyValues argRes = new PropertyValues();
// Iterator iter = Arrays.asList((Object[])arg).iterator();
// while( iter.hasNext() )
// {
// argRes.add( getRuleContext().getAttributeProperty( (String)iter.next() ) );
// } // end loop
// }
//
// else if( arg instanceof Collection )
// {
// PropertyValues argRes = new PropertyValues();
// Iterator iter = ((Collection)arg).iterator();
// while( iter.hasNext() )
// {
// argRes.add( getRuleContext().getAttributeProperty( (String)iter.next() ) );
// } // end loop
// }
//
// else if( arg instanceof String )
// {
// return getRuleContext().getAttributeProperty( (String)arg );
// }
//
// return arg;
return null;
}
/** The unique instance of the class*/
//protected static VelocityTemplateDirectives instance;
/**
* @return VelocityTemplateDirectives
*/
/* static public VelocityTemplateDirectives getInstance()
{
if(instance==null)
instance= new VelocityTemplateDirectives();
return instance;
}
*/
}