KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jrobin > mrtg > client > LinkInfo


1 /* ============================================================
2  * JRobin : Pure java implementation of RRDTool's functionality
3  * ============================================================
4  *
5  * Project Info: http://www.jrobin.org
6  * Project Lead: Sasa Markovic (saxon@jrobin.org);
7  *
8  * (C) Copyright 2003, by Sasa Markovic.
9  *
10  * Developers: Sasa Markovic (saxon@jrobin.org)
11  * Arne Vandamme (cobralord@jrobin.org)
12  *
13  * This library is free software; you can redistribute it and/or modify it under the terms
14  * of the GNU Lesser General Public License as published by the Free Software Foundation;
15  * either version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
18  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  * See the GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License along with this
22  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
23  * Boston, MA 02111-1307, USA.
24  */

25 package org.jrobin.mrtg.client;
26
27 import java.util.Comparator JavaDoc;
28 import java.util.Date JavaDoc;
29
30 class LinkInfo implements TreeElementInfo {
31     private String JavaDoc ifDescr, ifAlias, descr;
32     private int ifIndex, samplingInterval;
33     private boolean active;
34     private Date JavaDoc lastSampleTime;
35     private long ifInOctets, ifOutOctets;
36     private int sampleCount;
37
38     String JavaDoc getIfDescr() {
39         return ifDescr;
40     }
41
42     void setIfDescr(String JavaDoc ifDescr) {
43         this.ifDescr = ifDescr;
44     }
45
46     String JavaDoc getIfAlias() {
47         return ifAlias;
48     }
49
50     void setIfAlias(String JavaDoc ifAlias) {
51         this.ifAlias = ifAlias;
52     }
53
54     String JavaDoc getDescr() {
55         return descr;
56     }
57
58     void setDescr(String JavaDoc 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 JavaDoc getLastSampleTime() {
87         return lastSampleTime;
88     }
89
90     void setLastSampleTime(Date JavaDoc 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 JavaDoc toString() {
119         return ifDescr + " [" + ifIndex + "]";
120     }
121
122     public String JavaDoc getInfo() {
123         StringBuffer JavaDoc b = new StringBuffer JavaDoc();
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 JavaDoc getComparator() {
138         return new Comparator JavaDoc() {
139             public int compare(Object JavaDoc o1, Object JavaDoc 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 JavaDoc obj) {
148         if(obj instanceof LinkInfo) {
149             Comparator JavaDoc c = getComparator();
150             return c.compare(this, obj) == 0;
151         }
152         return false;
153     }
154 }
155
Popular Tags