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:
java.util.Map<K,V>

public class Headers<K,V>
extends java.util.Dictionary<K,V>
implements java.util.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
java.util.Map.Entry<K,V>
 
Constructor Summary
Headers(java.util.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(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Enumeration<V> elements()
          Values.
 java.util.Set<java.util.Map.Entry<K,V>> entrySet()
           
 V get(java.lang.Object key)
          Support case-insensitivity for keys.
 boolean isEmpty()
          Tests if this dictionary maps no keys to value.
 java.util.Enumeration<K> keys()
          Case-preserved keys.
 java.util.Set<K> keySet()
           
static Headers<java.lang.String,java.lang.String> parseManifest(java.io.InputStream in)
           
 V put(K key, V value)
          Always throws UnsupportedOperationException.
 void putAll(java.util.Map<? extends K,? extends V> c)
           
 V remove(java.lang.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.
 java.lang.String toString()
           
 java.util.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(java.util.Dictionary<? extends K,? extends V> values)
Create a Headers dictionary from a Dictionary.

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

keys

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

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

elements

public java.util.Enumeration<V> elements()
Values.

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

get

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

Specified by:
get in interface java.util.Map<K,V>
Specified by:
get in class java.util.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:
java.lang.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:
java.lang.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 java.util.Map<K,V>
Specified by:
size in class java.util.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 java.util.Map<K,V>
Specified by:
isEmpty in class java.util.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 java.util.Map<K,V>
Specified by:
put in class java.util.Dictionary<K,V>
Parameters:
key - header name.
value - header value.
Throws:
java.lang.UnsupportedOperationException

remove

public V remove(java.lang.Object key)
Always throws UnsupportedOperationException.

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

parseManifest

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

clear

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

containsKey

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

containsValue

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

entrySet

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

keySet

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

putAll

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

values

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


Copyright © 2007-2012 FuseSource, Corp.. All Rights Reserved.