com.apama.util
Event AnyExtractor


Provides a type-safe way to extract the values from a value of the any type.

It is useful for handling payload generated from connectivity plug-in codecs such as JSON. The value held by the any type value must be of one of the following EPL types: The values held by the sequence and the dictionary must also be of the supported types mentioned above.

It supports "." in the path to extract nested values from the dictionary. It is an error if the path before "." does not result in a dictionary. It also supports "[]" in the path to extract a specific element from the sequence. It is an error if the path before "[]" does not result in a sequence or the value between "[]" is not a valid index. It does not support extracting entries from a dictionary whose key contains special characters like ., [ or ].

No automatic conversions are performed on the values. It is an error to extract the value as an incorrect type.

Examples:

// Return the value held by the event as an integer.
getInteger("");

// Return the value of the entry with "temp" key in the dictionary value held by the event.
getFloat("temp");

// The value held by the event should be a dictionary with an entry for "location" key. The value
// of the entry should also be a dictionary with an entry for "city" key and a string value.
getString("location.city");

// The value held by the event should be a dictionary with an entry for "users" key.
// The value of the entry should be a sequence of dictionaries with at least one value.
// The dictionary value in the sequence should contain an entry for "id" key and an integer value.
getInteger("users[0].id);
Since:
10.1.0.5

Member Summary
 anydata

The value of the any type from which to extract the values. Helper actions with names starting with GET can be used to extract the value and cast it to a specific type.
 
Action Summary
 anygetAny(string path)

Extract the value as any.
 booleangetBoolean(string path)

Extract the value as a boolean. This is equivalent to calling <boolean>getAny(path). It throws CastException if the extracted value is not a boolean.
 dictionary<any, any >getDictionary(string path)

Extract the value as a dictionary<any,any>. This is equivalent to calling <dictionary<any,any> >getAny(path). It throws CastException if the extracted value is not a dictionary<any,any>.
 floatgetFloat(string path)

Extract the value as a float. This is equivalent to calling <float>getAny(path). It throws CastException if the extracted value is not a float.
 integergetInteger(string path)

Extract the value as an integer. This is equivalent to calling <integer>getAny(path). It throws CastException if the extracted value is not an integer.
 sequence<any >getSequence(string path)

Extract the value as a sequence<any>. This is equivalent to calling <sequence<any> >getAny(path). It throws CastException if the extracted value is not a sequence<any>.
 stringgetString(string path)

Extract the value as a string. This is equivalent to calling <string>getAny(path). It throws CastException if the extracted value is not a string.
 
Member Detail

data

any data
The value of the any type from which to extract the values. Helper actions with names starting with GET can be used to extract the value and cast it to a specific type.

Use "" as the path to simply return this value as the specified type.
See Also:
com.apama.util.AnyExtractor#getInteger() - Use getInteger() to extract the value as an integer.
com.apama.util.AnyExtractor#getFloat() - Use getFloat() to extract the value as a float.
com.apama.util.AnyExtractor#getString() - Use getSequence() to extract the value as a string.
com.apama.util.AnyExtractor#getSequence() - Use getSequence() to extract the value as a sequence<any>.
com.apama.util.AnyExtractor#getDictionary() - Use getDictionary() to extract the value as a dictionary<any,any>.
com.apama.util.AnyExtractor#getAny() - Use getAny() to extract the value as an any.

Action Detail

getAny

any getAny(string path)
Extract the value as any.

It throws exception in following cases:
  • Throws CastException if the values resulted before "." or "[]" are not of dictionary<any,any> and sequence<any> type respectively.
  • Throws IllegalArgumentException if the entry in the dictionary does not exist or an unmatched subscripts operator is used.
  • Throws ParseException if the subscripts operator does not specify integer value.
  • Throws IndexOutOfBoundsException if the subscripts operator specify integer value which is not a valid index for the sequence.
  • Parameters:
    path - The path to the value to extract. Use "" to return the value held. Use "." to extract entries from a dictionary and use "[]" to extract elements from a sequence.
    Returns:
    The extracted value.
    Since:
    10.1.0.5

    getBoolean

    boolean getBoolean(string path)
    Extract the value as a boolean. This is equivalent to calling <boolean>getAny(path). It throws CastException if the extracted value is not a boolean.
    Parameters:
    path - The path to the value to extract. Use "" to return the value held. Use "." and "[]" to extract the values from a dictionary and a sequence respectively.
    Returns:
    The extracted value.
    Since:
    10.1.0.5
    See Also:
    com.apama.util.AnyExtractor#getAny() - Use getAny() to extract the value as an any.

    getDictionary

    dictionary<any, any > getDictionary(string path)
    Extract the value as a dictionary<any,any>. This is equivalent to calling <dictionary<any,any> >getAny(path). It throws CastException if the extracted value is not a dictionary<any,any>.
    Parameters:
    path - The path to the value to extract. Use "" to return the value held. Use "." and "[]" to extract the values from a dictionary and a sequence respectively.
    Returns:
    The extracted value.
    Since:
    10.1.0.5
    See Also:
    com.apama.util.AnyExtractor#getAny() - Use getAny() to extract the value as an any.

    getFloat

    float getFloat(string path)
    Extract the value as a float. This is equivalent to calling <float>getAny(path). It throws CastException if the extracted value is not a float.
    Parameters:
    path - The path to the value to extract. Use "" to return the value held. Use "." and "[]" to extract the values from a dictionary and a sequence respectively.
    Returns:
    The extracted value.
    Since:
    10.1.0.5
    See Also:
    com.apama.util.AnyExtractor#getAny() - Use getAny() to extract the value as an any.

    getInteger

    integer getInteger(string path)
    Extract the value as an integer. This is equivalent to calling <integer>getAny(path). It throws CastException if the extracted value is not an integer.
    Parameters:
    path - The path to the value to extract. Use "" to return the value held. Use "." and "[]" to extract the values from a dictionary and a sequence respectively.
    Returns:
    The extracted value.
    Since:
    10.1.0.5
    See Also:
    com.apama.util.AnyExtractor#getAny() - Use getAny() to extract the value as an any.

    getSequence

    sequence<any > getSequence(string path)
    Extract the value as a sequence<any>. This is equivalent to calling <sequence<any> >getAny(path). It throws CastException if the extracted value is not a sequence<any>.
    Parameters:
    path - The path to the value to extract. Use "" to return the value held. Use "." and "[]" to extract the values from a dictionary and a sequence respectively.
    Returns:
    The extracted value.
    Since:
    10.1.0.5
    See Also:
    com.apama.util.AnyExtractor#getAny() - Use getAny() to extract the value as an any.

    getString

    string getString(string path)
    Extract the value as a string. This is equivalent to calling <string>getAny(path). It throws CastException if the extracted value is not a string.
    Parameters:
    path - The path to the value to extract. Use "" to return the value held. Use "." and "[]" to extract the values from a dictionary and a sequence respectively.
    Returns:
    The extracted value.
    Since:
    10.1.0.5
    See Also:
    com.apama.util.AnyExtractor#getAny() - Use getAny() to extract the value as an any.