org.openmdx.kernel.environment.cci
Class VersionNumber

java.lang.Object
  extended by org.openmdx.kernel.environment.cci.VersionNumber
All Implemented Interfaces:
Serializable, Cloneable, Comparable

public final class VersionNumber
extends Object
implements Cloneable, Serializable, Comparable

openMDX Version Number Class

See Also:
Serialized Form

Field Summary
protected  String external
           
protected  int[] internal
           
 
Constructor Summary
VersionNumber(int[] components)
          Create the version number represented by the components
VersionNumber(String version)
          Creates a version based on its string representation.
 
Method Summary
 Object clone()
           
 int compareTo(Object object)
           
 boolean equals(Object that)
           
 int get(int index)
          Retrieves a component of this verison number.
 VersionNumber getPrefix(int position)
          Get a version number's prefix
 int hashCode()
           
 boolean isCompliantWith(VersionNumber that)
          Compliance test: The first components must be equal and the second component of this version number must be greater or equal than the second component of the other object.
 int size()
          Get the number of components
protected static String toExternal(int[] internal)
          Get the external representation of the internal format.
protected static int[] toInternal(String external, boolean strict)
          Parses the external format
 String toString()
           
static VersionNumber toVersionNumber(int[] components)
          Create the version number represented by the components
static VersionNumber toVersionNumber(String source)
          Create a version number if the string represents one.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

internal

protected final int[] internal

external

protected final String external
Constructor Detail

VersionNumber

public VersionNumber(String version)
Creates a version based on its string representation.

Parameters:
version -
Throws:
IllegalArgumentException - if the version string can't be parsed.

VersionNumber

public VersionNumber(int[] components)
Create the version number represented by the components

Parameters:
components - an array of version number components, starting with the most significant one
Throws:
NullPointerException - if components is null
Method Detail

isCompliantWith

public boolean isCompliantWith(VersionNumber that)
Compliance test: The first components must be equal and the second component of this version number must be greater or equal than the second component of the other object.

Positive examples:

Negative examples:

Parameters:
that -

size

public int size()
Get the number of components

Returns:
the number of components

get

public int get(int index)
Retrieves a component of this verison number.

Parameters:
index - the 0-based index of the component to retrieve. Must be in the range [0,size()).
Returns:
the component at the given position
Throws:
ArrayIndexOutOfBoundsException - if index is outside the specified range

getPrefix

public VersionNumber getPrefix(int position)
Get a version number's prefix

Returns:
a version number's prefix
Throws:
IndexOutOfBoundsException - if position is greater than size

toExternal

protected static String toExternal(int[] internal)
Get the external representation of the internal format.

Parameters:
internal - the version number's internal representatiom
Returns:
the version number's external representation
Throws:
NullPointerException - if internal is null.

toInternal

protected static int[] toInternal(String external,
                                  boolean strict)
Parses the external format

Parameters:
external - the version number's external representation
strict - tells whether a parsing failure is signalled by a BadParameterException or a null return value
Returns:
the version number's internal representatiom
Throws:
IllegalArgumentException - in case of parsing failure if strict is true

toVersionNumber

public static VersionNumber toVersionNumber(String source)
Create a version number if the string represents one.

As opposed to VersionNumber(String) this method does not throw an exception in case of parse failure but returns null.

Parameters:
source -
Returns:
Return the corresponding version number or null if if the string does not represent a version number

toVersionNumber

public static VersionNumber toVersionNumber(int[] components)
Create the version number represented by the components

Parameters:
components - an array of version number components, starting with the most significant one
Returns:
the version number represented by components; or null if components is null

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

compareTo

public int compareTo(Object object)
Specified by:
compareTo in interface Comparable

equals

public boolean equals(Object that)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


This software is published under the BSD license. Copyright © 2003-2007, OMEX AG, Switzerland, All rights reserved. Use is subject to license terms.