|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.core.CollectionFactory
public abstract class CollectionFactory
Factory for collections, being aware of Commons Collection 3.x's extended collections as well as of JDK 1.5+ concurrent collections and backport-concurrent collections. Mainly for internal use within the framework.
The goal of this class is to avoid runtime dependencies on JDK 1.5+ and Commons Collections 3.x, simply using the best collection implementation that is available at runtime. As of Spring 2.5, JDK 1.4 is required, so former adapter methods for JDK 1.3/1.4 always return the JDK 1.4 collections now. The adapter methods are still kept for supporting Spring-based applications/frameworks which were built to support JDK 1.3.
| 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 ConcurrentMap |
createConcurrentMap(int initialCapacity)
Create a concurrent Map with a dedicated ConcurrentMap interface,
requiring JDK >= 1.5 or the backport-concurrent library on the classpath. |
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 Set |
createCopyOnWriteSet()
Create a copy-on-write Set (allowing for synchronization-less iteration), requiring JDK >= 1.5 or the backport-concurrent library on the classpath. |
static Map |
createIdentityMapIfPossible(int initialCapacity)
Deprecated. as of Spring 2.5, for usage on JDK 1.4 or higher |
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)
Deprecated. as of Spring 2.5, for usage on JDK 1.4 or higher |
static Set |
createLinkedSetIfPossible(int initialCapacity)
Deprecated. as of Spring 2.5, for usage on JDK 1.4 or higher |
static boolean |
isApproximableCollectionType(Class collectionType)
Determine whether the given collection type is an approximable type, i.e. a type that createApproximateCollection(java.lang.Object, int) can approximate. |
static boolean |
isApproximableMapType(Class mapType)
Determine whether the given map type is an approximable type, i.e. a type that createApproximateMap(java.lang.Object, int) can approximate. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CollectionFactory()
| Method Detail |
|---|
public static Set createLinkedSetIfPossible(int initialCapacity)
LinkedHashSet, since Spring 2.5
requires JDK 1.4 anyway.
initialCapacity - the initial capacity of the Set
public static Set createCopyOnWriteSet()
IllegalStateException - if no copy-on-write Set is availableConcurrentHashMap,
ConcurrentHashMappublic static Map createLinkedMapIfPossible(int initialCapacity)
LinkedHashMap, since Spring 2.5
requires JDK 1.4 anyway.
initialCapacity - the initial capacity of the Map
public static Map createLinkedCaseInsensitiveMapIfPossible(int initialCapacity)
LinkedHashMap will be used.
initialCapacity - the initial capacity of the Map
CaseInsensitiveMap,
ListOrderedMappublic static Map createIdentityMapIfPossible(int initialCapacity)
IdentityHashMap, since Spring 2.5
requires JDK 1.4 anyway.
initialCapacity - the initial capacity of the Map
public static Map createConcurrentMapIfPossible(int initialCapacity)
initialCapacity - the initial capacity of the Map
ConcurrentHashMap,
ConcurrentHashMappublic static ConcurrentMap createConcurrentMap(int initialCapacity)
ConcurrentMap interface,
requiring JDK >= 1.5 or the backport-concurrent library on the classpath.
Prefers a JDK 1.5+ ConcurrentHashMap to its backport-concurrent equivalent.
Throws an IllegalStateException if no concurrent Map is available.
initialCapacity - the initial capacity of the Map
IllegalStateException - if no concurrent Map is availableConcurrentHashMap,
ConcurrentHashMappublic static boolean isApproximableCollectionType(Class collectionType)
createApproximateCollection(java.lang.Object, int) can approximate.
collectionType - the collection type to check
true if the type is approximable,
false if it is not
public static Collection createApproximateCollection(Object collection,
int initialCapacity)
Creates an ArrayList, TreeSet or linked Set for a List, SortedSet or Set, respectively.
collection - the original collection objectinitialCapacity - the initial capacity
ArrayList,
TreeSet,
LinkedHashSetpublic static boolean isApproximableMapType(Class mapType)
createApproximateMap(java.lang.Object, int) can approximate.
mapType - the map type to check
true if the type is approximable,
false if it is not
public static Map createApproximateMap(Object map,
int initialCapacity)
Creates a TreeMap or linked Map for a SortedMap or Map, respectively.
map - the original map objectinitialCapacity - the initial capacity
TreeMap,
LinkedHashMap
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||