1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sf.asterisk;
18
19 import java.io.Serializable;
20
21 /***
22 * Represents the version of an Asterisk server.
23 *
24 * @since 0.2
25 * @author srt
26 * @version $Id: AsteriskVersion.java,v 1.1 2005/10/29 12:00:11 srt Exp $
27 */
28 public class AsteriskVersion implements Comparable, Serializable
29 {
30 private int version;
31 private String versionString;
32
33 /***
34 * Represents the Asterisk 1.0 series.
35 */
36 public static final AsteriskVersion ASTERISK_1_0 = new AsteriskVersion(100,
37 "Asterisk 1.0");
38
39 /***
40 * Represents the Asterisk 1.2 series.
41 */
42 public static final AsteriskVersion ASTERISK_1_2 = new AsteriskVersion(120,
43 "Asterisk 1.2");
44
45 /***
46 * Serial version identifier.
47 */
48 private static final long serialVersionUID = -5696160640576385797L;
49
50 private AsteriskVersion(int version, String versionString)
51 {
52 this.version = version;
53 this.versionString = versionString;
54 }
55
56 /***
57 * Returns <code>true</code> if this version is equal to or higher than
58 * the given version.
59 *
60 * @param o the version to compare to
61 * @return <code>true</code> if this version is equal to or higher than
62 * the given version.
63 */
64 public boolean isAtLeast(AsteriskVersion o)
65 {
66 if (version >= o.version)
67 {
68 return true;
69 }
70 else
71 {
72 return false;
73 }
74 }
75
76 public int compareTo(Object o)
77 {
78 int otherVersion;
79
80 otherVersion = ((AsteriskVersion) o).version;
81 if (version < otherVersion)
82 {
83 return -1;
84 }
85 else if (version > otherVersion)
86 {
87 return 1;
88 }
89 else
90 {
91 return 0;
92 }
93 }
94
95 public String toString()
96 {
97 return versionString;
98 }
99 }