edu.mit.jwi.item
Class Version

java.lang.Object
  extended by edu.mit.jwi.item.Version
All Implemented Interfaces:
IVersion, java.io.Serializable

public class Version
extends java.lang.Object
implements IVersion

Default, concrete implementation of the IVersion interface. This class, much like the Integer class, caches instances, which should be created via the createVersion methods.

This version object takes an optional bugfix version number and string qualifier. The qualifier may only contain characters are that are valid Java

Since:
JWI 2.1.0
Version:
2.4.0
Author:
Mark A. Finlayson
See Also:
Serialized Form

Field Summary
static Version ver16
           
static Version ver17
           
static Version ver171
           
static Version ver20
           
static Version ver21
           
static Version ver21swn_10k
           
static Version ver21swn_20k
           
static Version ver21swn_30k
           
static Version ver21swn_400k_cropped
           
static Version ver21swn_400k_full
           
static Version ver21swn_40k
           
static Version ver30
           
static Version ver31
           
static int versionOffset
          The byte offset of the version indicator in the standard Wordnet file headers.
 
Fields inherited from interface edu.mit.jwi.item.IVersion
NO_VERSION
 
Constructor Summary
Version(int major, int minor, int bugfix)
          Creates a new version object with the specified version numbers.
Version(int major, int minor, int bugfix, java.lang.String qualifier)
          Creates a new version object with the specified version numbers.
 
Method Summary
static java.lang.String checkQualifier(java.lang.String qualifier)
          Checks the specified qualifier for legality.
static java.lang.String checkVersion(int major, int minor, int bugfix, java.lang.String qualifier)
          Checks the supplied version numbers.
static void checkVersionNumber(int major, int minor, int bugfix)
          Checks the supplied version numbers.
 boolean equals(java.lang.Object obj)
           
static Version extractVersion(IContentType<?> type, java.nio.ByteBuffer buffer)
          Extracts a version object from a byte buffer that contains data with the specified content type.
 int getBugfixVersion()
          Returns the bugfix version number, i.e., the '2' in '1.7.2'.
 int getMajorVersion()
          Returns the major version number, i.e., the '1' in '1.7.2'.
 int getMinorVersion()
          Returns the minor version number, i.e., the '7' in '1.7.2'.
 java.lang.String getQualifier()
          Returns the version qualifier, i.e., the 'abc' in '1.7.2.abc'.
static Version getVersion(int major, int minor, int bugfix)
          Creates and caches, or retrieves from the cache, a version object corresponding to the specified numbers.
static Version getVersion(int major, int minor, int bugfix, java.lang.String qualifier)
          Creates and caches, or retrieves from the cache, a version object corresponding to the specified numbers.
 int hashCode()
           
static int hashCode(int major, int minor, int bugfix, java.lang.String qualifier)
          Calculates the hash code for a version object with the specified version numbers.
static boolean isIllegalQualifier(java.lang.String qualifier)
          Returns falseif the specified qualifier is legal, namely, if the string is either the empty string, or contains only characters that are found in valid java identifiers.
static boolean isIllegalVersion(int major, int minor, int bugfix, java.lang.String qualifier)
          Returns true if the arguments identify a legal version; false otherwise.
static boolean isIllegalVersionNumber(int major, int minor, int bugfix)
          Returns true if any of three numbers are negative
static java.lang.String makeVersionString(int major, int minor, int bugfix, java.lang.String qualifier)
          Creates a version string for the specified version numbers.
static Version parseVersion(java.lang.CharSequence verStr)
          Tries to transform the specified character sequence into a version object.
static Version parseVersionProtected(java.lang.CharSequence verStr)
          Tries to transform the specified character sequence into a version object.
protected  java.lang.Object readResolve()
          This utility method implements the appropriate deserialization for this object.
 java.lang.String toString()
           
static java.util.List<Version> values()
          Emulates the Enum.values() function.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ver16

public static final Version ver16

ver17

public static final Version ver17

ver171

public static final Version ver171

ver20

public static final Version ver20

ver21

public static final Version ver21

ver30

public static final Version ver30

ver31

public static final Version ver31

ver21swn_10k

public static final Version ver21swn_10k

ver21swn_20k

public static final Version ver21swn_20k

ver21swn_30k

public static final Version ver21swn_30k

ver21swn_40k

public static final Version ver21swn_40k

ver21swn_400k_cropped

public static final Version ver21swn_400k_cropped

ver21swn_400k_full

public static final Version ver21swn_400k_full

versionOffset

public static final int versionOffset
The byte offset of the version indicator in the standard Wordnet file headers.

Since:
JWI 2.1.0
See Also:
Constant Field Values
Constructor Detail

Version

public Version(int major,
               int minor,
               int bugfix)
Creates a new version object with the specified version numbers.

Clients should normally obtain instances of this class via the static getVersion methods.

Parameters:
major - the major version number, i.e., the '1' in 1.2.3
minor - the minor version number, i.e., the '2' in 1.2.3
bugfix - the bugfix version number, i.e., the '3' in 1.2.3
Throws:
java.lang.IllegalArgumentException - if any of the version numbers are negative
Since:
JWI 2.1.0

Version

public Version(int major,
               int minor,
               int bugfix,
               java.lang.String qualifier)
Creates a new version object with the specified version numbers.

Clients should normally obtain instances of this class via the static getVersion methods.

Parameters:
major - the major version number, i.e., the '1' in 1.2.3.q
minor - the minor version number, i.e., the '2' in 1.2.3.q
bugfix - the bugfix version number, i.e., the '3' in 1.2.3.q
qualifier - the version qualifier, i.e., the 'q' in 1.2.3.q
Throws:
java.lang.IllegalArgumentException - if any of the version numbers are negative, or the qualifier is not a legal qualifier
Since:
JWI 2.2.0
Method Detail

getMajorVersion

public int getMajorVersion()
Description copied from interface: IVersion
Returns the major version number, i.e., the '1' in '1.7.2'.

Specified by:
getMajorVersion in interface IVersion
Returns:
the major version number, never negative

getMinorVersion

public int getMinorVersion()
Description copied from interface: IVersion
Returns the minor version number, i.e., the '7' in '1.7.2'.

Specified by:
getMinorVersion in interface IVersion
Returns:
the minor version number, never negative

getBugfixVersion

public int getBugfixVersion()
Description copied from interface: IVersion
Returns the bugfix version number, i.e., the '2' in '1.7.2'.

Specified by:
getBugfixVersion in interface IVersion
Returns:
the bugfix version number, never negative

getQualifier

public java.lang.String getQualifier()
Description copied from interface: IVersion
Returns the version qualifier, i.e., the 'abc' in '1.7.2.abc'. The qualifer is never null, but may be empty.

Specified by:
getQualifier in interface IVersion
Returns:
the version qualifier, non-null, potentially empty

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

readResolve

protected java.lang.Object readResolve()
This utility method implements the appropriate deserialization for this object.

Returns:
the appropriate deserialized object.
Since:
JWI 2.4.0

checkVersion

public static java.lang.String checkVersion(int major,
                                            int minor,
                                            int bugfix,
                                            java.lang.String qualifier)
Checks the supplied version numbers. Throws an IllegalArgumentException if they do not define a legal version.,

Parameters:
major - the major version number
minor - the minor version number
bugfix - the bugfix version number
qualifier - the qualifier to check
Returns:
the null-masked qualifier
Throws:
java.lang.IllegalArgumentException - if the supplied arguments do not identify a legal version
Since:
JWI 2.2.0

checkVersionNumber

public static void checkVersionNumber(int major,
                                      int minor,
                                      int bugfix)
Checks the supplied version numbers. Throws an IllegalArgumentException if the version numbers are not valid (that is, any are below zero).

Parameters:
major - the major version number
minor - the minor version number
bugfix - the bugfix version number
Throws:
java.lang.IllegalArgumentException - if any of the supplied numbers are negative
Since:
JWI 2.1.0

checkQualifier

public static java.lang.String checkQualifier(java.lang.String qualifier)
Checks the specified qualifier for legality. Throws an IllegalArgumentException if it is not a legal qualifier.

Parameters:
qualifier - the qualifier to check
Returns:
the null-masked qualifier
Since:
JWI 2.1.0
See Also:
isIllegalQualifier(String)

isIllegalVersion

public static boolean isIllegalVersion(int major,
                                       int minor,
                                       int bugfix,
                                       java.lang.String qualifier)
Returns true if the arguments identify a legal version; false otherwise.

Parameters:
major - the major version number
minor - the minor version number
bugfix - the bugfix version number
qualifier - the version qualifier
Returns:
true if the arguments identify a legal version; false otherwise.
Since:
JWI 2.1.0

isIllegalVersionNumber

public static boolean isIllegalVersionNumber(int major,
                                             int minor,
                                             int bugfix)
Returns true if any of three numbers are negative

Parameters:
major - the major version number
minor - the minor version number
bugfix - the bugfix version number
Returns:
true if all the numbers are non-negative; false otherwise
Since:
JWI 2.1.0

isIllegalQualifier

public static boolean isIllegalQualifier(java.lang.String qualifier)
Returns falseif the specified qualifier is legal, namely, if the string is either the empty string, or contains only characters that are found in valid java identifiers.

Parameters:
qualifier - the qualifier to check
Returns:
true if not a legal qualifier; false otherwise
Throws:
java.lang.NullPointerException - if the specified string is null
Since:
JWI 2.2.0
See Also:
Character.isJavaIdentifierPart(char)

getVersion

public static Version getVersion(int major,
                                 int minor,
                                 int bugfix)
Creates and caches, or retrieves from the cache, a version object corresponding to the specified numbers.

Parameters:
major - the major version number
minor - the minor version number
bugfix - the bugfix version number
Returns:
the cached version object corresponding to these numbers
Since:
JWI 2.1.0

getVersion

public static Version getVersion(int major,
                                 int minor,
                                 int bugfix,
                                 java.lang.String qualifier)
Creates and caches, or retrieves from the cache, a version object corresponding to the specified numbers.

Parameters:
major - the major version number
minor - the minor version number
bugfix - the bugfix version number
qualifier - the version qualifier
Returns:
the cached version object corresponding to these numbers
Throws:
java.lang.IllegalArgumentException - if the version numbers and qualifier are not legal
Since:
JWI 2.2.0

makeVersionString

public static java.lang.String makeVersionString(int major,
                                                 int minor,
                                                 int bugfix,
                                                 java.lang.String qualifier)
Creates a version string for the specified version numbers. If a version's bugfix number is 0, and if the qualifier is null or empty, the string produced is of the form "x.y". I

Parameters:
major - the major version number, i.e., the '1' in 1.2.3.q
minor - the minor version number, i.e., the '2' in 1.2.3.q
bugfix - the bugfix version number, i.e., the '3' in 1.2.3.q
qualifier - the version qualifier, i.e., the 'q' in 1.2.3.q
Returns:
a string representing the specified version
Throws:
java.lang.IllegalArgumentException
Since:
JWI 2.2.0

hashCode

public static int hashCode(int major,
                           int minor,
                           int bugfix,
                           java.lang.String qualifier)
Calculates the hash code for a version object with the specified version numbers.

Parameters:
major - the major version number, i.e., the '1' in 1.2.3.q
minor - the minor version number, i.e., the '2' in 1.2.3.q
bugfix - the bugfix version number, i.e., the '3' in 1.2.3.q
qualifier - the version qualifier, i.e., the 'q' in 1.2.3.q
Returns:
the hash code for the specified version
Throws:
java.lang.IllegalArgumentException - if the specified parameters do not identify a legal version

extractVersion

public static Version extractVersion(IContentType<?> type,
                                     java.nio.ByteBuffer buffer)
Extracts a version object from a byte buffer that contains data with the specified content type. If no version can be extracted, returns null.

Parameters:
type - the content type of the data in the buffer
buffer - the buffer containing the data
Returns:
the Version that was extracted, or null if none
Since:
JWI 2.1.0

parseVersionProtected

public static Version parseVersionProtected(java.lang.CharSequence verStr)
Tries to transform the specified character sequence into a version object. If it cannot, returns null

Parameters:
verStr - the sequence of characters to be transformed
Returns:
the version, or null if the character sequence is not a valid version
Since:
JWI 2.1.0

parseVersion

public static Version parseVersion(java.lang.CharSequence verStr)
Tries to transform the specified character sequence into a version object.

Parameters:
verStr - the sequence of characters to be transformed
Returns:
the version
Throws:
java.lang.NullPointerException - if the character sequence is null
java.lang.IllegalArgumentException - if the character sequence does not correspond to a legal version
Since:
JWI 2.1.0

values

public static java.util.List<Version> values()
Emulates the Enum.values() function.

Returns:
all the static data type instances listed in the class, in the order they are declared.
Since:
JWI 2.0.0


Copyright © 2007-2013 Massachusetts Institute of Technology. All Rights Reserved.