1 25 package org.jrobin.mrtg.client; 26 27 import java.util.Comparator ; 28 import java.util.Date ; 29 30 class LinkInfo implements TreeElementInfo { 31 private String ifDescr, ifAlias, descr; 32 private int ifIndex, samplingInterval; 33 private boolean active; 34 private Date lastSampleTime; 35 private long ifInOctets, ifOutOctets; 36 private int sampleCount; 37 38 String getIfDescr() { 39 return ifDescr; 40 } 41 42 void setIfDescr(String ifDescr) { 43 this.ifDescr = ifDescr; 44 } 45 46 String getIfAlias() { 47 return ifAlias; 48 } 49 50 void setIfAlias(String ifAlias) { 51 this.ifAlias = ifAlias; 52 } 53 54 String getDescr() { 55 return descr; 56 } 57 58 void setDescr(String descr) { 59 this.descr = descr; 60 } 61 62 int getIfIndex() { 63 return ifIndex; 64 } 65 66 void setIfIndex(int ifIndex) { 67 this.ifIndex = ifIndex; 68 } 69 70 int getSamplingInterval() { 71 return samplingInterval; 72 } 73 74 void setSamplingInterval(int samplingInterval) { 75 this.samplingInterval = samplingInterval; 76 } 77 78 boolean isActive() { 79 return active; 80 } 81 82 void setActive(boolean active) { 83 this.active = active; 84 } 85 86 Date getLastSampleTime() { 87 return lastSampleTime; 88 } 89 90 void setLastSampleTime(Date lastSampleTime) { 91 this.lastSampleTime = lastSampleTime; 92 } 93 94 long getIfInOctets() { 95 return ifInOctets; 96 } 97 98 void setIfInOctets(long ifInOctets) { 99 this.ifInOctets = ifInOctets; 100 } 101 102 long getIfOutOctets() { 103 return ifOutOctets; 104 } 105 106 void setIfOutOctets(long ifOutOctets) { 107 this.ifOutOctets = ifOutOctets; 108 } 109 110 int getSampleCount() { 111 return sampleCount; 112 } 113 114 void setSampleCount(int sampleCount) { 115 this.sampleCount = sampleCount; 116 } 117 118 public String toString() { 119 return ifDescr + " [" + ifIndex + "]"; 120 } 121 122 public String getInfo() { 123 StringBuffer b = new StringBuffer (); 124 b.append("Interface description: " + getIfDescr() + "\n"); 125 b.append("MRTG description: " + getDescr() + "\n"); 126 b.append("Router alias: " + getIfAlias() + "\n"); 127 b.append("Interface index: " + getIfIndex() + "\n"); 128 b.append("Sampling interval: " + getSamplingInterval() + " sec\n"); 129 b.append("Active: " + isActive() + "\n\n"); 130 b.append("Last sample time: " + getLastSampleTime() + "\n"); 131 b.append("Last sample input octets: " + getIfInOctets() + "\n"); 132 b.append("Last sample output octets: " + getIfOutOctets() + "\n"); 133 b.append("Samples collected: " + getSampleCount() + "\n"); 134 return b.toString(); 135 } 136 137 static Comparator getComparator() { 138 return new Comparator () { 139 public int compare(Object o1, Object o2) { 140 LinkInfo link1 = (LinkInfo) o1; 141 LinkInfo link2 = (LinkInfo) o2; 142 return link1.getIfDescr().compareToIgnoreCase(link2.getIfDescr()); 143 } 144 }; 145 } 146 147 public boolean equals(Object obj) { 148 if(obj instanceof LinkInfo) { 149 Comparator c = getComparator(); 150 return c.compare(this, obj) == 0; 151 } 152 return false; 153 } 154 } 155 | Popular Tags |