1 22 23 package org.snmp4j.agent.agentx.master; 24 25 import org.snmp4j.agent.agentx.AgentXRegion; 26 import org.snmp4j.smi.OctetString; 27 import org.snmp4j.smi.OID; 28 29 public class AgentXRegEntry implements Comparable { 30 31 private AgentXMasterSession session; 32 private AgentXRegion region; 33 private int priority; 34 private OctetString context; 35 private int timeout; 36 private OID id; 37 38 public AgentXRegEntry(AgentXMasterSession session, 39 AgentXRegion region, 40 int priority, 41 OctetString context, 42 int timeout) { 43 this.session = session; 44 this.region = region; 45 this.priority = priority; 46 this.context = context; 47 if (this.context == null) { 48 this.context = new OctetString(); 49 } 50 this.timeout = timeout; 51 } 52 53 public OctetString getContext() { 54 return context; 55 } 56 57 public int getPriority() { 58 return priority; 59 } 60 61 public AgentXRegion getRegion() { 62 return region; 63 } 64 65 public AgentXMasterSession getSession() { 66 return session; 67 } 68 69 public int getSpecific() { 70 return region.getLowerBound().size(); 71 } 72 73 public int getTimeout() { 74 return timeout; 75 } 76 77 public OID getId() { 78 return id; 79 } 80 81 88 public int compareTo(Object o) { 89 AgentXRegEntry other = (AgentXRegEntry)o; 90 int diff = other.getSpecific() - getSpecific(); 91 if (diff == 0) { 92 diff = getPriority() - other.getPriority(); 93 } 94 100 return diff; 101 } 102 103 public boolean equals(Object obj) { 104 if (obj instanceof AgentXRegEntry) { 105 AgentXRegEntry other = (AgentXRegEntry)obj; 106 return session.equals(other.session) && 107 region.equals(other.region) && 108 (compareTo(other) == 0); 109 } 110 return false; 111 } 112 113 public int hashCode() { 114 return session.getSessionID() + region.getLowerBound().hashCode(); 115 } 116 117 public void setId(OID id) { 118 this.id = id; 119 } 120 121 public String toString() { 122 return getClass().getName()+"[region="+region+ 123 ",priority="+priority+ 124 ",context="+context+ 125 ",timeout="+timeout+ 126 ",id="+id+ 127 ",session="+session+"]"; 128 } 129 130 } 131 | Popular Tags |