- java.lang.Object
-
- org.snmp4j.tools.console.SnmpCommand
-
- All Implemented Interfaces:
java.lang.Runnable
,java.util.EventListener
,CommandResponder
,TransportListener
public class SnmpCommand extends java.lang.Object implements java.lang.Runnable, CommandResponder, TransportListener
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
SnmpCommand.SnmpCommandMessageDispatcher
-
Field Summary
Fields Modifier and Type Field Description protected int
operation
-
Constructor Summary
Constructors Constructor Description SnmpCommand(java.lang.String command, java.util.Map<java.lang.String,java.util.List<java.lang.Object>> args)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
example(java.lang.String prefix, java.lang.String command)
java.lang.String
help(java.lang.String prefix, java.lang.String command, boolean listOptionsDetails, boolean withDescription)
int
listen()
static void
main(java.lang.String[] args)
protected static void
printReport(PDU response)
static void
printUsage()
protected static void
printVariableBindings(PDU response)
protected static void
printVersion()
void
processMessage(TransportMapping<?> sourceTransport, Address destAddress, byte[] message)
<A extends Address>
voidprocessMessage(TransportMapping<? super A> sourceTransport, A incomingAddress, java.nio.ByteBuffer wholeMessage, TransportStateReference tmStateReference)
Processes an incoming message.<A extends Address>
voidprocessPdu(CommandResponderEvent<A> e)
Process an incoming request, report or notification PDU.void
run()
PDU
send()
static java.lang.String
spaces(int n)
int
table()
-
-
-
Method Detail
-
help
public java.lang.String help(java.lang.String prefix, java.lang.String command, boolean listOptionsDetails, boolean withDescription)
-
example
public java.lang.String example(java.lang.String prefix, java.lang.String command)
-
spaces
public static java.lang.String spaces(int n)
-
send
public PDU send() throws java.io.IOException
- Throws:
java.io.IOException
-
printReport
protected static void printReport(PDU response)
-
processPdu
public <A extends Address> void processPdu(CommandResponderEvent<A> e)
Description copied from interface:CommandResponder
Process an incoming request, report or notification PDU.- Specified by:
processPdu
in interfaceCommandResponder
- Type Parameters:
A
- type of the peerAddress
.- Parameters:
e
- aCommandResponderEvent
instance containing the PDU to process and some additional information returned by the message processing model that decoded the SNMP message.
-
printVariableBindings
protected static void printVariableBindings(PDU response)
-
table
public int table() throws java.io.IOException
- Throws:
java.io.IOException
-
listen
public int listen() throws java.io.IOException
- Throws:
java.io.IOException
-
main
public static void main(java.lang.String[] args)
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
printVersion
protected static void printVersion()
-
printUsage
public static void printUsage() throws java.io.IOException
- Throws:
java.io.IOException
-
processMessage
public <A extends Address> void processMessage(TransportMapping<? super A> sourceTransport, A incomingAddress, java.nio.ByteBuffer wholeMessage, TransportStateReference tmStateReference)
Description copied from interface:TransportListener
Processes an incoming message.- Specified by:
processMessage
in interfaceTransportListener
- Type Parameters:
A
- theAddress
type.- Parameters:
sourceTransport
- aTransportMapping
instance denoting the transport that received the message and that will be used to send any responses to this message. ThesourceTransport
has to support theincomingAddress
's implementation class.incomingAddress
- theAddress
from which the message has been received.wholeMessage
- anByteBuffer
containing the received message.tmStateReference
- the transport model state reference as defined by RFC 5590.
-
processMessage
public void processMessage(TransportMapping<?> sourceTransport, Address destAddress, byte[] message)
-
-