net.sourceforge.nite.util
Class VersionChecker

java.lang.Object
  extended by net.sourceforge.nite.util.VersionChecker

public class VersionChecker
extends java.lang.Object

A flexible java version checker that can take different actions for different versions. The default is to warn (on STDERR) if the Java version is less than 1.4.2_05 and to quit with an error message on STDOUT if the Java version is less than 1.4. But you can set the threshholds and make it pop messages on-screen if preferred. Note: depends on alphanumeric String comparison - I think that's valid.. Typical use:

 VersionChecker vc = new VersionChecker();
 int vres = vc.checkVersion();
 if (vres==VersionChecker.VERSION_ERROR) { System.exit(1); }


Field Summary
static int VERSION_ERROR
           
static int VERSION_OK
           
static int VERSION_WARNING
           
 
Constructor Summary
VersionChecker()
          This constructor uses all the defaults: warn (on STDERR) if the Java version is less than 1.4.2_05 and popup an on-screen error message if the Java version is less than 1.4.
VersionChecker(java.lang.String cut, java.lang.String warn, boolean cutmessage, boolean warnmessage)
          This constructor takes user-values for cutoff and warnings: cut is the version number under which an error is reported; warn is the version number below which a warning is reported; cutmessage is true if you want error messages on-screen (false for STDERR); warnmessage is true if you want warninng messages on-screen (false for STDERR).
 
Method Summary
 int checkVersion()
          check version compared to System version string: popup any warning / cutoff and return VERSION_OK, VERSION_WARNING or VERSION_ERROR so the client program can decide what to do about it
 int checkVersion(java.lang.String version)
          check version from given Version string: popup any warning / cutoff and return VERSION_OK, VERSION_WARNING or VERSION_ERROR so the client program can decide what to do about it
 void setCutoffMessageOnScreen(boolean val)
          set to true to see any failure mesage as a popup; false for STDERR.
 void setCutoffThreshhold(java.lang.String val)
          Set the cutoff threshold (as a string like '1.4.2_05' or similar).
 void setWarningMessageOnScreen(boolean val)
          set to true to see any warning mesage as a popup; false for STDERR.
 void setWarningThreshhold(java.lang.String val)
          Set the warning threshold (as a string like '1.4.2_06' or similar).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_OK

public static final int VERSION_OK
See Also:
Constant Field Values

VERSION_WARNING

public static final int VERSION_WARNING
See Also:
Constant Field Values

VERSION_ERROR

public static final int VERSION_ERROR
See Also:
Constant Field Values
Constructor Detail

VersionChecker

public VersionChecker()
This constructor uses all the defaults: warn (on STDERR) if the Java version is less than 1.4.2_05 and popup an on-screen error message if the Java version is less than 1.4.


VersionChecker

public VersionChecker(java.lang.String cut,
                      java.lang.String warn,
                      boolean cutmessage,
                      boolean warnmessage)
This constructor takes user-values for cutoff and warnings: cut is the version number under which an error is reported; warn is the version number below which a warning is reported; cutmessage is true if you want error messages on-screen (false for STDERR); warnmessage is true if you want warninng messages on-screen (false for STDERR).

Method Detail

checkVersion

public int checkVersion(java.lang.String version)
check version from given Version string: popup any warning / cutoff and return VERSION_OK, VERSION_WARNING or VERSION_ERROR so the client program can decide what to do about it


checkVersion

public int checkVersion()
check version compared to System version string: popup any warning / cutoff and return VERSION_OK, VERSION_WARNING or VERSION_ERROR so the client program can decide what to do about it


setCutoffMessageOnScreen

public void setCutoffMessageOnScreen(boolean val)
set to true to see any failure mesage as a popup; false for STDERR. Default is popup


setWarningMessageOnScreen

public void setWarningMessageOnScreen(boolean val)
set to true to see any warning mesage as a popup; false for STDERR. Default is STDERR.


setCutoffThreshhold

public void setCutoffThreshhold(java.lang.String val)
Set the cutoff threshold (as a string like '1.4.2_05' or similar). Default is '1.4'.


setWarningThreshhold

public void setWarningThreshhold(java.lang.String val)
Set the warning threshold (as a string like '1.4.2_06' or similar). Default is '1.4.2_06'.