public class Args extends LinkedHashMap<String,Object>
Args
class is a helper class for working with Splunk REST API
arguments.
This extension is used mainly for encoding arguments for UTF8 transmission
to a Splunk instance in a key=value pairing for a string, or
key=value1&key=value2
(and so on) for an array of strings.AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
Args()
Class constructor.
|
Args(Map<String,Object> values)
Class constructor.
|
Args(String key,
Object value)
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
Args |
add(String key,
Object value)
Adds an argument to an
Args object. |
static Args |
create()
Creates a new empty instance of
Args . |
static Args |
create(Map<String,Object> values)
Creates a new
Args instance and initializes it with a
pre-existing hash map. |
static Args |
create(String key,
Object value)
Creates a new
Args instance and initializes it with a single
key-value pair. |
String |
encode()
Encodes an
Args instance into a UTF8-encoded string. |
static String |
encode(Map<String,Object> args)
Encodes a hash map of
String:String or String:String[]
into a single UTF8-encoded string. |
static String |
encode(String value)
Encodes a single string with UTF8 encoding.
|
static <T> T |
get(Map<String,Object> args,
String key,
T defaultValue)
Returns the hash-map value of a specific key, or the default value if
the key is not found.
|
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
equals, hashCode, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
public Args()
public Args(String key, Object value)
key
- The key name.value
- The value, as a String:String
or
String:String[]
.public Args add(String key, Object value)
Args
object.key
- The key name.value
- The value, as a String:String
or
String:String[]
.Args
set.public static Args create()
Args
.Args
instance.public static Args create(String key, Object value)
Args
instance and initializes it with a single
key-value pair.key
- The key name.value
- The value, as a String:String
or
String:String[]
.Args
instance.public static Args create(Map<String,Object> values)
Args
instance and initializes it with a
pre-existing hash map.values
- The pre-existing hash map.Args
instance.public static String encode(String value)
value
- The string.public static String encode(Map<String,Object> args)
String:String
or String:String[]
into a single UTF8-encoded string.args
- The hash map.public String encode()
Args
instance into a UTF8-encoded string.public static <T> T get(Map<String,Object> args, String key, T defaultValue)
T
- The class type.args
- The hash map.key
- The key to look for.defaultValue
- The default value, if the key is not found.Copyright © 2022 Splunk, Inc.. All rights reserved.