org.apache.directory.server.protocol.shared.chain.impl
Class ContextBase

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by org.apache.directory.server.protocol.shared.chain.impl.ContextBase
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map, Context
Direct Known Subclasses:
ChangePasswordContext, DnsContext, KdcContext

public class ContextBase
extends java.util.HashMap
implements Context

Convenience base class for Context implementations.

In addition to the minimal functionality required by the Context interface, this class implements the recommended support for Attribute-Property Transparency

. This is implemented by analyzing the available JavaBeans properties of this class (or its subclass), exposes them as key-value pairs in the Map, with the key being the name of the property itself.

IMPLEMENTATION NOTE - Because empty is a read-only property defined by the Map interface, it may not be utilized as an attribute key or property name.

Version:
$Revision: 434432 $ $Date: 2006-08-24 18:52:26 +0200 (Thu, 24 Aug 2006) $
Author:
Apache Directory Project
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
ContextBase()
          Default, no argument constructor.
ContextBase(java.util.Map map)
          Initialize the contents of this Context by copying the values from the specified Map.
 
Method Summary
 void clear()
          Override the default Map behavior to clear all keys and values except those corresponding to JavaBeans properties.
 boolean containsValue(java.lang.Object value)
          Override the default Map behavior to return true if the specified value is present in either the underlying Map or one of the local property values.
 java.util.Set entrySet()
          Override the default Map behavior to return a Set that meets the specified default behavior except for attempts to remove the key for a property of the Context implementation class, which will throw UnsupportedOperationException.
 java.lang.Object get(java.lang.Object key)
          Override the default Map behavior to return the value of a local property if the specified key matches a local property name.
 boolean isEmpty()
          Override the default Map behavior to return true if the underlying Map only contains key-value pairs for local properties (if any).
 java.util.Set keySet()
          Override the default Map behavior to return a Set that meets the specified default behavior except for attempts to remove the key for a property of the Context implementation class, which will throw UnsupportedOperationException.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Override the default Map behavior to set the value of a local property if the specified key matches a local property name.
 void putAll(java.util.Map map)
          Override the default Map behavior to call the put() method individually for each key-value pair in the specified Map.
 java.lang.Object remove(java.lang.Object key)
          Override the default Map behavior to throw UnsupportedOperationException on any attempt to remove a key that is the name of a local property.
 java.util.Collection values()
          Override the default Map behavior to return a Collection that meets the specified default behavior except for attempts to remove the key for a property of the Context implementation class, which will throw UnsupportedOperationException.
 
Methods inherited from class java.util.HashMap
clone, containsKey, size
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, equals, hashCode, size
 

Constructor Detail

ContextBase

public ContextBase()
Default, no argument constructor.


ContextBase

public ContextBase(java.util.Map map)

Initialize the contents of this Context by copying the values from the specified Map. Any keys in map that correspond to local properties will cause the setter method for that property to be called.

Parameters:
map - Map whose key-value pairs are added
Throws:
java.lang.IllegalArgumentException - if an exception is thrown writing a local property value
java.lang.UnsupportedOperationException - if a local property does not have a write method.
Method Detail

clear

public void clear()

Override the default Map behavior to clear all keys and values except those corresponding to JavaBeans properties.

Specified by:
clear in interface java.util.Map
Overrides:
clear in class java.util.HashMap

containsValue

public boolean containsValue(java.lang.Object value)

Override the default Map behavior to return true if the specified value is present in either the underlying Map or one of the local property values.

Specified by:
containsValue in interface java.util.Map
Overrides:
containsValue in class java.util.HashMap
Throws:
java.lang.IllegalArgumentException - if a property getter throws an exception

entrySet

public java.util.Set entrySet()

Override the default Map behavior to return a Set that meets the specified default behavior except for attempts to remove the key for a property of the Context implementation class, which will throw UnsupportedOperationException.

Specified by:
entrySet in interface java.util.Map
Overrides:
entrySet in class java.util.HashMap

get

public java.lang.Object get(java.lang.Object key)

Override the default Map behavior to return the value of a local property if the specified key matches a local property name.

IMPLEMENTATION NOTE - If the specified key identifies a write-only property, null will arbitrarily be returned, in order to avoid difficulties implementing the contracts of the Map interface.

Specified by:
get in interface java.util.Map
Overrides:
get in class java.util.HashMap
Parameters:
key - Key of the value to be returned
Throws:
java.lang.IllegalArgumentException - if an exception is thrown reading this local property value
java.lang.UnsupportedOperationException - if this local property does not have a read method.

isEmpty

public boolean isEmpty()

Override the default Map behavior to return true if the underlying Map only contains key-value pairs for local properties (if any).

Specified by:
isEmpty in interface java.util.Map
Overrides:
isEmpty in class java.util.HashMap

keySet

public java.util.Set keySet()

Override the default Map behavior to return a Set that meets the specified default behavior except for attempts to remove the key for a property of the Context implementation class, which will throw UnsupportedOperationException.

Specified by:
keySet in interface java.util.Map
Overrides:
keySet in class java.util.HashMap

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)

Override the default Map behavior to set the value of a local property if the specified key matches a local property name.

Specified by:
put in interface java.util.Map
Overrides:
put in class java.util.HashMap
Parameters:
key - Key of the value to be stored or replaced
value - New value to be stored
Throws:
java.lang.IllegalArgumentException - if an exception is thrown reading or wrting this local property value
java.lang.UnsupportedOperationException - if this local property does not have both a read method and a write method

putAll

public void putAll(java.util.Map map)

Override the default Map behavior to call the put() method individually for each key-value pair in the specified Map.

Specified by:
putAll in interface java.util.Map
Overrides:
putAll in class java.util.HashMap
Parameters:
map - Map containing key-value pairs to store (or replace)
Throws:
java.lang.IllegalArgumentException - if an exception is thrown reading or wrting a local property value
java.lang.UnsupportedOperationException - if a local property does not have both a read method and a write method

remove

public java.lang.Object remove(java.lang.Object key)

Override the default Map behavior to throw UnsupportedOperationException on any attempt to remove a key that is the name of a local property.

Specified by:
remove in interface java.util.Map
Overrides:
remove in class java.util.HashMap
Parameters:
key - Key to be removed
Throws:
java.lang.UnsupportedOperationException - if the specified key matches the name of a local property

values

public java.util.Collection values()

Override the default Map behavior to return a Collection that meets the specified default behavior except for attempts to remove the key for a property of the Context implementation class, which will throw UnsupportedOperationException.

Specified by:
values in interface java.util.Map
Overrides:
values in class java.util.HashMap


Copyright © 2003-2010 Apache Software Foundation. All Rights Reserved.