|
|||||||||
| Home >> All >> org >> metacosm >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.metacosm.util
Class CollectionFactory

java.lang.Objectorg.metacosm.util.CollectionFactory
- public class CollectionFactory
- extends java.lang.Object
This factory encapsulates the creation of Collections.
A configuration file is used to get Collections returned by *Pref* methods.
The configuration gile is 'CollectionFactory.properties'.
Example:
Collection myCollection;
myCollection = CollectionFactory.createPrefCollection();
myCollection = CollectionFactory.createStandardCollection("ArrayList");
TODO:CHECK FOR ERRORS!!!
clean up code and optimize
improve documentation
improve type checking in methods
create optimized version for Pref (using cache)
create synchronized versions
create version with load factor?
add initial capacity and load factor to properties?
create method to change load factor at runtime?
Create method to re-init properties at runtime (needed to change pref collections at runtime)
- Version:
- 1.2.2
| Field Summary | |
private static java.util.Properties |
configuration
The configuration of CollectionFactory. |
private static java.lang.String |
DEFAULT_COLLECTION
|
private static java.lang.String |
DEFAULT_LIST
|
private static java.lang.String |
DEFAULT_MAP
|
private static java.lang.String |
DEFAULT_SET
|
private static java.lang.String |
DEFAULT_SORTED_MAP
|
private static java.lang.String |
DEFAULT_SORTED_SET
|
private static java.lang.Integer |
initialCapacity
Initial capacity of the collection |
private static java.lang.String |
PREF_ERR
Load factor |
private static java.lang.String |
preferredCollection
|
private static java.lang.String |
preferredList
|
private static java.lang.String |
preferredMap
|
private static java.lang.String |
preferredSet
|
private static java.lang.String |
preferredSortedMap
|
private static java.lang.String |
preferredSortedSet
|
| Constructor Summary | |
CollectionFactory()
|
|
| Method Summary | |
private static java.lang.Object |
create(java.lang.String type,
boolean isStandard,
java.lang.String defaultType)
|
private static java.lang.Object |
create(java.lang.String type,
java.util.Collection collection,
boolean isStandard,
java.lang.String defaultType)
|
private static java.lang.Object |
create(java.lang.String type,
java.util.Map map,
boolean isStandard,
java.lang.String defaultType)
|
private static java.lang.Object |
create(java.lang.String type,
java.lang.Object collection,
java.lang.Class collectionType,
boolean isStandard,
java.lang.String defaultType)
|
static java.util.Collection |
createCollection(java.lang.String fullType)
Creates a Collection. |
static java.util.Collection |
createCollection(java.lang.String fullType,
java.util.Collection collection)
Creates a Collection and initiliazes it with an existing Collection. |
private static java.lang.Object |
createDefault(java.lang.String defaultType)
|
private static java.lang.Object |
createDefault(java.lang.String defaultType,
java.util.Collection collection)
|
private static java.lang.Object |
createDefault(java.lang.String defaultType,
java.util.Map map)
|
static java.util.List |
createList(java.lang.String fullType)
|
static java.util.List |
createList(java.lang.String fullType,
java.util.Collection collection)
Creates a List and initiliazes it with an existing Collection. |
static java.util.Map |
createMap(java.lang.String fullType)
|
static java.util.Map |
createMap(java.lang.String fullType,
java.util.Map map)
Creates a Map and initiliazes it with an existing Map. |
static java.util.Collection |
createPrefCollection()
Creates a Collection which type is defined in the configuration file. |
static java.util.Collection |
createPrefCollection(java.util.Collection collection)
Creates a Collection which type is defined in the configuration file and initializes it with an existing Collection. |
static java.util.List |
createPrefList()
Creates a List which type is defined in the configuration file. |
static java.util.List |
createPrefList(java.util.Collection collection)
Creates a List which type is defined in the configuration file and initializes it with an existing Collection. |
static java.util.Map |
createPrefMap()
Creates a Map which type is defined in the configuration file. |
static java.util.Map |
createPrefMap(java.util.Map map)
Creates a Map which type is defined in the configuration file and initializes it with an existing Map. |
static java.util.Set |
createPrefSet()
Creates a Set which type is defined in the configuration file. |
static java.util.Set |
createPrefSet(java.util.Collection collection)
Creates a Set which type is defined in the configuration file and initializes it with an existing Collection. |
static java.util.SortedMap |
createPrefSortedMap()
Creates a SortedMap which type is defined in the configuration file. |
static java.util.SortedMap |
createPrefSortedMap(java.util.Map map)
Creates a SortedMap which type is defined in the configuration file and initializes it with an existing Map. |
static java.util.SortedSet |
createPrefSortedSet()
Creates a SortedSet which type is defined in the configuration file. |
static java.util.SortedSet |
createPrefSortedSet(java.util.Collection collection)
Creates a SortedSet which type is defined in the configuration file and initializes it with an existing Collection. |
static java.util.Set |
createSet(java.lang.String fullType)
|
static java.util.Set |
createSet(java.lang.String fullType,
java.util.Collection collection)
Creates a Set and initiliazes it with an existing Collection. |
static java.util.SortedMap |
createSortedMap(java.lang.String fullType)
|
static java.util.SortedMap |
createSortedMap(java.lang.String fullType,
java.util.Map map)
Creates a SortedMap and initiliazes it with an existing Map. |
static java.util.SortedSet |
createSortedSet(java.lang.String fullType)
|
static java.util.SortedSet |
createSortedSet(java.lang.String fullType,
java.util.Collection collection)
Creates a SortedSet and initiliazes it with an existing Collection. |
static java.util.Collection |
createStandardCollection(java.lang.String type)
Creates a standard Collection from java.util. |
static java.util.Collection |
createStandardCollection(java.lang.String type,
java.util.Collection collection)
Creates a standard Collection from java.util and initializes it with an existing Collection. |
static java.util.List |
createStandardList(java.lang.String type)
|
static java.util.List |
createStandardList(java.lang.String type,
java.util.Collection collection)
Creates a standard List from java.util and initializes it with an existing Collection. |
static java.util.Map |
createStandardMap(java.lang.String type)
|
static java.util.Map |
createStandardMap(java.lang.String type,
java.util.Map map)
Creates a standard Map from java.util and initializes it with an existing Map. |
static java.util.Set |
createStandardSet(java.lang.String type)
|
static java.util.Set |
createStandardSet(java.lang.String type,
java.util.Collection collection)
Creates a standard Set from java.util and initializes it with an existing Collection. |
static java.util.SortedMap |
createStandardSortedMap(java.lang.String type)
|
static java.util.SortedMap |
createStandardSortedMap(java.lang.String type,
java.util.Map map)
Creates a standard SortedMap from java.util and initializes it with an existing Map. |
static java.util.SortedSet |
createStandardSortedSet(java.lang.String type)
|
static java.util.SortedSet |
createStandardSortedSet(java.lang.String type,
java.util.Collection collection)
Creates a standard SortedSet from java.util and initializes it with an existing Collection. |
private static java.lang.String |
errorMessage(java.lang.String diagnostic,
java.lang.Exception e)
|
private static java.lang.Class |
loadClass(java.lang.String type,
boolean isStandard,
java.lang.String defaultType)
|
static void |
setInitialCapacity(int capacity)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
configuration
private static java.util.Properties configuration
- The configuration of CollectionFactory.
preferredCollection
private static java.lang.String preferredCollection
preferredList
private static java.lang.String preferredList
preferredMap
private static java.lang.String preferredMap
preferredSortedMap
private static java.lang.String preferredSortedMap
preferredSet
private static java.lang.String preferredSet
preferredSortedSet
private static java.lang.String preferredSortedSet
initialCapacity
private static java.lang.Integer initialCapacity
- Initial capacity of the collection
PREF_ERR
private static final java.lang.String PREF_ERR
- Load factor
- See Also:
- Constant Field Values
DEFAULT_COLLECTION
private static final java.lang.String DEFAULT_COLLECTION
- See Also:
- Constant Field Values
DEFAULT_LIST
private static final java.lang.String DEFAULT_LIST
- See Also:
- Constant Field Values
DEFAULT_MAP
private static final java.lang.String DEFAULT_MAP
- See Also:
- Constant Field Values
DEFAULT_SORTED_MAP
private static final java.lang.String DEFAULT_SORTED_MAP
- See Also:
- Constant Field Values
DEFAULT_SET
private static final java.lang.String DEFAULT_SET
- See Also:
- Constant Field Values
DEFAULT_SORTED_SET
private static final java.lang.String DEFAULT_SORTED_SET
- See Also:
- Constant Field Values
| Constructor Detail |
CollectionFactory
public CollectionFactory()
| Method Detail |
setInitialCapacity
public static final void setInitialCapacity(int capacity)
createStandardCollection
public static java.util.Collection createStandardCollection(java.lang.String type)
- Creates a standard Collection from java.util.
createStandardCollection
public static java.util.Collection createStandardCollection(java.lang.String type, java.util.Collection collection)
- Creates a standard Collection from java.util and initializes it with an existing Collection.
createCollection
public static java.util.Collection createCollection(java.lang.String fullType)
- Creates a Collection.
createCollection
public static java.util.Collection createCollection(java.lang.String fullType, java.util.Collection collection)
- Creates a Collection and initiliazes it with an existing Collection.
createPrefCollection
public static java.util.Collection createPrefCollection()
- Creates a Collection which type is defined in the configuration file.
The property is 'preferredEmptyCollection'.
createPrefCollection
public static java.util.Collection createPrefCollection(java.util.Collection collection)
- Creates a Collection which type is defined in the configuration file
and initializes it with an existing Collection.
The property is 'preferredFilledCollection'.
createStandardList
public static java.util.List createStandardList(java.lang.String type)
createStandardList
public static java.util.List createStandardList(java.lang.String type, java.util.Collection collection)
- Creates a standard List from java.util and initializes it with an existing Collection.
createList
public static java.util.List createList(java.lang.String fullType)
createList
public static java.util.List createList(java.lang.String fullType, java.util.Collection collection)
- Creates a List and initiliazes it with an existing Collection.
createPrefList
public static java.util.List createPrefList()
- Creates a List which type is defined in the configuration file.
The property is 'preferredEmptyList'.
createPrefList
public static java.util.List createPrefList(java.util.Collection collection)
- Creates a List which type is defined in the configuration file
and initializes it with an existing Collection.
The property is 'preferredFilledList'.
createStandardMap
public static java.util.Map createStandardMap(java.lang.String type)
createStandardMap
public static java.util.Map createStandardMap(java.lang.String type, java.util.Map map)
- Creates a standard Map from java.util and initializes it with an existing Map.
createMap
public static java.util.Map createMap(java.lang.String fullType)
createMap
public static java.util.Map createMap(java.lang.String fullType, java.util.Map map)
- Creates a Map and initiliazes it with an existing Map.
createPrefMap
public static java.util.Map createPrefMap()
- Creates a Map which type is defined in the configuration file.
The property is 'preferredEmptyMap'.
createPrefMap
public static java.util.Map createPrefMap(java.util.Map map)
- Creates a Map which type is defined in the configuration file
and initializes it with an existing Map.
The property is 'preferredFilledMap'.
createStandardSortedMap
public static java.util.SortedMap createStandardSortedMap(java.lang.String type)
createStandardSortedMap
public static java.util.SortedMap createStandardSortedMap(java.lang.String type, java.util.Map map)
- Creates a standard SortedMap from java.util and initializes it with an existing Map.
createSortedMap
public static java.util.SortedMap createSortedMap(java.lang.String fullType)
createSortedMap
public static java.util.SortedMap createSortedMap(java.lang.String fullType, java.util.Map map)
- Creates a SortedMap and initiliazes it with an existing Map.
createPrefSortedMap
public static java.util.SortedMap createPrefSortedMap()
- Creates a SortedMap which type is defined in the configuration file.
The property is 'preferredEmptySortedMap'.
createPrefSortedMap
public static java.util.SortedMap createPrefSortedMap(java.util.Map map)
- Creates a SortedMap which type is defined in the configuration file
and initializes it with an existing Map.
The property is 'preferredFilledSortedMap'.
createStandardSet
public static java.util.Set createStandardSet(java.lang.String type)
createStandardSet
public static java.util.Set createStandardSet(java.lang.String type, java.util.Collection collection)
- Creates a standard Set from java.util and initializes it with an existing Collection.
createSet
public static java.util.Set createSet(java.lang.String fullType)
createSet
public static java.util.Set createSet(java.lang.String fullType, java.util.Collection collection)
- Creates a Set and initiliazes it with an existing Collection.
createPrefSet
public static java.util.Set createPrefSet()
- Creates a Set which type is defined in the configuration file.
The property is 'preferredEmptyset'.
createPrefSet
public static java.util.Set createPrefSet(java.util.Collection collection)
- Creates a Set which type is defined in the configuration file
and initializes it with an existing Collection.
The property is 'preferredFilledSet'.
createStandardSortedSet
public static java.util.SortedSet createStandardSortedSet(java.lang.String type)
createStandardSortedSet
public static java.util.SortedSet createStandardSortedSet(java.lang.String type, java.util.Collection collection)
- Creates a standard SortedSet from java.util and initializes it with an existing Collection.
createSortedSet
public static java.util.SortedSet createSortedSet(java.lang.String fullType)
createSortedSet
public static java.util.SortedSet createSortedSet(java.lang.String fullType, java.util.Collection collection)
- Creates a SortedSet and initiliazes it with an existing Collection.
createPrefSortedSet
public static java.util.SortedSet createPrefSortedSet()
- Creates a SortedSet which type is defined in the configuration file.
The property is 'preferredEmptySortedSet'.
createPrefSortedSet
public static java.util.SortedSet createPrefSortedSet(java.util.Collection collection)
- Creates a SortedSet which type is defined in the configuration file
and initializes it with an existing Collection.
The property is 'preferredFilledSortedSet'.
loadClass
private static java.lang.Class loadClass(java.lang.String type, boolean isStandard, java.lang.String defaultType)
createDefault
private static java.lang.Object createDefault(java.lang.String defaultType)
createDefault
private static java.lang.Object createDefault(java.lang.String defaultType, java.util.Collection collection)
createDefault
private static java.lang.Object createDefault(java.lang.String defaultType, java.util.Map map)
create
private static java.lang.Object create(java.lang.String type, boolean isStandard, java.lang.String defaultType)
create
private static java.lang.Object create(java.lang.String type, java.util.Map map, boolean isStandard, java.lang.String defaultType)
create
private static java.lang.Object create(java.lang.String type, java.util.Collection collection, boolean isStandard, java.lang.String defaultType)
create
private static java.lang.Object create(java.lang.String type, java.lang.Object collection, java.lang.Class collectionType, boolean isStandard, java.lang.String defaultType)
errorMessage
private static java.lang.String errorMessage(java.lang.String diagnostic, java.lang.Exception e)
|
|||||||||
| Home >> All >> org >> metacosm >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.metacosm.util.CollectionFactory