SNMP Stack 4_12

uk.co.westhawk.snmp.event
Class TrapEvent

java.lang.Object
  |
  +--java.util.EventObject
        |
        +--uk.co.westhawk.snmp.event.TrapEvent
All Implemented Interfaces:
java.io.Serializable

public class TrapEvent
extends java.util.EventObject

The TrapEvent class. This class is delivered when a trap is received. Since traps cannot always be decoded, this event either contains the 'raw' bytes or the decoded trap pdu.

Version:
$Revision: 1.4 $ $Date: 2002/10/10 15:13:56 $
Author:
Birgit Arkesteijn
See Also:
Serialized Form

Field Summary
protected  boolean consumed
           
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
TrapEvent(java.lang.Object source, int v, java.lang.String hn, byte[] mess)
          The constructor for an undecoded trap event.
TrapEvent(java.lang.Object source, Pdu pdu)
          The constructor for a decoded trap event.
 
Method Summary
 void consume()
          Consumes this event so that it will not be send to any other listeners.
 java.lang.String getHostAddress()
          The IP address of the host where the trap came from.
 byte[] getMessage()
          The trap SNMP message in bytes.
 Pdu getPdu()
          The trap pdu.
 int getVersion()
          The SNMP version number of the trap.
 boolean isConsumed()
          Returns whether or not this event has been consumed.
 boolean isDecoded()
          Returns if this is a decoded trap event.
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

consumed

protected boolean consumed
Constructor Detail

TrapEvent

public TrapEvent(java.lang.Object source,
                 Pdu pdu)
The constructor for a decoded trap event. The SnmpContext classes will fire decoded trap events.
Parameters:
source - The source of the event
pdu - The trap pdu
See Also:
getPdu()

TrapEvent

public TrapEvent(java.lang.Object source,
                 int v,
                 java.lang.String hn,
                 byte[] mess)
The constructor for an undecoded trap event. The DefaultTrapContext class will fire undecoded trap events.
Parameters:
source - The source of the event
v - The SNMP version of the trap
hn - The IP address of the host where the trap came from
mess - The trap in bytes
See Also:
getVersion(), getHostAddress(), getMessage()
Method Detail

isDecoded

public boolean isDecoded()
Returns if this is a decoded trap event. If it is a decoded trap, then a Trap Pdu is available (see getPdu()). If it is an undecoded trap, then the version number, the hostAddress and the byte array is available.
Returns:
true if decoded trap, false if undecoded trap

getVersion

public int getVersion()
The SNMP version number of the trap. The version is part of an undecoded trap event.
Returns:
The version number.
See Also:
TrapEvent(Object, int, String, byte []), getHostAddress(), getMessage(), SnmpConstants.SNMP_VERSION_1, SnmpConstants.SNMP_VERSION_2c, SnmpConstants.SNMP_VERSION_3

getHostAddress

public java.lang.String getHostAddress()
The IP address of the host where the trap came from. The host address is part of an undecoded trap event.
Returns:
The IP address of the host or null.
See Also:
TrapEvent(Object, int, String, byte []), getVersion(), getMessage()

getMessage

public byte[] getMessage()
The trap SNMP message in bytes. This is a copy of the original message. The bytes are part of an undecoded trap event.
Returns:
The trap in bytes.
See Also:
TrapEvent(Object, int, String, byte []), getVersion(), getHostAddress()

getPdu

public Pdu getPdu()
The trap pdu. The pdu is part of a decoded trap event.
Returns:
The decoded Pdu.
See Also:
TrapEvent(Object, Pdu)

consume

public void consume()
Consumes this event so that it will not be send to any other listeners.

isConsumed

public boolean isConsumed()
Returns whether or not this event has been consumed.
See Also:
consume()

SNMP Stack 4_12