1 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 { 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 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 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 |