Index: lutinutil/src/java/org/codelutin/util/VersionNumber.java diff -u /dev/null lutinutil/src/java/org/codelutin/util/VersionNumber.java:1.1 --- /dev/null Thu Jan 3 05:55:36 2008 +++ lutinutil/src/java/org/codelutin/util/VersionNumber.java Thu Jan 3 05:55:29 2008 @@ -0,0 +1,62 @@ +/* +* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* Tony Chemit +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package org.codelutin.util; + +/** + * A class to represent an application version + * + * @author chemit + */ +public class VersionNumber implements Comparable { + protected int[] numbers; + + public VersionNumber() { + this.numbers = new int[]{0}; + } + + public VersionNumber(int[] numbers) { + this.numbers = numbers; + } + + public int[] getNumbers() { + return numbers; + } + + public int getNbComponents() { + return numbers.length; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + for (int number : numbers) { + sb.append('.').append(number); + } + return sb.toString().substring(1); + } + + public int compareTo(VersionNumber o) { + String str = toString(); + String ostr = o.toString(); + if (str.equals(ostr)) { + return 0; + } + return VersionNumberUtil.greaterThan(str, ostr) ? 1 : -1; + } +}