Developing Apama Applications > Developing Apama Applications in EPL > Using Correlator Plug-ins in EPL > Using the Payload Extraction plug-in > The indirect-access functions
The indirect-access functions
The advantage of the direct-access functions is that they are straightforward to use. They parse through the payload on every call, so they are also the most appropriate functions to utilize if you only need to access a single field from within the payload.
However, if it is required to access several fields from within the payload or even the same fields repeatedly, it is more appropriate to use the indirect-access functions. In this case the payload is parsed only once, and a highly optimized representation of its contents is generated. This makes subsequent field access very fast, and the difference in performance over the direct access functions can be considerable, particularly if the payload contains a very large number of fields.
To use the indirect access functions you must first call parsePayload(>payload_field), which returns a chunk object.
The parameters for the indirect-access functions have the same meaning as for the direct-access function parameters; see Parameters for primary direct-access functions.
The primary indirect-access functions are described in the following sections.
getString
string getString(
chunk payload_chunk,
string field_name,
string default_value)
Access the chunk specified in payload_chunk, retrieve the field called field_name, and return its contents as a string. If the field does not exist, is empty, or is invalid, return the string literal specified in default_value.
getFloat
float getFloat(
chunk payload_chunk,
string field_name,
float default_value)
Access the chunk specified in payload_chunk, retrieve the field called field_name, and return its contents as a float. If the field does not exist, is empty, is invalid, or cannot be cast to a valid float, return the float value specified in default_value.
getInteger
integer getInteger(
chunk payload_chunk,
string field_name,
integer default_value)
Access the chunk specified in payload_chunk, retrieve the field called field_name, and return its contents as a integer. If the field does not exist, is empty, is invalid, or cannot be cast to a valid integer, return the integer value specified in default_value.
getBoolean
boolean getBoolean(
chunk payload_chunk,
string field_name,
boolean default_value)
Access the chunk specified in payload_chunk, retrieve the field called field_name, and return its contents as a boolean. If the field does not exist, is empty, is invalid, or cannot be cast to a valid boolean, return the boolean value specified in default_value.
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.