org.exolab.castor.mapping.handlers
Class J2MapHandler
java.lang.Object
org.exolab.castor.mapping.handlers.J2MapHandler
- MapHandler
public final class J2MapHandler
extends java.lang.Object
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.
$Revision: 1.1.1.1 $ $Date: 2003/03/03 07:08:28 $
void | clear(Object map) - Clears the map of all key-value pairs.
|
Object | create() - Creates a new Instance of the map represented by this MapHandler.
|
Enumeration | elements(Object map) - Returns an enumeration of all the objects in the Map.
|
Object | get(Object map, Object key) - Returns the object associated with the given key.
|
Enumeration | keys(Object map) - Returns an enumeration of all the keys in the Map.
|
Object | put(Object map, Object key, Object object) - Adds the given key-value pair to the map.
|
int | size(Object map) - Returns the number of elements (key-value) in the map.
|
clear
public void clear(Object map)
throws ClassCastException
Clears the map of all key-value pairs.
- clear in interface MapHandler
create
public Object create()
Creates a new Instance of the map represented by this MapHandler.
- create in interface MapHandler
elements
public Enumeration elements(Object map)
throws ClassCastException
Returns an enumeration of all the objects in the Map.
- elements in interface MapHandler
map
- The map instance for which to return the enumeration
of elements for.
- An enumeration of all the elements in the Map.
get
public Object get(Object map,
Object key)
throws ClassCastException
Returns the object associated with the given key.
- get in interface MapHandler
map
- the map to return the object from.key
- the key for the object.
- the object associated with the given key, or null
if no association was found in the given map.
keys
public Enumeration keys(Object map)
throws ClassCastException
Returns an enumeration of all the keys in the Map.
- keys in interface MapHandler
map
- The map instance for which to return the enumeration
of keys.
- An enumeration of all the keys in the Map.
put
public Object put(Object map,
Object key,
Object object)
throws ClassCastException
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.
- put in interface MapHandler
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.
- The map with the new object if a different
instance than the map parameter, null otherwise
size
public int size(Object map)
throws ClassCastException
Returns the number of elements (key-value) in the map.
- size in interface MapHandler
- Number of key-value associations in the Map
Intalio Inc. (C) 1999-2003. All rights reserved http://www.intalio.com