Use
This object enables you to cache the values that you want to read again when you next call any user-defined function in the same message mapping. Note that the sequence in which user-defined functions are called is predefined. It depends on the position of the target fields that the function was assigned to.
Imagine a target structure in the mapping editor in which all the structure nodes have been expanded. The fields are processed from top to bottom, starting at the root node.
Furthermore, in the same as for the Container object, you can also access the fields of the message header by using the GlobalContainer object.
Integration
To get a global container object, call the getGlobalContainer() method for the Container Object.
Features
Methods of the GlobalContainer Object
Method | Use |
void | Saves the obj object under the parName name in a global container, which can be accessed by all user-specific functions of a message mapping. |
Object | Returns the object that was saved under the parName name in the global container by using the setParameter method. If no such parameter exists, getParameter returns null. |
Map getParameters(); | Returns a Map for accessing fields of the message header. You access the fields in the same way as described in the example in Container Object. |
Example
The following example only details the use of getParameters(). The source code queries the constant INTERFACE_NAMESPACEin a user-defined function, displays it as information by using the MappingTrace object and returns it as a result of the function:
GlobalContainer globalContainer;
AbstractTrace trace;
String headerField;
java.util.Map map;
// Get trace using the container object
// (which is passed by parameter ‘container’
// to this user-defined function)
trace = container.getTrace();
// To get a global container, use method getGlobalContainer()
// of the container object
globalContainer = container.getGlobalContainer();
// There are two ways of getting the runtime constant map now:
// a) by calling container.getTransformationParameters() or
// b) by calling globalContainer.getParameters().
map = globalContainer.getParameters();
// get the value for a header field
headerField = (String) map.get(
StreamTransformationConstants.INTERFACE_NAMESPACE);
// output value to trace and return it
trace.addInfo("INTERFACE_NAMESPACE:" + headerField);
return headerField;
At design time, the mapping runtime constants do not yet have any values. Therefore, the mapping editor only displays a test string for each constant in the test environment.
See also: Special Access to Mapping Runtime Constants.
No comments:
Post a Comment