/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008 Sun Microsystems, Inc.
* Portions copyright 2013 ForgeRock AS.
*/
/**
* Represents a particular version of OpenDJ useful for making comparisons
* between versions.
*/
{
private final int major;
private final int minor;
private final int point;
private final long rev;
/**
* Returns the build version as specified by the dynamic constants.
*
* @return The build version as specified by the dynamic constants.
*/
{
return BINARY_VERSION;
}
/**
*
* @throws InitializationException
* If an error occurred while reading or parsing the version.
*/
{
try
{
if (s != null)
{
return valueOf(s);
}
else
{
}
}
catch (IOException e)
{
}
catch (final IllegalArgumentException e)
{
}
finally
{
{
try
{
}
catch (final Exception e)
{
// Ignore.
}
}
}
}
/**
* Checks if the binary version is the same than the instance version.
*
* @throws InitializationException
* Sends an exception if the version mismatch.
*/
{
{
.instanceVersion().toString()));
}
}
/**
* Parses the string argument as a build version. The string must be of the
* form:
*
* <pre>
* major.minor.point.rev
* </pre>
*
* @param s
* The string to be parsed as a build version.
* @return The parsed build version.
* @throws IllegalArgumentException
* If the string does not contain a parsable build version.
*/
throws IllegalArgumentException
{
{
throw new IllegalArgumentException("Invalid version string " + s);
}
}
/**
* Creates a new build version using the provided version information.
*
* @param major
* Major release version number.
* @param minor
* Minor release version number.
* @param point
* Point release version number.
* @param rev
* VCS revision number.
*/
final long rev)
{
}
/**
* {@inheritDoc}
*/
{
{
{
{
{
return 0;
}
{
return -1;
}
}
{
return -1;
}
}
{
return -1;
}
}
{
return -1;
}
return 1;
}
/**
* {@inheritDoc}
*/
{
if (this == obj)
{
return true;
}
else if (obj instanceof BuildVersion)
{
}
else
{
return false;
}
}
/**
* Returns the major release version number.
*
* @return The major release version number.
*/
public int getMajorVersion()
{
return major;
}
/**
* Returns the minor release version number.
*
* @return The minor release version number.
*/
public int getMinorVersion()
{
return minor;
}
/**
* Returns the point release version number.
*
* @return The point release version number.
*/
public int getPointVersion()
{
return point;
}
/**
* Returns the VCS revision number.
*
* @return The VCS revision number.
*/
public long getRevisionNumber()
{
return rev;
}
/**
* {@inheritDoc}
*/
public int hashCode()
{
(int) (rev & 0xFFFFL) });
}
/**
* {@inheritDoc}
*/
{
}
}