KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > agent > agentx > AgentXGetBulkPDU


1 /*_############################################################################
2   _##
3   _## SNMP4J-AgentX - AgentXGetBulkPDU.java
4   _##
5   _## Copyright (C) 2005-2007 Frank Fock (SNMP4J.org)
6   _##
7   _## This program is free software; you can redistribute it and/or modify
8   _## it under the terms of the GNU General Public License version 2 as
9   _## published by the Free Software Foundation.
10   _##
11   _## This program is distributed in the hope that it will be useful,
12   _## but WITHOUT ANY WARRANTY; without even the implied warranty of
13   _## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14   _## GNU General Public License for more details.
15   _##
16   _## You should have received a copy of the GNU General Public License
17   _## along with this program; if not, write to the Free Software
18   _## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19   _## MA 02110-1301 USA
20   _##
21   _##########################################################################*/

22
23 package org.snmp4j.agent.agentx;
24
25 import java.nio.ByteBuffer JavaDoc;
26 import java.io.IOException JavaDoc;
27 import org.snmp4j.agent.MOScope;
28 import org.snmp4j.smi.OctetString;
29
30 public class AgentXGetBulkPDU extends AgentXRequestPDU {
31
32   protected short maxRepetitions;
33   protected short nonRepeaters;
34
35   public AgentXGetBulkPDU(OctetString context,
36                           short maxRepetitions,
37                           short nonRepeaters,
38                           MOScope[] ranges) {
39     super(AGENTX_GETBULK_PDU, context, ranges);
40     this.maxRepetitions = maxRepetitions;
41     this.nonRepeaters = nonRepeaters;
42   }
43
44   public AgentXGetBulkPDU(AgentXMessageHeader header) {
45     super(header);
46     if (header.getType() != AGENTX_GETBULK_PDU) {
47       throw new IllegalArgumentException JavaDoc();
48     }
49   }
50
51   public short getMaxRepetitions() {
52     return maxRepetitions;
53   }
54
55   public short getNonRepeaters() {
56     return nonRepeaters;
57   }
58
59   public void setMaxRepetitions(short maxRepetitions) {
60     this.maxRepetitions = maxRepetitions;
61   }
62
63   public void setNonRepeaters(short nonRepeaters) {
64     this.nonRepeaters = nonRepeaters;
65   }
66
67   protected void decodeAfterContext(ByteBuffer JavaDoc buf, int length) throws IOException JavaDoc {
68     nonRepeaters = buf.getShort();
69     maxRepetitions = buf.getShort();
70     super.decodeAfterContext(buf, length);
71   }
72
73   protected void encodeAfterContext(ByteBuffer JavaDoc buf) {
74     buf.putShort(nonRepeaters);
75     buf.putShort(maxRepetitions);
76     super.encodeAfterContext(buf);
77   }
78
79   protected int getAfterContextLength() {
80     return AgentXProtocol.AGENTX_INT_SIZE + super.getAfterContextLength();
81   }
82
83   protected String JavaDoc toStringExtMembers() {
84     return super.toStringExtMembers()+",nonRepeaters="+nonRepeaters+
85         ",maxRepetitions="+maxRepetitions;
86   }
87
88 }
89
Popular Tags