org.opennms.netmgt.eventd.datablock
Class EventKey

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap<String,Object>
              extended by org.opennms.netmgt.eventd.datablock.EventKey
All Implemented Interfaces:
Serializable, Cloneable, Comparable<EventKey>, Map<String,Object>

public class EventKey
extends LinkedHashMap<String,Object>
implements Serializable, Comparable<EventKey>

 The key for an event - it extends the Hashtable and basically is a
  map of name/value pairs of the 'maskelements' block in the event.
  While the names are maskelement names,
  - if the event is a 'org.opennms.netmgt.xml.eventconf.Event',
    the maskvalue list is taken as the value
  - if the event is an 'org.opennms.netmgt.xml.event.Event', 
    the value in the event for the mask element is used as the value.
 
  This hashtable is pretty much constant once constructed - so the hashcode
  is evaluated once at construction and reused(if new values are added or
  values changed, hashcode is re-evaluated)
 

Author:
Sowmya Nataraj , OpenNMS.org
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
static String TAG_HOST
          The event host xml tag
static String TAG_INTERFACE
          The event interface xml tag
static String TAG_NODEID
          The event nodeid xml tag
static String TAG_SERVICE
          The event service xml tag
static String TAG_SNMP_COMMUNITY
          The SNMP community xml tag
static String TAG_SNMP_EID
          The SNMP EID xml tag
static String TAG_SNMP_GENERIC
          The SNMP generic xml tag
static String TAG_SNMP_SPECIFIC
          The SNMP specific xml tag
static String TAG_SNMPHOST
          The event snmp host xml tag
static String TAG_SOURCE
          The event source xml tag
static String TAG_UEI
          The UEI xml tag
 
Constructor Summary
EventKey()
          Default constructor for this class
EventKey(Event event)
          Constructor for this class
EventKey(Event event)
          Constructor for this class
EventKey(int initCapacity)
          Constructor for this class
EventKey(int initCapacity, float loadFactor)
          Constructor for this class
EventKey(Map<String,Object> maskelements)
          Constructor for this class
 
Method Summary
 void clear()
          Override to re-evaluate hashcode
 int compareTo(EventKey obj)
          Implementation for the Comparable interface
 void evaluateHashCode()
           Evaluate the hash code for this object This hashtable gets constructed once and does not really change - so hashcode is only evaluated at construction time.
static String getMaskElementValue(Event event, String mename)
           Get the value of the mask element for this event.
 int hashCode()
          Overrides the 'hashCode()' method in the superclass
 Object put(String key, Object value)
          Override to re-evaluate hashcode
 void putAll(Map<? extends String,? extends Object> m)
          Override to re-evaluate hashcode
 Object remove(Object key)
          Override to re-evaluate hashcode
 String toString()
          Returns a String equivalent of this object
 
Methods inherited from class java.util.LinkedHashMap
containsValue, get, removeEldestEntry
 
Methods inherited from class java.util.HashMap
clone, containsKey, entrySet, isEmpty, keySet, size, values
 
Methods inherited from class java.util.AbstractMap
equals
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, entrySet, equals, isEmpty, keySet, size, values
 

Field Detail

TAG_UEI

public static final String TAG_UEI
The UEI xml tag

See Also:
Constant Field Values

TAG_SOURCE

public static final String TAG_SOURCE
The event source xml tag

See Also:
Constant Field Values

TAG_NODEID

public static final String TAG_NODEID
The event nodeid xml tag

See Also:
Constant Field Values

TAG_HOST

public static final String TAG_HOST
The event host xml tag

See Also:
Constant Field Values

TAG_INTERFACE

public static final String TAG_INTERFACE
The event interface xml tag

See Also:
Constant Field Values

TAG_SNMPHOST

public static final String TAG_SNMPHOST
The event snmp host xml tag

See Also:
Constant Field Values

TAG_SERVICE

public static final String TAG_SERVICE
The event service xml tag

See Also:
Constant Field Values

TAG_SNMP_EID

public static final String TAG_SNMP_EID
The SNMP EID xml tag

See Also:
Constant Field Values

TAG_SNMP_SPECIFIC

public static final String TAG_SNMP_SPECIFIC
The SNMP specific xml tag

See Also:
Constant Field Values

TAG_SNMP_GENERIC

public static final String TAG_SNMP_GENERIC
The SNMP generic xml tag

See Also:
Constant Field Values

TAG_SNMP_COMMUNITY

public static final String TAG_SNMP_COMMUNITY
The SNMP community xml tag

See Also:
Constant Field Values
Constructor Detail

EventKey

public EventKey()
Default constructor for this class


EventKey

public EventKey(int initCapacity)
Constructor for this class

See Also:
Hashtable.Hashtable(int)

EventKey

public EventKey(int initCapacity,
                float loadFactor)
Constructor for this class

See Also:
Hashtable.Hashtable(int, float)

EventKey

public EventKey(Map<String,Object> maskelements)
Constructor for this class

Parameters:
maskelements - the maskelements that should form this key

EventKey

public EventKey(Event event)
Constructor for this class

Parameters:
event - the config event that this will be the key for

EventKey

public EventKey(Event event)
Constructor for this class

Parameters:
event - the event that this will be the key for
Method Detail

clear

public void clear()
Override to re-evaluate hashcode

Specified by:
clear in interface Map<String,Object>
Overrides:
clear in class LinkedHashMap<String,Object>
See Also:
Hashtable.clear()

put

public Object put(String key,
                  Object value)
Override to re-evaluate hashcode

Specified by:
put in interface Map<String,Object>
Overrides:
put in class HashMap<String,Object>
See Also:
Hashtable.put(Object, Object)

putAll

public void putAll(Map<? extends String,? extends Object> m)
Override to re-evaluate hashcode

Specified by:
putAll in interface Map<String,Object>
Overrides:
putAll in class HashMap<String,Object>
See Also:
Hashtable.putAll(Map)

remove

public Object remove(Object key)
Override to re-evaluate hashcode

Specified by:
remove in interface Map<String,Object>
Overrides:
remove in class HashMap<String,Object>
See Also:
Hashtable.remove(Object)

evaluateHashCode

public void evaluateHashCode()
 Evaluate the hash code for this object
 
  This hashtable gets constructed once and does not really change -
  so hashcode is only evaluated at construction time. Also, while
  the superclass uses just the entry set to calculate the hashcode,
  this uses both the names and their values in calculating the hashcode


compareTo

public int compareTo(EventKey obj)
Implementation for the Comparable interface

Specified by:
compareTo in interface Comparable<EventKey>
See Also:
Comparable.compareTo(Object)

hashCode

public int hashCode()
Overrides the 'hashCode()' method in the superclass

Specified by:
hashCode in interface Map<String,Object>
Overrides:
hashCode in class AbstractMap<String,Object>
Returns:
a hash code for this object

toString

public String toString()
Returns a String equivalent of this object

Overrides:
toString in class AbstractMap<String,Object>
Returns:
a String equivalent of this object

getMaskElementValue

public static String getMaskElementValue(Event event,
                                         String mename)
 Get the value of the mask element for this event.
  
 
 Note:
 
  The only event elements that can occur to
  uniquely identify an event are -
  uei, source, host, snmphost, nodeid, interface, service, id(SNMP EID), specific, generic, community

Returns:
value of the event element


Copyright © 2009. All Rights Reserved.