001 package users.events;
002
003 import users.*;
004
005 import java.util.*;
006
007 /**
008 * An event indicating changes in a user's capabilities.
009 *
010 * @see User
011 * @see Capability
012 * @see CapabilityDataListener
013 *
014 * @author Steffen Zschaler
015 * @version 2.0 05/05/1999
016 * @since v2.0
017 */
018 public class CapabilityDataEvent extends EventObject {
019
020 /**
021 * The capabilities that participated in the change.
022 *
023 * @serial
024 */
025 private Set m_stCapNames;
026
027 /**
028 * Create a new CapabilityDataEvent with a source and a set of affected capabilities
029 *
030 * @param source the source of the event, usually a User object.
031 * @param stCapNames the set of capabilities that changed.
032 */
033 public CapabilityDataEvent(Object source, Set stCapNames) {
034 super(source);
035
036 m_stCapNames = stCapNames;
037 }
038
039 /**
040 * Test whether a given capability is affected by this event.
041 *
042 * @param sCapName the name of the capability to be tested
043 *
044 * @return true if the given capability is affected by this event.
045 *
046 * @override Never
047 */
048 public boolean affectsCapability(String sCapName) {
049 return m_stCapNames.contains(sCapName);
050 }
051
052 /**
053 * Return a capability if it is affected by this event.
054 *
055 * @param sCapName the name of the capability to be returned.
056 *
057 * @return the capability with the given name, if it is affected by this event.
058 * <code>null</code> otherwise.
059 *
060 * @override Never
061 */
062 public Capability getCapability(String sCapName) {
063 return ((affectsCapability(sCapName)) ? (((User)getSource()).getCapability(sCapName)) : (null));
064 }
065
066 }