com.faunos.util
Class Version

java.lang.Object
  extended by com.faunos.util.Version
All Implemented Interfaces:
Comparable<Version>

public class Version
extends Object
implements Comparable<Version>

Represents a [software release] version of the form xx.xx.xx where xx is a decimal number in the range [0, 99]. Provides two mutually compatible serialization mechanisms:

  1. As a long: Version(long), toLong()
  2. As a String: Version(String), toCharSequence()
Both representations are mutually compatible because they are both exactly 8 bytes wide. The default behavior ignores the separator character (default is '.'), so there is a many-to-one mapping of serial representations to logically equal Version instances.


Field Summary
static char DEFAULT_SEPARATOR
          The default separator ('.').
 
Constructor Summary
Version(int major, int minor, int sub)
           
Version(int major, int minor, int sub, char separator)
           
Version(long encoded)
           
Version(long encoded, char separator)
           
Version(long encoded, char separator, boolean checkSep)
           
Version(String versionString)
           
 
Method Summary
 int compareTo(Version other)
           
 boolean equals(Object other)
           
 int getMajor()
           
 int getMinor()
           
 char getSeparator()
          Returns the separator character in the string representation of this instance.
 int getSub()
           
 CharSequence toCharSequence()
          Returns a string representation of this instance.
 long toLong()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_SEPARATOR

public static final char DEFAULT_SEPARATOR
The default separator ('.').

See Also:
Constant Field Values
Constructor Detail

Version

public Version(int major,
               int minor,
               int sub)

Version

public Version(int major,
               int minor,
               int sub,
               char separator)

Version

public Version(String versionString)

Version

public Version(long encoded)

Version

public Version(long encoded,
               char separator)

Version

public Version(long encoded,
               char separator,
               boolean checkSep)
Method Detail

getMajor

public final int getMajor()

getMinor

public final int getMinor()

getSub

public final int getSub()

equals

public final boolean equals(Object other)
Overrides:
equals in class Object

compareTo

public final int compareTo(Version other)
Specified by:
compareTo in interface Comparable<Version>

getSeparator

public char getSeparator()
Returns the separator character in the string representation of this instance. The default behavior returns '.'.

See Also:
DEFAULT_SEPARATOR

toString

public String toString()
Overrides:
toString in class Object

toCharSequence

public final CharSequence toCharSequence()
Returns a string representation of this instance.

See Also:
Version(String)

toLong

public final long toLong()


SourceForge.net Logo