Top Description Fields Constructors Methods
org.apache.tools.ant.util

public Class LinkedHashtable<K, V>

extends Hashtable<K, V>
Class Inheritance
Imports
java.util.Collection, .Collections, .Enumeration, .Hashtable, .LinkedHashMap, .Map, .Set

Subclass of Hashtable that wraps a LinkedHashMap to provide predictable iteration order.

This is not a general purpose class but has been written because the protected members of Copy prohibited later revisions from using a more predictable collection.

Methods are synchronized to keep Hashtable's contract.

Since
Ant 1.8.2

Field Summary

Modifier and TypeField and Description
private final LinkedHashMap<K, V>
private static final long

Constructor Summary

AccessConstructor and Description
public
public
LinkedHashtable(int initialCapacity)

public
LinkedHashtable(int initialCapacity, float loadFactor)

public

Method Summary

Modifier and TypeMethod and Description
public synchronized void
clear()

Overrides java.util.Hashtable.clear.

Implements java.util.Map.clear.

Clears this hashtable so that it contains no keys.
public boolean
contains(Object
a value to search for
value
)

Overrides java.util.Hashtable.contains.

Tests if some key maps into the specified value in this hashtable.
public synchronized boolean
containsKey(Object
possible key
value
)

Overrides java.util.Hashtable.containsKey.

Implements java.util.Map.containsKey.

Tests if the specified object is a key in this hashtable.
public synchronized boolean
containsValue(Object
value whose presence in this hashtable is to be tested
value
)

Overrides java.util.Hashtable.containsValue.

Implements java.util.Map.containsValue.

Returns true if this hashtable maps one or more keys to this value.
public Enumeration<V>
elements()

Overrides java.util.Hashtable.elements.

Returns an enumeration of the values in this hashtable.
public synchronized Set<Map.Entry<K, V>>
entrySet()

Overrides java.util.Hashtable.entrySet.

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.
public synchronized boolean
equals(Object
object to be compared for equality with this hashtable
o
)

Overrides java.util.Hashtable.equals.

Implements java.util.Map.equals.

Compares the specified Object with this Map for equality, as per the definition in the Map interface.
public synchronized V
get(Object
the key whose associated value is to be returned
k
)

Overrides java.util.Hashtable.get.

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
public synchronized int
hashCode()

Overrides java.util.Hashtable.hashCode.

Implements java.util.Map.hashCode.

Returns the hash code value for this Map as per the definition in the Map interface.
public synchronized boolean
isEmpty()

Overrides java.util.Hashtable.isEmpty.

Implements java.util.Map.isEmpty.

Tests if this hashtable maps no keys to values.
public Enumeration<K>
keys()

Overrides java.util.Hashtable.keys.

Returns an enumeration of the keys in this hashtable.
public synchronized Set<K>
keySet()

Overrides java.util.Hashtable.keySet.

Implements java.util.Map.keySet.

Returns a Set view of the keys contained in this map.
public synchronized V
put(K
the hashtable key
k
,
V
the value
v
)

Overrides java.util.Hashtable.put.

Implements java.util.Map.put.

Maps the specified key to the specified value in this hashtable.
public synchronized void
putAll(Map<? extends K, ? extends V>
mappings to be stored in this map
m
)

Overrides java.util.Hashtable.putAll.

Implements java.util.Map.putAll.

Copies all of the mappings from the specified map to this hashtable.
public synchronized V
remove(Object
the key that needs to be removed
k
)

Overrides java.util.Hashtable.remove.

Implements java.util.Map.remove.

Removes the key (and its corresponding value) from this hashtable.
public synchronized int
size()

Overrides java.util.Hashtable.size.

Implements java.util.Map.size.

Returns the number of keys in this hashtable.
public synchronized String
toString()

Overrides java.util.Hashtable.toString.

Returns a string representation of this Hashtable object in the form of a set of entries, enclosed in braces and separated by the ASCII characters " , " (comma and space).
public synchronized Collection<V>
values()

Overrides java.util.Hashtable.values.

Implements java.util.Map.values.

Returns a Collection view of the values contained in this map.
Inherited from java.util.Hashtable:
clonecomputecomputeIfAbsentcomputeIfPresentforEachgetOrDefaultmergeputIfAbsentrehashremovereplacereplacereplaceAll

Field Detail

mapback to summary
private final LinkedHashMap<K, V> map
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.Hashtable.serialVersionUID.

Constructor Detail

LinkedHashtableback to summary
public LinkedHashtable()
LinkedHashtableback to summary
public LinkedHashtable(int initialCapacity)
LinkedHashtableback to summary
public LinkedHashtable(int initialCapacity, float loadFactor)
LinkedHashtableback to summary
public LinkedHashtable(Map<K, V> m)

Method Detail

clearback to summary
public synchronized void clear()

Overrides java.util.Hashtable.clear.

Implements java.util.Map.clear.

Doc from java.util.Hashtable.clear.

Clears this hashtable so that it contains no keys.

containsback to summary
public boolean contains(Object value)

Overrides java.util.Hashtable.contains.

Doc from java.util.Hashtable.contains.

Tests if some key maps into the specified value in this hashtable. This operation is more expensive than the containsKey method.

Note that this method is identical in functionality to containsValue, (which is part of the Map interface in the collections framework).

Parameters
value:Object

a value to search for

Returns:boolean

true if and only if some key maps to the value argument in this hashtable as determined by the equals method; false otherwise.

Annotations
@Override
containsKeyback to summary
public synchronized boolean containsKey(Object value)

Overrides java.util.Hashtable.containsKey.

Implements java.util.Map.containsKey.

Doc from java.util.Hashtable.containsKey.

Tests if the specified object is a key in this hashtable.

Parameters
value:Object

possible key

Returns:boolean

true if and only if the specified object is a key in this hashtable, as determined by the equals method; false otherwise.

Annotations
@Override
containsValueback to summary
public synchronized boolean containsValue(Object value)

Overrides java.util.Hashtable.containsValue.

Implements java.util.Map.containsValue.

Doc from java.util.Hashtable.containsValue.

Returns true if this hashtable maps one or more keys to this value.

Note that this method is identical in functionality to contains (which predates the Map interface).

Parameters
value:Object

value whose presence in this hashtable is to be tested

Returns:boolean

true if this map maps one or more keys to the specified value

Annotations
@Override
elementsback to summary
public Enumeration<V> elements()

Overrides java.util.Hashtable.elements.

Doc from java.util.Hashtable.elements.

Returns an enumeration of the values in this hashtable. Use the Enumeration methods on the returned object to fetch the elements sequentially. If the hashtable is structurally modified while enumerating over the values then the results of enumerating are undefined.

Returns:Enumeration<V>

an enumeration of the values in this hashtable.

Annotations
@Override
entrySetback to summary
public synchronized Set<Map.Entry<K, V>> entrySet()

Overrides java.util.Hashtable.entrySet.

Implements java.util.Map.entrySet.

Doc from java.util.Hashtable.entrySet.

Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Returns:Set<Map.Entry<K, V>>

Doc from java.util.Map.entrySet.

a set view of the mappings contained in this map

Annotations
@Override
equalsback to summary
public synchronized boolean equals(Object o)

Overrides java.util.Hashtable.equals.

Implements java.util.Map.equals.

Doc from java.util.Hashtable.equals.

Compares the specified Object with this Map for equality, as per the definition in the Map interface.

Parameters
o:Object

object to be compared for equality with this hashtable

Returns:boolean

true if the specified Object is equal to this Map

Annotations
@Override
getback to summary
public synchronized V get(Object k)

Overrides java.util.Hashtable.get.

Implements java.util.Map.get.

Doc from java.util.Hashtable.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that (key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

Parameters
k:Object

the key whose associated value is to be returned

Returns:V

the value to which the specified key is mapped, or null if this map contains no mapping for the key

Annotations
@Override
hashCodeback to summary
public synchronized int hashCode()

Overrides java.util.Hashtable.hashCode.

Implements java.util.Map.hashCode.

Doc from java.util.Hashtable.hashCode.

Returns the hash code value for this Map as per the definition in the Map interface.

Returns:int

Doc from java.util.Map.hashCode.

the hash code value for this map

Annotations
@Override
isEmptyback to summary
public synchronized boolean isEmpty()

Overrides java.util.Hashtable.isEmpty.

Implements java.util.Map.isEmpty.

Doc from java.util.Hashtable.isEmpty.

Tests if this hashtable maps no keys to values.

Returns:boolean

true if this hashtable maps no keys to values; false otherwise.

Annotations
@Override
keysback to summary
public Enumeration<K> keys()

Overrides java.util.Hashtable.keys.

Doc from java.util.Hashtable.keys.

Returns an enumeration of the keys in this hashtable. Use the Enumeration methods on the returned object to fetch the keys sequentially. If the hashtable is structurally modified while enumerating over the keys then the results of enumerating are undefined.

Returns:Enumeration<K>

an enumeration of the keys in this hashtable.

Annotations
@Override
keySetback to summary
public synchronized Set<K> keySet()

Overrides java.util.Hashtable.keySet.

Implements java.util.Map.keySet.

Doc from java.util.Hashtable.keySet.

Returns a Set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.

Returns:Set<K>

Doc from java.util.Map.keySet.

a set view of the keys contained in this map

Annotations
@Override
putback to summary
public synchronized V put(K k, V v)

Overrides java.util.Hashtable.put.

Implements java.util.Map.put.

Doc from java.util.Hashtable.put.

Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Parameters
k:K

the hashtable key

v:V

the value

Returns:V

the previous value of the specified key in this hashtable, or null if it did not have one

Annotations
@Override
putAllback to summary
public synchronized void putAll(Map<? extends K, ? extends V> m)

Overrides java.util.Hashtable.putAll.

Implements java.util.Map.putAll.

Doc from java.util.Hashtable.putAll.

Copies all of the mappings from the specified map to this hashtable. These mappings will replace any mappings that this hashtable had for any of the keys currently in the specified map.

Parameters
m:Map<? extends K, ? extends V>

mappings to be stored in this map

Annotations
@Override
removeback to summary
public synchronized V remove(Object k)

Overrides java.util.Hashtable.remove.

Implements java.util.Map.remove.

Doc from java.util.Hashtable.remove.

Removes the key (and its corresponding value) from this hashtable. This method does nothing if the key is not in the hashtable.

Parameters
k:Object

the key that needs to be removed

Returns:V

the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping

Annotations
@Override
sizeback to summary
public synchronized int size()

Overrides java.util.Hashtable.size.

Implements java.util.Map.size.

Doc from java.util.Hashtable.size.

Returns the number of keys in this hashtable.

Returns:int

the number of keys in this hashtable.

Annotations
@Override
toStringback to summary
public synchronized String toString()

Overrides java.util.Hashtable.toString.

Doc from java.util.Hashtable.toString.

Returns a string representation of this Hashtable object in the form of a set of entries, enclosed in braces and separated by the ASCII characters " , " (comma and space). Each entry is rendered as the key, an equals sign =, and the associated element, where the toString method is used to convert the key and element to strings.

Returns:String

a string representation of this hashtable

Annotations
@Override
valuesback to summary
public synchronized Collection<V> values()

Overrides java.util.Hashtable.values.

Implements java.util.Map.values.

Doc from java.util.Hashtable.values.

Returns a Collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Returns:Collection<V>

Doc from java.util.Map.values.

a collection view of the values contained in this map

Annotations
@Override