1 /* 2 Copyright (C) 2000 - 2007 Grid Systems, S.A. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License, version 2, as 6 published by the Free Software Foundation. 7 8 This program is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License 14 along with this program; if not, write to the Free Software 15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 */ 17 18 package com.gridsystems.innergrid.kernel.services; 19 20 /** 21 * Bean containing plug-in version data. 22 * Version information is important because it is used to resolve the dependencies 23 * between different plug-ins. 24 * 25 * @author Rodrigo Ruiz 26 * @version 1.0 27 */ 28 public class VersionInfo implements Cloneable { 29 /** The major version number. */ 30 private int major; 31 32 /** The minor version number. */ 33 private int minor; 34 35 /** The release version number. */ 36 private int release; 37 38 /** The build number. */ 39 private int build; 40 41 /** The project code name. */ 42 private String codeName; 43 44 /** 45 * Default empty constructor. 46 */ 47 public VersionInfo() { } 48 49 /** 50 * Gets the build number. 51 * This number will usually be a date formatted as YYYYMMDD. 52 * 53 * @return the build number. 54 */ 55 public int getBuild() { 56 return build; 57 } 58 59 /** 60 * Gets the code name given to this version of the plug-in. 61 * 62 * @return the code name given to this version of the plug-in. 63 */ 64 public String getCodeName() { 65 return codeName; 66 } 67 68 /** 69 * Gets the major version number. 70 * 71 * @return the plug-in major version. 72 */ 73 public int getMajor() { 74 return major; 75 } 76 77 /** 78 * Gets the minor version number. 79 * 80 * @return The plug-in minor version. 81 */ 82 public int getMinor() { 83 return minor; 84 } 85 86 /** 87 * Gets the release number. 88 * 89 * @return The plug-in release number. 90 */ 91 public int getRelease() { 92 return release; 93 } 94 95 /** 96 * Sets the build number (for internal use only). 97 * 98 * @param build the build number 99 */ 100 public void setBuild(int build) { 101 this.build = build; 102 } 103 104 /** 105 * Sets the product code name (for internal use only). 106 * 107 * @param codeName the product code name 108 */ 109 public void setCodeName(String codeName) { 110 this.codeName = codeName; 111 } 112 113 /** 114 * Sets the major version number (for internal use only). 115 * 116 * @param major the major version number 117 */ 118 public void setMajor(int major) { 119 this.major = major; 120 } 121 122 /** 123 * Sets the minor version number (for internal use only). 124 * 125 * @param minor the minor version number 126 */ 127 public void setMinor(int minor) { 128 this.minor = minor; 129 } 130 131 /** 132 * Sets the release number (for internal use only). 133 * 134 * @param release the release value 135 */ 136 public void setRelease(int release) { 137 this.release = release; 138 } 139 140 /** 141 * {@inheritDoc} 142 */ 143 //@Override 144 public Object clone() throws CloneNotSupportedException { 145 VersionInfo clone = (VersionInfo) super.clone(); 146 return clone; 147 } 148 149 /** 150 * Converts an object into a collection of characters, returning its name and 151 * essential information. 152 * 153 * @return a <code>String</code> representation of object passed along with the method 154 * @see java.lang.Object#toString() 155 */ 156 //@Override 157 public String toString() { 158 StringBuffer sb = new StringBuffer(); 159 sb.append(major).append('.').append(minor).append('.').append(release); 160 161 if (build != 0) { 162 sb.append(" Build ").append(build); 163 } 164 165 if (codeName != null) { 166 sb.append(" (").append(codeName).append(')'); 167 } 168 169 return sb.toString(); 170 } 171 }