under construction under construction
Under construction


CVersion is a utility class for comparing version information as used in software library files.


There is a factory method for creating a CVersion instance. It creates a version object from a string. If you use a filename, please use it without extension.

public static CVersion fromFilename(@NotNull final String aFilename);

// usage:
final CVersion v = CVersion.fromFilename("mylib-1.2.3-SNAPSHOT");

Another static method creates the version object from a file object. Here the extension of the file name is removed. The file object is saved as a user object in the version object and can be retrieved later (see below).

public static CVersion fromFile(@NotNull final java.io.File aFile);

// usage:
final File file = ...
final CVersion v = CVersion.fromFile(file);

// retrieve the file object later:
final File file1 = (File) v.getData();

There is also a public constructor. It takes over the version components. The suffix is not analyzed in this case. It is treated like a string during comparison, even if it contains extended information like -rc1 or similar.

public CVersion(final int aMajorVersion,
                final int aMinorVersion,
                final int aPatchVersion,
                @NotNull final String aSuffix);


The individual components of the version can be fetched via getter methods.

public int getMajorVersion();
public int getMinorVersion();
public int getPatchVersion();
public String getSuffix();

User objects

Objects belonging to the version can be stored in the version object. This often facilitates the assignment of a version to an object of source.

public void setData(@Nullable final Object aData);
public Object getData();


The class supports the equals and hashCode methods as well as the Comparable interface.

Homepage of nyssr.net and RemoteSkin