public class

Version

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

Class Overview

Version number object, in the form of: 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 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)
int getBuildid()
Get the build id number.
int getChannel()
Get the channel.
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)
Determine if the version is like "major.?.?.?"
boolean like(int major, int minor)
Determine if the version is like "major.minor.?.?"
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.
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 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 int getBuildid ()

Get the build id number.

public int getChannel ()

Get the channel.

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)

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

public boolean like (int major, int minor)

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

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 String toString ()

Same as format(true).