com.splunk
Class ResourceCollection<T extends Resource>

java.lang.Object
  extended by com.splunk.Resource
      extended by com.splunk.ResourceCollection<T>
Type Parameters:
T - The type of members of the collection.
All Implemented Interfaces:
java.util.Map<java.lang.String,T>
Direct Known Subclasses:
ConfCollection, EntityCollection

public class ResourceCollection<T extends Resource>
extends Resource
implements java.util.Map<java.lang.String,T>

The ResourceCollection class represents a collection of Splunk resources.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
protected  java.lang.Class itemClass
           
protected  java.util.Map<java.lang.String,T> items
           
 
Fields inherited from class com.splunk.Resource
actions, path, service, title
 
Method Summary
 void clear()
          
 boolean containsKey(java.lang.Object key)
          
 boolean containsValue(java.lang.Object value)
          
protected  T createItem(AtomEntry entry)
          Creates a collection member (or item) corresponding to a given Atom entry.
protected  T createItem(java.lang.Class itemClass, java.lang.String path)
          Creates a collection member (or item).
 java.util.Set<java.util.Map.Entry<java.lang.String,T>> entrySet()
          
 boolean equals(java.lang.Object o)
          
 T get(java.lang.Object key)
          
 int hashCode()
           
 boolean isEmpty()
          
protected  java.lang.String itemKey(AtomEntry entry)
          Returns the value to use as the item key from a given Atom entry.
protected  java.lang.String itemPath(AtomEntry entry)
          Returns the value to use as the item path from a given Atom entry.
 java.util.Set<java.lang.String> keySet()
          
 ResponseMessage list()
          Issues an HTTP request to list the contents of the collection resource.
 T put(java.lang.String key, T value)
          
 void putAll(java.util.Map<? extends java.lang.String,? extends T> map)
          Copies all mappings from a given map to this map (unsupported).
 ResourceCollection refresh()
          Refreshes the local state of this resource.
 T remove(java.lang.Object key)
          
 int size()
          
 ResourceCollection<T> validate()
          Ensures that the local state of the resource is current, invoking refresh if necessary.
 java.util.Collection<T> values()
          
 
Methods inherited from class com.splunk.Resource
getActions, getName, getPath, getService, getTitle, invalidate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

items

protected java.util.Map<java.lang.String,T extends Resource> items

itemClass

protected java.lang.Class itemClass
Method Detail

clear

public void clear()

Specified by:
clear in interface java.util.Map<java.lang.String,T extends Resource>

containsKey

public boolean containsKey(java.lang.Object key)

Specified by:
containsKey in interface java.util.Map<java.lang.String,T extends Resource>

containsValue

public boolean containsValue(java.lang.Object value)

Specified by:
containsValue in interface java.util.Map<java.lang.String,T extends Resource>

createItem

protected T createItem(java.lang.Class itemClass,
                       java.lang.String path)
Creates a collection member (or item).

Parameters:
itemClass - The class of the member to create.
path - The path to the member resource.
Returns:
The new member.

createItem

protected T createItem(AtomEntry entry)
Creates a collection member (or item) corresponding to a given Atom entry. This base implementation uses the class object that was passed in when the generic ResourceCollection was created. Subclasses may override this method to provide alternative means of instantiating collection items.

Parameters:
entry - The AtomEntry corresponding to the member to instantiate.
Returns:
The new member.

entrySet

public java.util.Set<java.util.Map.Entry<java.lang.String,T>> entrySet()

Specified by:
entrySet in interface java.util.Map<java.lang.String,T extends Resource>

equals

public boolean equals(java.lang.Object o)

Specified by:
equals in interface java.util.Map<java.lang.String,T extends Resource>
Overrides:
equals in class java.lang.Object

get

public T get(java.lang.Object key)

Specified by:
get in interface java.util.Map<java.lang.String,T extends Resource>

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map<java.lang.String,T extends Resource>
Overrides:
hashCode in class java.lang.Object

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface java.util.Map<java.lang.String,T extends Resource>

itemKey

protected java.lang.String itemKey(AtomEntry entry)
Returns the value to use as the item key from a given Atom entry. Subclasses may override this value for collections that use something other than title as the key.

Parameters:
entry - The AtomEntry corresponding to the collection member.
Returns:
The value to use as the member's key.

itemPath

protected java.lang.String itemPath(AtomEntry entry)
Returns the value to use as the item path from a given Atom entry. Subclasses may override this value to support alternative methods of determining a member's path.

Parameters:
entry - The AtomEntry corresponding to the collection member.
Returns:
The value to use as the member's path.

keySet

public java.util.Set<java.lang.String> keySet()

Specified by:
keySet in interface java.util.Map<java.lang.String,T extends Resource>

list

public ResponseMessage list()
Issues an HTTP request to list the contents of the collection resource.

Returns:
The list response message.

put

public T put(java.lang.String key,
             T value)

Specified by:
put in interface java.util.Map<java.lang.String,T extends Resource>

putAll

public void putAll(java.util.Map<? extends java.lang.String,? extends T> map)
Copies all mappings from a given map to this map (unsupported).

Specified by:
putAll in interface java.util.Map<java.lang.String,T extends Resource>
Parameters:
map - The set of mappings to copy into this map.

refresh

public ResourceCollection refresh()
Refreshes the local state of this resource.

Specified by:
refresh in class Resource
Returns:
The current Resource instance.

remove

public T remove(java.lang.Object key)

Specified by:
remove in interface java.util.Map<java.lang.String,T extends Resource>

size

public int size()

Specified by:
size in interface java.util.Map<java.lang.String,T extends Resource>

validate

public ResourceCollection<T> validate()
Ensures that the local state of the resource is current, invoking refresh if necessary.

Overrides:
validate in class Resource
Returns:
The current Resource instance.

values

public java.util.Collection<T> values()

Specified by:
values in interface java.util.Map<java.lang.String,T extends Resource>