Package org.exolab.castor.mapping
Interface MapHandler
- All Known Implementing Classes:
J1MapHandler
,J2MapHandler
public interface MapHandler
A Map handler for adding and retreiving key-value pairs from
A map. A map handler is instantiated only once, must be thread
safe and not use any synchronization.
- Version:
- $Revision: 5951 $ $Date: 2004-02-13 14:34:10 -0700 (Fri, 13 Feb 2004) $
- Author:
- Keith Visco
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the map of all key-value pairs.create()
Creates a new Instance of the map represented by this MapHandler.Returns an enumeration of all the objects in the Map.Returns the object associated with the given key.Returns an enumeration of all the keys in the Map.Adds the given key-value pair to the map.int
Returns the number of elements (key-value) in the map.
-
Method Details
-
create
Object create()Creates a new Instance of the map represented by this MapHandler.- Returns:
- the new map.
-
put
Adds the given key-value pair to the map. Keys must be unique. Adding a key-value pair to the map, when an existing association for that key already exists will cause the existing association to be overwritten. The map is provided as a parameter and is returned as the return value if the returned map is a different object. That way the handler can create a new map if necessary.- Parameters:
map
- the map, null if no map has been created yet.key
- the key for the object.object
- the object to add to the map.- Returns:
- The map with the new object if a different instance than the map parameter, null otherwise
- Throws:
ClassCastException
- The MapHandler does not support maps of the given type.
-
elements
Returns an enumeration of all the objects in the Map.- Parameters:
map
- The map instance for which to return the enumeration of elements for.- Returns:
- An enumeration of all the elements in the Map.
- Throws:
ClassCastException
- The MapHandler does not support collections of this type
-
keys
Returns an enumeration of all the keys in the Map.- Parameters:
map
- The map instance for which to return the enumeration of keys.- Returns:
- An enumeration of all the keys in the Map.
- Throws:
ClassCastException
- The MapHandler does not support collections of this type
-
size
Returns the number of elements (key-value) in the map.- Parameters:
map
- the map.- Returns:
- Number of key-value associations in the Map
- Throws:
ClassCastException
- The MapHandler does not support collections of the given type.
-
clear
Clears the map of all key-value pairs.- Parameters:
map
- the map to clear.- Throws:
ClassCastException
- The MapHandler does not support collections of the given type.
-
get
Returns the object associated with the given key.- Parameters:
map
- the map to return the object from.key
- the key for the object.- Returns:
- the object associated with the given key, or null if no association was found in the given map.
- Throws:
ClassCastException
- The MapHandler does not support maps of the given type.
-