com.splunk
Class Args

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap<java.lang.String,java.lang.Object>
              extended by com.splunk.Args
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.lang.Object>
Direct Known Subclasses:
CollectionArgs, JobArgs, JobEventsArgs, JobExportArgs, JobResultsArgs, JobResultsPreviewArgs, JobSummaryArgs, SavedSearchDispatchArgs, ServiceArgs

public class Args
extends java.util.LinkedHashMap<java.lang.String,java.lang.Object>

The 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.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
Args()
          Class constructor.
Args(java.util.Map<java.lang.String,java.lang.Object> values)
          Class constructor.
Args(java.lang.String key, java.lang.Object value)
          Class constructor.
 
Method Summary
 Args add(java.lang.String key, java.lang.Object value)
          Adds an argument to an Args object.
static Args create()
          Creates a new empty instance of Args.
static Args create(java.util.Map<java.lang.String,java.lang.Object> values)
          Creates a new Args instance and initializes it with a pre-existing hash map.
static Args create(java.lang.String key, java.lang.Object value)
          Creates a new Args instance and initializes it with a single key-value pair.
 java.lang.String encode()
          Encodes an Args instance into a UTF8-encoded string.
static java.lang.String encode(java.util.Map<java.lang.String,java.lang.Object> args)
          Encodes a hash map of String:String or String:String[] into a single UTF8-encoded string.
static java.lang.String encode(java.lang.String value)
          Encodes a single string with UTF8 encoding.
static
<T> T
get(java.util.Map<java.lang.String,java.lang.Object> args, java.lang.String key, T defaultValue)
          Returns the hash-map value of a specific key, or the default value if the key is not found.
 
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, get, removeEldestEntry
 
Methods inherited from class java.util.HashMap
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

Args

public Args()
Class constructor.


Args

public Args(java.lang.String key,
            java.lang.Object value)
Class constructor. Initializes a single key-value pair.

Parameters:
key - The key name.
value - The value, as a String:String or String:String[].

Args

public Args(java.util.Map<java.lang.String,java.lang.Object> values)
Class constructor. Initializes a pre-existing hash map.

Parameters:
values - A set of key-value pairs.
Method Detail

add

public Args add(java.lang.String key,
                java.lang.Object value)
Adds an argument to an Args object.

Parameters:
key - The key name.
value - The value, as a String:String or String:String[].
Returns:
This Args set.

create

public static Args create()
Creates a new empty instance of Args.

Returns:
The Args instance.

create

public static Args create(java.lang.String key,
                          java.lang.Object value)
Creates a new Args instance and initializes it with a single key-value pair.

Parameters:
key - The key name.
value - The value, as a String:String or String:String[].
Returns:
The Args instance.

create

public static Args create(java.util.Map<java.lang.String,java.lang.Object> values)
Creates a new Args instance and initializes it with a pre-existing hash map.

Parameters:
values - The pre-existing hash map.
Returns:
The Args instance.

encode

public static java.lang.String encode(java.lang.String value)
Encodes a single string with UTF8 encoding.

Parameters:
value - The string.
Returns:
The encoded string.

encode

public static java.lang.String encode(java.util.Map<java.lang.String,java.lang.Object> args)
Encodes a hash map of String:String or String:String[] into a single UTF8-encoded string.

Parameters:
args - The hash map.
Returns:
The string.

encode

public java.lang.String encode()
Encodes an Args instance into a UTF8-encoded string.

Returns:
The UTF8-encoded string.

get

public static <T> T get(java.util.Map<java.lang.String,java.lang.Object> args,
                        java.lang.String key,
                        T defaultValue)
Returns the hash-map value of a specific key, or the default value if the key is not found.

Type Parameters:
T - The class type.
Parameters:
args - The hash map.
key - The key to look for.
defaultValue - The default value, if the key is not found.
Returns:
The value.