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));
 }
 


Field Summary
 Object value
          Use this to return values the old fashoned way.
 
Constructor Summary
ParameterSubstitution(String pattern)
          This constructor parses the pattern string for use in subsequent substitute calls.
ParameterSubstitution(String pattern, int type)
          This constructor parses the pattern string for special use.
 
Method Summary
 Object[] getPreparedArgList(Map<String,Object> params)
          Builds an array of objects based for prepared statements
 String getPreparedArgName(int index)
          Return the name for the n'th prepared argument
static void main(String[] args)
           
 String substitute(Map<String,Object> params)
          This method expands the current pattern string using params as source for substitution values.
 String substitute(Map<String,Object> params, List<String> incref)
           
static String substitute(String pattern, Map<String,Object> params)
          This method performs a one-time parsing and substitution of pattern with the objects available in params.
static String substitute(String pattern, Map<String,Object> params, List<String> 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
 

Field Detail

value

public Object value
Use this to return values the old fashoned way. It is better to use return someValue;

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

ParameterSubstitution

public ParameterSubstitution(String pattern,
                             int type)
                      throws Exception
This constructor parses the pattern string for special use.

Parameters:
pattern - The pattern string to expand
type - 0=normal, 1=JDBC Prepared statement
Throws:
Exception
Since:
7.0
Method Detail

substitute

public String substitute(Map<String,Object> 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<String,Object> params,
                         List<String> incref)
                  throws Exception
Throws:
Exception

substitute

public static String substitute(String pattern,
                                Map<String,Object> 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<String,Object> params,
                                List<String> 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) "
cref - The list of previously used config object expressions (avoid circular references)
Returns:
The expanded string
Throws:
Exception

getPreparedArgList

public Object[] getPreparedArgList(Map<String,Object> params)
                            throws Exception
Builds an array of objects based for prepared statements

Parameters:
params -
Returns:
the resultant array of objects
Throws:
Exception
Since:
7.0

getPreparedArgName

public String getPreparedArgName(int index)
Return the name for the n'th prepared argument


main

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