com.ibm.di.util
Class ParameterSubstitution

java.lang.Object
  extended by com.ibm.di.util.ParameterSubstitution

public class ParameterSubstitution
extends Object

This class provides the "Parameter Substitution" features of TDI. If you are expanding a pattern only once you can use the static method. If you expand a pattern more than once using different params, you could create an instance and call substitute(Map) to avoid parsing the template for every call. The substitute call uses a Map object where you provide the available objects for pattern expansion. You should at least provide "mc=MetamergeConfig" or "config=BaseConfiguration" object, otherwise expansion of TDI-properties will not work. If you want to expand alcomponent parameters, you need to provide a "config=BaseConfiguration" object.

     expression = system.getTDIExpression("{work.cn} {property.myprop}");
     map = new java.util.HashMap();
     map.put("mc", main.getMetamergeConfig());
     
     while ( (work = nextentry()) != null ) {
       map.put("work", work);
       task.logmsg(expression.substitute(map));
     }
 


Constructor Summary
ParameterSubstitution(String pattern)
          This constructor parses the pattern string for use in subsequent substitute calls.
 
Method Summary
static void main(String[] args)
           
 String substitute(Map params)
          This method expands the current pattern string using params as source for substitution values.
 String substitute(Map params, List incref)
           
static String substitute(String pattern, Map params)
          This method performs a one-time parsing and substitution of pattern with the objects available in params.
static String substitute(String pattern, Map params, List cref)
          This method performs a one-time parsing and substitution of pattern with the objects available in params.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterSubstitution

public ParameterSubstitution(String pattern)
                      throws Exception
This constructor parses the pattern string for use in subsequent substitute calls.

Parameters:
pattern - The pattern string to expand
Throws:
Exception
Method Detail

substitute

public String substitute(Map params)
                  throws Exception
This method expands the current pattern string using params as source for substitution values.

Parameters:
params - The available objects (e.g. conn, work, task etc)
Returns:
A string resulting from the pattern expansion (which may be empty, null is never returned)
Throws:
Exception

substitute

public String substitute(Map params,
                         List incref)
                  throws Exception
Throws:
Exception

substitute

public static String substitute(String pattern,
                                Map params)
                         throws Exception
This method performs a one-time parsing and substitution of pattern with the objects available in params.

Parameters:
pattern - The pattern string to expand
params - The available objects (e.g. conn, work, task etc)
Returns:
The expanded string
Throws:
Exception

substitute

public static String substitute(String pattern,
                                Map params,
                                List cref)
                         throws Exception
This method performs a one-time parsing and substitution of pattern with the objects available in params.

Parameters:
pattern - The pattern string to expand
params - The available objects (e.g. conn, work, task etc) " @param cref The list of previously used config object expressions (avoid circular references)
Returns:
The expanded string
Throws:
Exception

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception