Package com.ibm.di.util
Class ParameterSubstitution
- java.lang.Object
-
- com.ibm.di.util.ParameterSubstitution
-
public class ParameterSubstitution extends java.lang.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
Fields Modifier and Type Field Description java.lang.Object
value
Use this to return values the old fashoned way.
-
Constructor Summary
Constructors Constructor Description ParameterSubstitution(java.lang.String pattern)
This constructor parses the pattern string for use in subsequent substitute calls.ParameterSubstitution(java.lang.String pattern, int type)
This constructor parses the pattern string for special use.ParameterSubstitution(java.lang.String pattern, java.util.Map<java.lang.String,java.lang.Object> params)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object[]
getPreparedArgList(java.util.Map<java.lang.String,java.lang.Object> params)
Builds an array of objects based for prepared statementsjava.lang.String
getPreparedArgName(int index)
Return the name for the n'th prepared argumentstatic void
main(java.lang.String[] args)
static java.lang.String
substitute(java.lang.String pattern, java.util.Map<java.lang.String,java.lang.Object> params)
This method performs a one-time parsing and substitution of pattern with the objects available in params.static java.lang.String
substitute(java.lang.String pattern, java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<java.lang.String> cref)
This method performs a one-time parsing and substitution of pattern with the objects available in params.java.lang.String
substitute(java.util.Map<java.lang.String,java.lang.Object> params)
This method expands the current pattern string using params as source for substitution values.java.lang.String
substitute(java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<java.lang.String> incref)
-
-
-
Constructor Detail
-
ParameterSubstitution
public ParameterSubstitution(java.lang.String pattern) throws java.lang.Exception
This constructor parses the pattern string for use in subsequent substitute calls.- Parameters:
pattern
- The pattern string to expand- Throws:
java.lang.Exception
-
ParameterSubstitution
public ParameterSubstitution(java.lang.String pattern, int type) throws java.lang.Exception
This constructor parses the pattern string for special use.- Parameters:
pattern
- The pattern string to expandtype
- 0=normal, 1=JDBC Prepared statement- Throws:
java.lang.Exception
- Since:
- 7.0
-
ParameterSubstitution
public ParameterSubstitution(java.lang.String pattern, java.util.Map<java.lang.String,java.lang.Object> params) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-
Method Detail
-
substitute
public java.lang.String substitute(java.util.Map<java.lang.String,java.lang.Object> params) throws java.lang.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:
java.lang.Exception
-
substitute
public java.lang.String substitute(java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<java.lang.String> incref) throws java.lang.Exception
- Throws:
java.lang.Exception
-
substitute
public static java.lang.String substitute(java.lang.String pattern, java.util.Map<java.lang.String,java.lang.Object> params) throws java.lang.Exception
This method performs a one-time parsing and substitution of pattern with the objects available in params.- Parameters:
pattern
- The pattern string to expandparams
- The available objects (e.g. conn, work, task etc)- Returns:
- The expanded string
- Throws:
java.lang.Exception
-
substitute
public static java.lang.String substitute(java.lang.String pattern, java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<java.lang.String> cref) throws java.lang.Exception
This method performs a one-time parsing and substitution of pattern with the objects available in params.- Parameters:
pattern
- The pattern string to expandparams
- 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:
java.lang.Exception
-
getPreparedArgList
public java.lang.Object[] getPreparedArgList(java.util.Map<java.lang.String,java.lang.Object> params) throws java.lang.Exception
Builds an array of objects based for prepared statements- Parameters:
params
-- Returns:
- the resultant array of objects
- Throws:
java.lang.Exception
- Since:
- 7.0
-
getPreparedArgName
public java.lang.String getPreparedArgName(int index)
Return the name for the n'th prepared argument
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-