org.zkoss.util
Class Utils

java.lang.Object
  extended by org.zkoss.util.Utils

public class Utils
extends java.lang.Object

Generic utilities.

Since:
3.0.0
Author:
tomyeh

Constructor Summary
Utils()
           
 
Method Summary
static int compareVersion(int[] v1, int[] v2)
          Compares two version.
static int getSubversion(java.lang.String version, int portion)
          Returns a portion of the specified version in an integer, or 0 if no such portion exists.
static int[] parseVersion(java.lang.String version)
          Parses the specified version into an array of integer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

getSubversion

public static final int getSubversion(java.lang.String version,
                                      int portion)
Returns a portion of the specified version in an integer, or 0 if no such portion exists.

For example, getSubversion(0) returns the so-called major version (2 in "2.4.0"), and getSubversion(1) returns the so-called minor version (4 in "2.4.0").

Note: alpha is consider as -500, beta -300, and rc -100. Moreover, beta3 is -497 (= -500 + 3) and rc5 -95 (-100 + 5)

Parameters:
version - the version. The version is assumed to a series of integer separated by a non-alphanumeric separator.
portion - which portion of the version; starting from 0. If you want to retrieve the major version, specify 0.
Since:
3.0.0

parseVersion

public static final int[] parseVersion(java.lang.String version)
Parses the specified version into an array of integer. For example, parseVersion("3.5.2") will return [3, 5, 2].

Since:
3.5.2

compareVersion

public static final int compareVersion(int[] v1,
                                       int[] v2)
Compares two version.

Returns:
0 if equals, 1 if the first one is larger, -1 if smaller.
Since:
3.5.2


Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo