public class

Version

extends Object
implements Comparable<T>
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.Version

Class Overview

Version number object. The syntax is as follows: major.minor.buildid.timestamp.channel or major.minor-channelString.buildid.timestamp.

Details:
- A valid version string must contain the fields major, minor and buildid
- Timestamp format: YYYYMMDDhhmm
- Allowed channels: RELEASE(0,""), BETA(1,"beta"), ALPHA(2,"alpha")

Examples of valid version strings:

 1.0.0
 1.0.2.201801021400
 1.0.2.201801021400.0
 1.0.2.201801021400.1
 1.0.2.201801021400.2
 1.2.123
 1.2-beta.123
 1.2-alpha.123
 1.2-beta.123.201807140000
 
Version objects can be persisted.

Summary

Constants
int ALPHA
int BETA
int CHANNEL_MOST_UNSTABLE
int CHANNEL_STABLE
int RELEASE
Public Constructors
Version(Version v)
Copy constructor.
Version(int major, int minor)
Create a new version object "major.minor.0.0".
Version(int major, int minor, int buildid)
Create a new version object "major.minor.buildid.0".
Version(int major, int minor, int buildid, long timestamp)
Create a new version object "major.minor.buildid.timestamp".
Version(int major, int minor, int buildid, long timestamp, int channel)
Create a new version object "major.minor.buildid.timestamp".
Public Methods
int compareTo(Version o)
int compareToIgnoreChannel(Version o)
int compareToIgnoreTimestamp(Version o)
int compareToIgnoreTimestampAndChannel(Version o)
static Version create(int major, int minor, int buildid, long timestamp)
Static builder, equivalent of Version(int, int, int, long).
static Version create(int major, int minor, int buildid, long timestamp, int channel)
Static builder, equivalent of Version(int, int, int, long, int).
static Version create(int major, int minor, int buildid)
Static builder, equivalent of Version(int, int, int).
static Version create(int major, int minor)
Static builder, equivalent of Version(int, int).
boolean equals(Object obj)
String format(boolean useChannelString)
String formatCompact()
static Version fromInt(int val)
Create a version object from an integer generated by toInt().
int getBuildid()
Get the build id number.
int getChannel()
Get the channel.
static String getChannelInfo(int channel)
static String getChannelName(int channel)
static String[] getChannelNames()
String getChannelString()
int getMajor()
Get the major number.
int getMinor()
Get the minor number.
long getTimestamp()
Get the timestamp.
int hashCode()
boolean like(int major, int minor, int buildid)
Determine if the version is like "major.minor.buildid.?"
boolean like(int major, int minor)
Determine if the version is like "major.minor.?.?"
boolean like(int major)
Determine if the version is like "major.?.?.?"
static Version parseFromFile(File f)
Read a file which should contain a single string containing a version number.
static Version parseFromString(String s)
Parse a version string into a Version object.
void setBuildid(int buildid)
void setChannel(int channel)
void setMajor(int major)
void setMinor(int minor)
void setTimestamp(long timestamp)
int toInt()
Generate a 4-byte integer representing the three most relevant components of this version object.
String toString()
Same as format(true).
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.Comparable

Constants

public static final int ALPHA

Constant Value: 2 (0x00000002)

public static final int BETA

Constant Value: 1 (0x00000001)

public static final int CHANNEL_MOST_UNSTABLE

Constant Value: 2 (0x00000002)

public static final int CHANNEL_STABLE

Constant Value: 0 (0x00000000)

public static final int RELEASE

Constant Value: 0 (0x00000000)

Public Constructors

public Version (Version v)

Copy constructor.

Parameters
v a version object

public Version (int major, int minor)

Create a new version object "major.minor.0.0".

Parameters
major zero or positive number
minor zero or positive number

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

Create a new version object "major.minor.buildid.0".

Parameters
major zero or positive number
minor zero or positive number
buildid zero or positive number

public Version (int major, int minor, int buildid, long timestamp)

Create a new version object "major.minor.buildid.timestamp".

Parameters
major zero or positive number
minor zero or positive number
buildid zero or positive number
timestamp zero or positive number

public Version (int major, int minor, int buildid, long timestamp, int channel)

Create a new version object "major.minor.buildid.timestamp".

Parameters
major zero or positive number
minor zero or positive number
buildid zero or positive number
timestamp zero or positive number
channel optional; 0=release, 1=beta, 2=alpha

Public Methods

public int compareTo (Version o)

public int compareToIgnoreChannel (Version o)

public int compareToIgnoreTimestamp (Version o)

public int compareToIgnoreTimestampAndChannel (Version o)

public static Version create (int major, int minor, int buildid, long timestamp)

Static builder, equivalent of Version(int, int, int, long).

public static Version create (int major, int minor, int buildid, long timestamp, int channel)

Static builder, equivalent of Version(int, int, int, long, int).

public static Version create (int major, int minor, int buildid)

Static builder, equivalent of Version(int, int, int).

public static Version create (int major, int minor)

Static builder, equivalent of Version(int, int).

public boolean equals (Object obj)

public String format (boolean useChannelString)

Parameters
useChannelString true to format the channel (if present) as a string appended to the Minor version number; else, the channel value, if non 0, will be appended to the version Timestamp

public String formatCompact ()

public static Version fromInt (int val)

Create a version object from an integer generated by toInt().

Parameters
val a version-int, as generated by toInt()
Returns
  • a version Object

public int getBuildid ()

Get the build id number.

public int getChannel ()

Get the channel.

public static String getChannelInfo (int channel)

public static String getChannelName (int channel)

public static String[] getChannelNames ()

public String getChannelString ()

public int getMajor ()

Get the major number.

public int getMinor ()

Get the minor number.

public long getTimestamp ()

Get the timestamp.

public int hashCode ()

public boolean like (int major, int minor, int buildid)

Determine if the version is like "major.minor.buildid.?"

public boolean like (int major, int minor)

Determine if the version is like "major.minor.?.?"

public boolean like (int major)

Determine if the version is like "major.?.?.?"

public static Version parseFromFile (File f)

Read a file which should contain a single string containing a version number.

Parameters
f a file
Returns
  • the version object, null on error

public static Version parseFromString (String s)

Parse a version string into a Version object.

Parameters
s a string
Returns
  • a version object, null on error

public void setBuildid (int buildid)

public void setChannel (int channel)

public void setMajor (int major)

public void setMinor (int minor)

public void setTimestamp (long timestamp)

public int toInt ()

Generate a 4-byte integer representing the three most relevant components of this version object. The resulting int is as such: {00AABBCC} where AA=getMajor(), BB=getMinor(), CC=getBuildid(). If any of AA, BB, CC exceeds 255, it is truncated to 255.

Returns
  • a version-int

public String toString ()

Same as format(true).