com.sun.sgs.impl.util
Interface BindingKeyedMap<V>

Type Parameters:
V - the type for the map's values
All Superinterfaces:
Map<String,V>
All Known Implementing Classes:
BindingKeyedMapImpl

public interface BindingKeyedMap<V>
extends Map<String,V>

A persistent Map that uses service bindings in the data service to store key/value mappings. Values stored in this map must implement Serializable, and may (but are not required to) implement ManagedObject. This map does not permit null keys or values.

A value is stored in the data service using its associated key (a String) as a suffix to the keyPrefix specified during construction (see BindingKeyedCollections.newMap(java.lang.String)). If a value implements Serializable, but does not implement ManagedObject, the value will be wrapped in an instance of ManagedSerializable when storing it in the data service. Note: users of this map must use this map's APIs to avoid leaking wrappers for non-managed, serializable objects.

The iterators of an Map.entrySet(), Map.keySet(), or Map.values() view of this map implement Serializable. None of the iterators of this map throw ConcurrentModificationException for any of their methods.

The iterators of an Map.entrySet() or Map.values() view of this map throw ObjectNotFoundException during an attempt to access (via the Iterator.next method) a ManagedObject that has been removed from the DataManager.

Note: This map is parameterized by value type only. A String is the only valid key type for a BindingKeyedMap.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Method Summary
 void clear()
          Removes all mappings from this map.
 boolean containsValue(Object value)
          Returns true if this map maps one or more keys to the specified value.
 V get(Object key)
          Returns the value to which the specified key is mapped, or null if this map contains no mapping for this key.
 String getKeyPrefix()
          Returns the key prefix for this map.
 V put(String key, V value)
          Associates the specified value with the specified key in this map.
 boolean putOverride(String key, V value)
          Associates the specified key with the specified value, and returns true if the key was previously mapped.
 V remove(Object key)
          Removes the mapping for key from this map if it is present, and returns the value to which the key was previously mapped, or null if this map contains no mapping for this key.
 boolean removeOverride(String key)
          Removes the specified key and associated value from the map, and returns true if the key was previously mapped.
 int size()
          Returns the number of key-value mappings in this map.
 
Methods inherited from interface java.util.Map
containsKey, entrySet, equals, hashCode, isEmpty, keySet, putAll, values
 

Method Detail

getKeyPrefix

String getKeyPrefix()
Returns the key prefix for this map.

Returns:
the key prefix for this map

put

V put(String key,
      V value)
Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the previous value is replaced by the specified value.

Specified by:
put in interface Map<String,V>
Parameters:
key - a key
value - a value
Returns:
the previous value associated with key, or null if there was no such mapping
Throws:
IllegalArgumentException - if value does not implement Serializable
ObjectNotFoundException - if value is a managed object that has been removed from the DataManager, or the key was previously mapped to a ManagedObject that has been removed

putOverride

boolean putOverride(String key,
                    V value)
Associates the specified key with the specified value, and returns true if the key was previously mapped. This method will not throw ObjectNotFoundException if the key was previously mapped to a ManagedObject that has been removed from the DataManager.

Parameters:
key - a key
value - a value
Returns:
true if the key was previously mapped, and false otherwise
Throws:
IllegalArgumentException - if value does not implement Serializable
ObjectNotFoundException - if value is a managed object that has been removed from the DataManager

get

V get(Object key)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for this key.

Specified by:
get in interface Map<String,V>
Parameters:
key - a key
Returns:
the value to which the specified key is mapped, or null if there is no such mapping
Throws:
ClassCastException - if key is not an instance of String
ObjectNotFoundException - if the key is mapped to a ManagedObject that has been removed

remove

V remove(Object key)
Removes the mapping for key from this map if it is present, and returns the value to which the key was previously mapped, or null if this map contains no mapping for this key.

Specified by:
remove in interface Map<String,V>
Parameters:
key - a key
Returns:
the value to which the specified key was previously mapped, or null if there is no such mapping
Throws:
ClassCastException - if key is not an instance of String
ObjectNotFoundException - if the key was previously mapped to a ManagedObject that has been removed

removeOverride

boolean removeOverride(String key)
Removes the specified key and associated value from the map, and returns true if the key was previously mapped. This method will not throw ObjectNotFoundException if the key was previously mapped to a ManagedObject that has been removed from the DataManager.

Parameters:
key - a key
Returns:
true if the key was previously mapped, and false otherwise

containsValue

boolean containsValue(Object value)
Returns true if this map maps one or more keys to the specified value. Values that have been removed from the data manager will be ignored.

Specified by:
containsValue in interface Map<String,V>
Parameters:
value - value whose presence in this map is to be tested
Returns:
true if this map maps one or more keys to the specified value
Throws:
ClassCastException - if value is of an inappropriate type for this map (optional)

clear

void clear()
Removes all mappings from this map. This operation may be expensive because all of the map entries need to be traversed.

Specified by:
clear in interface Map<String,V>

size

int size()
Returns the number of key-value mappings in this map. This operation may be expensive because all of the map entries may need to be traversed to determine the map's size.

Specified by:
size in interface Map<String,V>
Returns:
the number of key-value mappings in this map

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved