Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*-
   * See the file LICENSE for redistribution information.
   *
   * Copyright (c) 2002, 2013 Oracle and/or its affiliates.  All rights reserved.
   *
   */
  
  package com.sleepycat.je;
  
Berkeley DB Java Edition version information. Versions consist of major, minor and patch numbers.

There is one JEVersion object per running JVM and it may be accessed using the static field JEVersion.CURRENT_VERSION.

 
 public class JEVersion implements Comparable<JEVersion> {

    
Release version.
 
     public static final JEVersion CURRENT_VERSION =
         new JEVersion(5, 0, 73, null);
 
     private final int majorNum;
     private final int minorNum;
     private final int patchNum;
     private final String name;
 
     private JEVersion(int majorNumint minorNumint patchNumString name) {
         this. = majorNum;
         this. = minorNum;
         this. = patchNum;
         this. = name;
     }
 
     public JEVersion(String version) {
         StringTokenizer st = new StringTokenizer(version".");
 
          = Integer.parseInt(st.nextToken());
          = Integer.parseInt(st.nextToken());
          = Integer.parseInt(st.nextToken());
         if (st.hasMoreTokens()) {
              = st.nextToken();
         } else {
              = null;
         }
     }
 
     @Override
     public String toString() {
         return getVersionString();
     }

    
Major number of the release version.

Returns:
The major number of the release version.
 
     public int getMajor() {
         return ;
     }

    
Minor number of the release version.

Returns:
The minor number of the release version.
 
     public int getMinor() {
         return ;
     }

    
Patch number of the release version.

Returns:
The patch number of the release version.
 
     public int getPatch() {
         return ;
     }

    
The numeric version string, without the patch tag.

Returns:
The release version
 
     public String getNumericVersionString() {
         StringBuilder version = new StringBuilder();
         version.append().append(".");
         version.append().append(".");
         version.append();
         return version.toString();
     }

    
Release version, suitable for display.

Returns:
The release version, suitable for display.
    public String getVersionString() {
        StringBuilder version = new StringBuilder();
        version.append().append(".");
        version.append().append(".");
        version.append();
        if ( != null) {
            version.append(".");
            version.append();
        }
        return version.toString();
    }
    /*
     * Return -1 if the current version is earlier than the comparedVersion.
     * Return 0 if the current version is the same as the comparedVersion.
     * Return 1 if the current version is later than the comparedVersion.
     */
    public int compareTo(JEVersion comparedVersion) {
        int result = 0;
        if ( == comparedVersion.getMajor()) {
            if ( == comparedVersion.getMinor()) {
                if ( > comparedVersion.getPatch()) {
                    result = 1;
                } else if ( < comparedVersion.getPatch()) {
                    result = -1;
                }
            } else if ( > comparedVersion.getMinor()) {
                result = 1;
            } else {
                result = -1;
            }
        } else if ( > comparedVersion.getMajor()) {
            result = 1;
        } else {
            result = -1;
        }
        return result;
    }
    /*
     * If its type is JEVersion, and the version numbers are the same,
     * then we consider these two versions equal.
     */
    @Override
    public boolean equals(Object o) {
        return (o instanceof JEVersion) && (compareTo((JEVersiono) == 0);
    }
    /* Produce a unique hash code for JEVersion. */
    @Override
    public int hashCode() {
        return  * 1000 * 1000 +  * 1000 + ;
    }
New to GrepCode? Check out our FAQ X