KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*_############################################################################
2   _##
3   _## SNMP4J-AgentX - AgentXRegion.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 org.snmp4j.agent.DefaultMOScope;
26 import org.snmp4j.smi.OID;
27
28 public class AgentXRegion extends DefaultMOScope implements Comparable JavaDoc {
29
30   private boolean singleOID;
31   private byte rangeSubID;
32
33   public AgentXRegion(OID lowerBound, OID upperBound) {
34     super(lowerBound, true, upperBound, false);
35   }
36
37   public AgentXRegion(AgentXRegion other) {
38     super(other.getLowerBound(), other.isLowerIncluded(),
39           other.getUpperBound(), other.isUpperIncluded());
40     this.singleOID = other.singleOID;
41     this.rangeSubID = other.rangeSubID;
42   }
43
44   public byte getRangeSubID() {
45     return rangeSubID;
46   }
47
48   public boolean isSingleOID() {
49     return singleOID;
50   }
51
52   public void setRangeSubID(byte rangeSubID) {
53     this.rangeSubID = rangeSubID;
54   }
55
56   public void setSingleOID(boolean singleOID) {
57     this.singleOID = singleOID;
58   }
59
60   public int getUpperBoundSubID() {
61     if (rangeSubID != 0) {
62       return upperBound.get(rangeSubID-1);
63     }
64     return 0;
65   }
66
67   public boolean isRange() {
68     return (rangeSubID > 0);
69   }
70
71   public boolean isEmpty() {
72     return (lowerBound.compareTo(upperBound) >= 0);
73   }
74
75   public int getLowerBoundSubID() {
76     if (rangeSubID != 0) {
77       return lowerBound.get(rangeSubID-1);
78     }
79     return 0;
80   }
81
82   public int compareTo(Object JavaDoc o) {
83     AgentXRegion other = (AgentXRegion)o;
84     int c = lowerBound.compareTo(other.lowerBound);
85     if (c == 0) {
86       c = upperBound.compareTo(other.upperBound);
87       if (c == 0) {
88         c = rangeSubID - other.rangeSubID;
89       }
90     }
91     return c;
92   }
93
94   public String JavaDoc toString() {
95     return getClass().getName()+"[lowerBound="+lowerBound+
96         ",lowerIncluded="+lowerIncluded+
97         ",upperBound="+upperBound+
98         ",upperIncluded="+upperIncluded+
99         ",rangeSubID="+rangeSubID+
100         ",upperBoundSubID="+getUpperBoundSubID()+"]";
101   }
102 }
103
Popular Tags