org.eclipse.osgi.framework.util
Class Headers<K,V>

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by org.eclipse.osgi.framework.util.Headers<K,V>
All Implemented Interfaces:
Map<K,V>

public class Headers<K,V>
extends Dictionary<K,V>
implements Map<K,V>

Headers classes. This class implements a Dictionary that has the following behavior:

Since:
3.1

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
Headers(Dictionary<? extends K,? extends V> values)
          Create a Headers dictionary from a Dictionary.
Headers(int initialCapacity)
          Create an empty Headers dictionary.
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Enumeration<V> elements()
          Values.
 Set<Map.Entry<K,V>> entrySet()
           
 V get(Object key)
          Support case-insensitivity for keys.
 boolean isEmpty()
          Tests if this dictionary maps no keys to value.
 Enumeration<K> keys()
          Case-preserved keys.
 Set<K> keySet()
           
static Headers<String,String> parseManifest(InputStream in)
           
 V put(K key, V value)
          Always throws UnsupportedOperationException.
 void putAll(Map<? extends K,? extends V> c)
           
 V remove(Object key)
          Always throws UnsupportedOperationException.
 V set(K key, V value)
          Set a header value.
 V set(K key, V value, boolean replace)
          Set a header value or optionally replace it if it already exists.
 void setReadOnly()
           
 int size()
          Returns the number of entries (distinct keys) in this dictionary.
 String toString()
           
 Collection<V> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

Headers

public Headers(int initialCapacity)
Create an empty Headers dictionary.

Parameters:
initialCapacity - The initial capacity of this Headers object.

Headers

public Headers(Dictionary<? extends K,? extends V> values)
Create a Headers dictionary from a Dictionary.

Parameters:
values - The initial dictionary for this Headers object.
Throws:
IllegalArgumentException - If a case-variant of the key is in the dictionary parameter.
Method Detail

keys

public Enumeration<K> keys()
Case-preserved keys.

Specified by:
keys in class Dictionary<K,V>

elements

public Enumeration<V> elements()
Values.

Specified by:
elements in class Dictionary<K,V>

get

public V get(Object key)
Support case-insensitivity for keys.

Specified by:
get in interface Map<K,V>
Specified by:
get in class Dictionary<K,V>
Parameters:
key - name.

set

public V set(K key,
             V value,
             boolean replace)
Set a header value or optionally replace it if it already exists.

Parameters:
key - Key name.
value - Value of the key or null to remove key.
replace - A value of true will allow a previous value of the key to be replaced. A value of false will cause an IllegalArgumentException to be thrown if a previous value of the key exists.
Returns:
the previous value to which the key was mapped, or null if the key did not have a previous mapping.
Throws:
IllegalArgumentException - If a case-variant of the key is already present.
Since:
3.2

set

public V set(K key,
             V value)
Set a header value.

Parameters:
key - Key name.
value - Value of the key or null to remove key.
Returns:
the previous value to which the key was mapped, or null if the key did not have a previous mapping.
Throws:
IllegalArgumentException - If a case-variant of the key is already present.

setReadOnly

public void setReadOnly()

size

public int size()
Returns the number of entries (distinct keys) in this dictionary.

Specified by:
size in interface Map<K,V>
Specified by:
size in class Dictionary<K,V>
Returns:
the number of keys in this dictionary.

isEmpty

public boolean isEmpty()
Tests if this dictionary maps no keys to value. The general contract for the isEmpty method is that the result is true if and only if this dictionary contains no entries.

Specified by:
isEmpty in interface Map<K,V>
Specified by:
isEmpty in class Dictionary<K,V>
Returns:
true if this dictionary maps no keys to values; false otherwise.

put

public V put(K key,
             V value)
Always throws UnsupportedOperationException.

Specified by:
put in interface Map<K,V>
Specified by:
put in class Dictionary<K,V>
Parameters:
key - header name.
value - header value.
Throws:
UnsupportedOperationException

remove

public V remove(Object key)
Always throws UnsupportedOperationException.

Specified by:
remove in interface Map<K,V>
Specified by:
remove in class Dictionary<K,V>
Parameters:
key - header name.
Throws:
UnsupportedOperationException

toString

public String toString()
Overrides:
toString in class Object

parseManifest

public static Headers<String,String> parseManifest(InputStream in)
                                            throws BundleException
Throws:
BundleException

clear

public void clear()
Specified by:
clear in interface Map<K,V>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<K,V>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<K,V>

entrySet

public Set<Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface Map<K,V>

keySet

public Set<K> keySet()
Specified by:
keySet in interface Map<K,V>

putAll

public void putAll(Map<? extends K,? extends V> c)
Specified by:
putAll in interface Map<K,V>

values

public Collection<V> values()
Specified by:
values in interface Map<K,V>


Copyright © 2007–2014 The Apache Software Foundation. All rights reserved.