public class KVList extends java.lang.Object implements java.lang.Iterable<KVList.Pair>
Modifier and Type | Class and Description |
---|---|
private static class |
KVList.EmptyIterator<E>
small class implementing an iterator for no elements
|
static class |
KVList.Pair
small class holding a key value pair (used for the iterator
|
private static class |
KVList.RemoveDisabledIterator<E>
small wrapper class of an Iterator the suppresses the use of the
remove method
|
private static class |
KVList.SingletonIterator<E>
small class representing a singleton iterator
|
static interface |
KVList.Value
public interface to values.
|
protected static class |
KVList.ValueImpl
inner class that implements a value
|
Modifier and Type | Field and Description |
---|---|
private java.util.LinkedHashMap<java.lang.String,KVList.ValueImpl> |
pairs
all key value pairs
|
Constructor and Description |
---|
KVList()
constructor
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String key,
java.util.Collection<java.lang.String> col)
add a collection of values for the given key
|
void |
add(java.lang.String key,
java.lang.String... values)
add all values for the given key
|
void |
add(java.lang.String key,
java.lang.String value)
add a value for the given key
|
void |
clear(java.lang.String key)
clear the given key
|
boolean |
containsKey(java.lang.String key)
return whether the given key exists
|
java.lang.String[] |
getAll(java.lang.String key)
return all strings associated with the key
|
java.lang.String[] |
getAll(java.lang.String key,
java.lang.String[] values)
return all strings associated with the key
|
int |
getCount(java.lang.String key)
return the number of strings associated with a key
|
java.lang.String |
getFirst(java.lang.String key)
return the first string of the key
|
java.util.Iterator<java.lang.String> |
getIterator(java.lang.String key)
return an iterator over all strings of a key
|
java.util.Iterator<java.lang.String> |
getKeyIterator()
return an iterator over the keys
|
java.util.List<java.lang.String> |
getList(java.lang.String key)
return the strings associated with the key as a list
|
java.util.Iterator<KVList.Pair> |
iterator()
return an iterator over the key-value pairs
|
void |
set(java.lang.String key,
java.util.Collection<java.lang.String> col)
set the given key, replacing all previous contents
|
void |
set(java.lang.String key,
java.lang.String... values)
set the given key, replacing all previous contents
|
void |
set(java.lang.String key,
java.lang.String value)
set the given key, replacing all previous contents
|
private java.util.LinkedHashMap<java.lang.String,KVList.ValueImpl> pairs
public void add(java.lang.String key, java.lang.String value)
key
- the keyvalue
- the valuepublic void add(java.lang.String key, java.lang.String... values)
key
- the keyvalues
- the valuespublic void add(java.lang.String key, java.util.Collection<java.lang.String> col)
key
- the keycol
- the valuespublic void set(java.lang.String key, java.lang.String value)
key
- the keyvalue
- the valuepublic void set(java.lang.String key, java.lang.String... values)
key
- the keyvalues
- the valuespublic void set(java.lang.String key, java.util.Collection<java.lang.String> col)
key
- the keycol
- the valuespublic void clear(java.lang.String key)
key
- the keypublic boolean containsKey(java.lang.String key)
key
- the keytrue
if sopublic int getCount(java.lang.String key)
key
- the key0
indicating that the key does not existpublic java.lang.String getFirst(java.lang.String key)
key
- the keynull
if
the key does not existpublic java.lang.String[] getAll(java.lang.String key, java.lang.String[] values)
key
- the keyvalues
- the array where the strings are stored
(may be null
)null
. If
the key does not exist, null
is returnedpublic java.lang.String[] getAll(java.lang.String key)
key
- the keynull
public java.util.List<java.lang.String> getList(java.lang.String key)
key
- the keypublic java.util.Iterator<java.lang.String> getIterator(java.lang.String key)
key
- the keypublic java.util.Iterator<java.lang.String> getKeyIterator()
public java.util.Iterator<KVList.Pair> iterator()
iterator
in interface java.lang.Iterable<KVList.Pair>
Copyright © 2005-2013 Knipp Medien und Kommunikation GmbH