站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.0.5 API 文档英文版

CollectionFactory (Spring Framework API 2.0) - Spring Framework 2.0.5 API 文档英文版

The Spring Framework

org.springframework.core
Class CollectionFactory

java.lang.Object
  extended by org.springframework.core.CollectionFactory

public abstract class CollectionFactory
extends Object

Factory for collections, being aware of JDK 1.4+ extended collections and Commons Collection 3.x's corresponding versions for older JDKs, as well as JDK 1.5+ concurrent collections and backport-concurrent versions of those. 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, falling back to JDK 1.3 collections as worst case.

Since:
1.1.1
Author:
Juergen Hoeller
See Also:
createLinkedSetIfPossible(int), createLinkedMapIfPossible(int), createLinkedCaseInsensitiveMapIfPossible(int), createIdentityMapIfPossible(int)

Constructor Summary
CollectionFactory()
           
 
Method Summary
static Collection createApproximateCollection(Object collection, int initialCapacity)
          Create the most approximate collection for the given collection.
static Map createApproximateMap(Object map, int initialCapacity)
          Create the most approximate map for the given map.
static Map createConcurrentMapIfPossible(int initialCapacity)
          Create a concurrent map if possible: that is, if running on JDK >= 1.5 or if the backport-concurrent library is available.
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 createLinkedCaseInsensitiveMapIfPossible(int initialCapacity)
          Create a linked case-insensitive map if possible: if Commons Collections 3.x is available, a CaseInsensitiveMap with ListOrderedMap decorator will be created.
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

createLinkedCaseInsensitiveMapIfPossible

public static Map createLinkedCaseInsensitiveMapIfPossible(int initialCapacity)
Create a linked case-insensitive map if possible: if Commons Collections 3.x is available, a CaseInsensitiveMap with ListOrderedMap decorator will be created. Else, a JDK 1.4+ LinkedHashMap or plain HashMap will be used.

Parameters:
initialCapacity - the initial capacity of the map
Returns:
the new map instance
See Also:
CaseInsensitiveMap, ListOrderedMap

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

createConcurrentMapIfPossible

public static Map createConcurrentMapIfPossible(int initialCapacity)
Create a concurrent map if possible: that is, if running on JDK >= 1.5 or if the backport-concurrent library is available. Prefers a JDK 1.5+ ConcurrentHashMap to its backport-concurrent equivalent.

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

createApproximateCollection

public static Collection createApproximateCollection(Object collection,
                                                     int initialCapacity)
Create the most approximate collection for the given collection.

Creates an ArrayList, TreeSet or linked Set for a List, SortedSet or Set, respectively.

Parameters:
collection - the original collection object
initialCapacity - the initial capacity
Returns:
the new collection instance
See Also:
ArrayList, TreeSet, createLinkedSetIfPossible(int)

createApproximateMap

public static Map createApproximateMap(Object map,
                                       int initialCapacity)
Create the most approximate map for the given map.

Creates a TreeMap or linked Map for a SortedMap or Map, respectively.

Parameters:
map - the original map object
initialCapacity - the initial capacity
Returns:
the new collection instance
See Also:
TreeMap, createLinkedMapIfPossible(int)

The Spring Framework

Copyright © 2002-2007 The Spring Framework.