public class Event extends HashMap<String,String>
Event
class wraps an individual event or result that was returned
by the ResultsReader.getNextEvent()
method.
An event maps each field name to a list of zero of more values.
These values can be accessed as either an array (using the getArray(java.lang.String)
method) or as a delimited string (using the get(java.lang.String)
method). We
recommend accessing values as an array when possible.
The delimiter for field values depends on the underlying result format.
If the underlying format does not specify a delimiter, such as with the
ResultsReaderXml
class, the delimiter is a comma (,).
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Method and Description |
---|---|
void |
clear() |
Object |
clone() |
String |
get(String key)
Returns the single value or delimited set of values for the specified
field name, or
null if the specified field is not present. |
String[] |
getArray(String key)
Gets the values for the specified field name.
|
String[] |
getArray(String key,
String delimiter)
Gets the values for the specified field name.
|
String |
getSegmentedRaw()
Gets the XML markup for the
"_raw" field value. |
String |
put(String key,
String value) |
void |
putAll(Map<? extends String,? extends String> m) |
String |
remove(Object key) |
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putIfAbsent, remove, replace, replace, replaceAll, size, values
equals, hashCode, toString
public String get(String key)
null
if the specified field is not present.
When getting a multi-valued field, use the getArray(String)
or
getArray(String, String)
method instead.key
- The field name.public String[] getArray(String key)
getArray(String, String)
is
unsafe for ResultsReader
implementations that require a
delimiter. Therefore, this method should only be used for results that
are returned by ResultsReaderXml
. For other readers, use the
getArray(String, String)
method instead.
ResultsReader
object has no delimiter, the
original array of values is returned. If the object does have a
delimiter, the single/delimited value is assumed to be a single value and
is returned as a single-valued array.key
- The field name.public String[] getArray(String key, String delimiter)
Event
object.
The delimiter is ignored for ResultsReader
implementations
that do not require a delimiter, such as ResultsReaderXml
.
If the underlying ResultsReader
object has no delimiter, the
original array of values is returned (and the specified delimiter is
ignored). If the object does have a delimiter, the
single/delimited value is split based on the specified delimiter and is
returned as an array.key
- The field name.delimiter
- The delimiter.public String getSegmentedRaw()
"_raw"
field value. This value
is only used by the ResultsReaderXml
class.
The return value is different than that of get("_raw")
in that this segmented raw value is an XML fragment that includes all
markup such as XML tags and escaped characters.
For example, get("_raw")
returns this:
"http://localhost:8000/en-US/app/search/flashtimeline?q=search%20search%20index%3D_internal%20%7C%20head%2010&earliest=rt-1h&latest=rt"
The getSegmentedRaw
method returns this:
<v xml:space="preserve" trunc="0">"http://localhost:8000/en-US/app/<sg h=\"1\">search</sg>/flashtimeline?q=<sg h=\"1\">search</sg>%20<sg h=\"1\">search</sg>%20index%3D_internal%20%7C%20head%2010&earliest=rt-1h&latest=rt"</v>
public void clear()
Copyright © 2022 Splunk, Inc.. All rights reserved.