Container Object
Use
This object enables you to cache the values that you want to read again when you next call the same user-defined function. An instance of the container object is transferred to each user-specific function by using thecontainerparameter.
Integration
When using the container object, you do not just temporarily save values for a user-defined function, you also access the following objects as well:
MappingTrace object to write messages to the trace.
GlobalContainer object to exchange values between different user-defined functions.
Map object to access mapping runtime constants.
The following figure shows how the GlobalContainer and Container objects access mapping runtime constants.
Features
|
Method(s) |
Use |
|---|---|
|
void setParameter (String parName, Object obj); |
Saves theobjobject under the nameparNamein a container for a user-specific function. |
|
Object getParameter (String parName); |
Returns the parameter that was saved under theparNamename in this user-specific function by using thesetParametermethod. If no such parameter exists,getParameterreturnsnull |
|
AbstractTrace getTrace(); |
Returns a MappingTrace object with which you can transfer messages to the mapping trace. |
|
GlobalContainer getGlobalContainer(); |
Returns a GlobalContainer object with which you can save the values that can be read by any user-specific functions in the same message mapping. |
|
java.util.Map container.getTransformationParameters() |
Returns a map with the mapping runtime constants. For a description of which constants you can access by using this map, see Java Mapping . The constants are attributes of the class com.sap.aii.mapping.api.StreamTransformationConstants(also see the example below). |
Example
The following source code queries the constantINTERFACE_NAMESPACEin a user-defined function, displays it as information by using the MappingTrace object and returns it as a result of the function:
AbstractTrace trace; String headerField; java.util.Map map;
trace = container.getTrace();
// get constant map map = container.getTransformationParameters();
headerField = (String) map.get( StreamTransformationConstants.INTERFACE_NAMESPACE); 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 .