1 9 package org.jboss.portal.common.util; 10 11 15 public class Version 16 { 17 18 private String toString; 19 private final String name; 20 private final int major; 21 private final int minor; 22 private final int patch; 23 private final IntermediateMajor intermediateMajor; 24 private final int intermediateMinor; 25 26 public Version(String name, int major, int minor, int patch, IntermediateMajor intermediateMajor, int intermediateMinor) 27 { 28 this.name = name; 29 this.major = major; 30 this.minor = minor; 31 this.patch = patch; 32 this.intermediateMajor = intermediateMajor; 33 this.intermediateMinor = intermediateMinor; 34 this.toString = buildToString(); 35 } 36 37 40 public String getName() 41 { 42 return name; 43 } 44 45 48 public int getMajor() 49 { 50 return major; 51 } 52 53 56 public int getMinor() 57 { 58 return minor; 59 } 60 61 64 public int getPatch() 65 { 66 return patch; 67 } 68 69 72 public IntermediateMajor getIntermediateMajor() 73 { 74 return intermediateMajor; 75 } 76 77 81 public int getIntermediateMinor() 82 { 83 return intermediateMinor; 84 } 85 86 public String toString() 87 { 88 return toString; 89 } 90 91 private String buildToString() 92 { 93 StringBuffer buffer = new StringBuffer ("JBoss Portal "); 94 buffer.append(getMajor()).append('.'); 95 buffer.append(getMinor()).append('.'); 96 buffer.append(getPatch()).append('-'); 97 buffer.append(getIntermediateMajor()); 98 if (getIntermediateMinor() >= 1) 99 { 100 buffer.append(getIntermediateMinor()); 101 } 102 return buffer.toString(); 103 } 104 105 108 public static class IntermediateMajor implements Comparable 109 { 110 111 public static final IntermediateMajor DR = new IntermediateMajor("DR", "Developer release"); 112 public static final IntermediateMajor ALPHA = new IntermediateMajor("ALPHA", "Alpha"); 113 public static final IntermediateMajor BETA = new IntermediateMajor("BETA", "Beta"); 114 public static final IntermediateMajor RC = new IntermediateMajor("RC", "Release candidate"); 115 public static final IntermediateMajor FINAL = new IntermediateMajor("FINAL", "Final"); 116 public static final IntermediateMajor SP = new IntermediateMajor("SP", "Service pack"); 117 118 private static int nextOrdinal = 0; 119 120 private final int ordinal; 121 122 private final String name; 123 124 private final String description; 125 126 private IntermediateMajor(String name, String description) 127 { 128 this.ordinal = nextOrdinal++; 129 this.name = name; 130 this.description = description; 131 } 132 133 public String getName() 134 { 135 return name; 136 } 137 138 public String getDescription() 139 { 140 return description; 141 } 142 143 public int compareTo(Object o) 144 { 145 return ordinal - ((IntermediateMajor)o).ordinal; 146 } 147 148 public String toString() 149 { 150 return name; 151 } 152 } 153 } 154 | Popular Tags |