org.springframework.core
Class CollectionFactory

java.lang.Object
  extended byorg.springframework.core.CollectionFactory

public class CollectionFactory
extends Object

Factory for collections, being aware of JDK 1.4's extended collections and Commons Collection 3.1's corresponding versions for older JDKs. Mainly for internal use within the framework.

The goal of this class is to avoid runtime dependencies on JDK 1.4 or Commons Collections 3.x, simply using the best collection implementation that is available. Prefers JDK 1.4 collection implementations to Commons Collections 3.x versions.

Since:
1.1.1
Author:
Juergen Hoeller

Constructor Summary
CollectionFactory()
           
 
Method Summary
static Map createIdentityMapIfPossible(int initialCapacity)
          Create an identity map if possible: that is, if running on JDK 1.4 or if Commons Collections 3.x is available.
static Map createLinkedMapIfPossible(int initialCapacity)
          Create a linked map if possible: that is, if running on JDK >= 1.4 or if Commons Collections 3.x is available.
static Set createLinkedSetIfPossible(int initialCapacity)
          Create a linked set if possible: that is, if running on JDK >= 1.4 or if Commons Collections 3.x is available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionFactory

public CollectionFactory()
Method Detail

createLinkedSetIfPossible

public static Set createLinkedSetIfPossible(int initialCapacity)
Create a linked set if possible: that is, if running on JDK >= 1.4 or if Commons Collections 3.x is available. Prefers a JDK 1.4 LinkedHashSet to a Commons Collections 3.x ListOrderedSet.

Parameters:
initialCapacity - the initial capacity of the set
Returns:
the new set instance
See Also:
LinkedHashSet, ListOrderedSet

createLinkedMapIfPossible

public static Map createLinkedMapIfPossible(int initialCapacity)
Create a linked map if possible: that is, if running on JDK >= 1.4 or if Commons Collections 3.x is available. Prefers a JDK 1.4 LinkedHashMap to a Commons Collections 3.x LinkedMap.

Parameters:
initialCapacity - the initial capacity of the map
Returns:
the new map instance
See Also:
LinkedHashMap, LinkedMap

createIdentityMapIfPossible

public static Map createIdentityMapIfPossible(int initialCapacity)
Create an identity map if possible: that is, if running on JDK 1.4 or if Commons Collections 3.x is available. Prefers a JDK 1.4 IdentityHashMap to a Commons Collections 3.x IdentityMap.

Parameters:
initialCapacity - the initial capacity of the map
Returns:
the new map instance
See Also:
IdentityHashMap, IdentityMap


Copyright (C) 2003-2004 The Spring Framework Project.