org.abstracthorizon.danube.http.util
Interface MultiStringMap

All Known Implementing Classes:
MultiStringHashMap

public interface MultiStringMap

This is interface defining a map that can, for a value, have one or more strings. It is used for request or response headers or request parameters.

Author:
Daniel Sendula

Method Summary
 void add(String id, String value)
          Adds new element to the map.
 void addAll(String id, Collection<String> values)
          Adds all elements from the given collection
 void addAll(String id, String[] values)
          Adds all elements from the given array.
 void clear()
          Clears the map
 boolean containsKey(String id)
          Returns true if there is at least one entry
 Collection<Map.Entry<String,String>> getAllEntries()
          Returns list of all entries.
 String[] getAsArray(String id)
          Returns array of all elements under asked key.
 List<String> getAsList(String id)
          Returns list of all elements under asked key.
 Map<String,Object> getAsMap()
          Returns a map that contains all elements.
 int getEntrySize(String id)
          Returns number of entries for given key
 String getFirst(String id)
          Retrieves first element from the given key.
 String getOnly(String id)
          Retrieves element from the given key.
 Set<String> keySet()
          Returns key set
 void putAll(String id, Collection<String> values)
          Replaces existing element(s), if there are any under the given key, with the given values.
 void putAll(String id, String[] values)
          Replaces existing element(s), if there are any under the given key, with the given values.
 void putOnly(String id, String value)
          Replaces existing element(s), if there are any under the given key, with the given value.
 String remove(String id, int index)
          Removes n-th element from the given key.
 Collection<String> removeAll(String id)
          Removes all elements from the given key
 String removeFirst(String id)
          Removes first element from the given key.
 int size()
          Number of keys in the map.
 

Method Detail

add

void add(String id,
         String value)
Adds new element to the map. If no entries with given id exist than this is going to be the first. If there are already values under given id then this is going to be added as a new one

Parameters:
id - key
value - value to be added

addAll

void addAll(String id,
            String[] values)
Adds all elements from the given array.

Parameters:
id - key
values - array of values
See Also:
add(String, String)

addAll

void addAll(String id,
            Collection<String> values)
Adds all elements from the given collection

Parameters:
id - key
values - collection which elements are to be added
See Also:
add(String, String)

putOnly

void putOnly(String id,
             String value)
Replaces existing element(s), if there are any under the given key, with the given value.

Parameters:
id - key
value - value to be put to the map

putAll

void putAll(String id,
            String[] values)
Replaces existing element(s), if there are any under the given key, with the given values.

Parameters:
id - key
values - values to be put to the map
See Also:
putOnly(String, String)

putAll

void putAll(String id,
            Collection<String> values)
Replaces existing element(s), if there are any under the given key, with the given values.

Parameters:
id - key
values - collection of values to be put to the map
See Also:
putOnly(String, String)

removeAll

Collection<String> removeAll(String id)
Removes all elements from the given key

Parameters:
id - key

removeFirst

String removeFirst(String id)
Removes first element from the given key. If there was only one element then there will be no more elements under the given key

Parameters:
id - key

remove

String remove(String id,
              int index)
Removes n-th element from the given key.

Parameters:
id - key
index - index of the element to be removed
Throws:
IndexOutOfBoundsException - if there are no elements under the given key

containsKey

boolean containsKey(String id)
Returns true if there is at least one entry

Parameters:
id - key
Returns:
true if there is at least one entry

getEntrySize

int getEntrySize(String id)
Returns number of entries for given key

Parameters:
id - key
Returns:
number of entries for given key

getOnly

String getOnly(String id)
Retrieves element from the given key. Key must have only one element (or none) for this method to work.

Parameters:
id - key of the asked element
Returns:
element
Throws:
IllegalStateException - if there are more then one element under this key

getFirst

String getFirst(String id)
Retrieves first element from the given key.

Parameters:
id - key of the asked element
Returns:
element or null if there are no elements given

getAsArray

String[] getAsArray(String id)
Returns array of all elements under asked key. If there are no elements then it returns an empty array.

Parameters:
id - key of the asked elements
Returns:
an array of strings

getAsList

List<String> getAsList(String id)
Returns list of all elements under asked key. If there are no elements then it returns an empty list.

Parameters:
id - key of the asked elements
Returns:
a list of strings

clear

void clear()
Clears the map


getAllEntries

Collection<Map.Entry<String,String>> getAllEntries()
Returns list of all entries. Entries with the same key will repeat if there are more elements stored under the same key.

Returns:
list of all entries

keySet

Set<String> keySet()
Returns key set

Returns:
key set

getAsMap

Map<String,Object> getAsMap()
Returns a map that contains all elements. Where there are more elements per key then implementation is responsiple of returning something sensible like an array of strings or a collection (or a list) whose elements are strings

Returns:
a map

size

int size()
Number of keys in the map. It won't return total number of elements but just number of differnet keys in the map.

Returns:
number of keys in the map


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.