Save This Page
Home » spring-framework-2.5.5-with-dependencies » org.springframework » core » [javadoc | source]
org.springframework.core
abstract public class: CollectionFactory [javadoc | source]
java.lang.Object
   org.springframework.core.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.

Method from org.springframework.core.CollectionFactory Summary:
createApproximateCollection,   createApproximateMap,   createConcurrentMap,   createConcurrentMapIfPossible,   createCopyOnWriteSet,   createIdentityMapIfPossible,   createLinkedCaseInsensitiveMapIfPossible,   createLinkedMapIfPossible,   createLinkedSetIfPossible,   isApproximableCollectionType,   isApproximableMapType
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.core.CollectionFactory Detail:
 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.

 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.

 public 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. Prefers a JDK 1.5+ ConcurrentHashMap to its backport-concurrent equivalent. Throws an IllegalStateException if no concurrent Map is available.
 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. Falls back to a plain synchronized HashMap if no concurrent Map is available.
 public 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. Prefers a JDK 1.5+ CopyOnWriteArraySet to its backport-concurrent equivalent. Throws an IllegalStateException if no copy-on-write Set is available.
 public static Map createIdentityMapIfPossible(int initialCapacity) 
Deprecated! as - of Spring 2.5, for usage on JDK 1.4 or higher

    Create an identity Map if possible: This implementation always creates a java.util.IdentityHashMap , since Spring 2.5 requires JDK 1.4 anyway.
 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 java.util.LinkedHashMap will be used.
 public static Map createLinkedMapIfPossible(int initialCapacity) 
Deprecated! as - of Spring 2.5, for usage on JDK 1.4 or higher

    Create a linked Map if possible: This implementation always creates a java.util.LinkedHashMap , since Spring 2.5 requires JDK 1.4 anyway.
 public static Set createLinkedSetIfPossible(int initialCapacity) 
Deprecated! as - of Spring 2.5, for usage on JDK 1.4 or higher

    Create a linked Set if possible: This implementation always creates a java.util.LinkedHashSet , since Spring 2.5 requires JDK 1.4 anyway.
 public static boolean isApproximableCollectionType(Class collectionType) 
 public static boolean isApproximableMapType(Class mapType) 
    Determine whether the given map type is an approximable type, i.e. a type that #createApproximateMap can approximate.