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:

any data;

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

// Return the value of the entry with "temp" key in the dictionary value held by the event.
AnyExtractor(data).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.
AnyExtractor(data).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.
AnyExtractor(data).getInteger("users[0].id");
Since:
10.2

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).
 dictionary<anyany>getDictionary(string path)

Extract the value as a dictionary<any,any>. This is equivalent to calling <dictionary<any,any> >getAny(path).
 floatgetFloat(string path)

Extract the value as a float. This is equivalent to calling <float>getAny(path).
 integergetInteger(string path)

Extract the value as an integer. This is equivalent to calling <integer>getAny(path).
 sequence<any>getSequence(string path)

Extract the value as a sequence<any>. This is equivalent to calling <sequence<any> >getAny(path).
 stringgetString(string path)

Extract the value as a string. This is equivalent to calling <string>getAny(path).
 
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.
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.
Throws:
Throws CastException if the values resulted before "." or "[]" are not of dictionary<any,any> and sequence<any> type respectively.

getBoolean

boolean getBoolean(string path)
Extract the value as a boolean. This is equivalent to calling <boolean>getAny(path).
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.
Throws:
Throws CastException if the extracted value is not a boolean.
See Also:
com.apama.util.AnyExtractor#getAny() - Use getAny() to extract the value as an any.

getDictionary

dictionary<anyanygetDictionary(string path)
Extract the value as a dictionary<any,any>. This is equivalent to calling <dictionary<any,any> >getAny(path).
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.
Throws:
Throws CastException if the extracted value is not a dictionary<any,any>.
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).
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.
Throws:
Throws CastException if the extracted value is not a float.
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).
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.
Throws:
Throws CastException if the extracted value is not an integer.
See Also:
com.apama.util.AnyExtractor#getAny() - Use getAny() to extract the value as an any.

getSequence

sequence<anygetSequence(string path)
Extract the value as a sequence<any>. This is equivalent to calling <sequence<any> >getAny(path).
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.
Throws:
Throws CastException if the extracted value is not a sequence<any>.
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).
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.
Throws:
Throws CastException if the extracted value is not a string.
See Also:
com.apama.util.AnyExtractor#getAny() - Use getAny() to extract the value as an any.