GUACAMOLE-422: Update comments and internals of protocol methods.

This commit is contained in:
Virtually Nick
2019-05-10 12:33:59 -04:00
parent 06315a88b3
commit dd9062a841
2 changed files with 21 additions and 33 deletions

View File

@@ -152,7 +152,8 @@ public class GuacamoleClientInformation {
/** /**
* Return the timezone as reported by the client, or null if the timezone * Return the timezone as reported by the client, or null if the timezone
* is not set. Valid timezones are specified in tz database format. * is not set. Valid timezones are specified in IANA zone key format,
* also known as Olson time zone database or TZ Database.
* *
* @return * @return
* A string value of the timezone reported by the client. * A string value of the timezone reported by the client.
@@ -163,8 +164,8 @@ public class GuacamoleClientInformation {
/** /**
* Set the string value of the timezone, or null if the timezone will not * Set the string value of the timezone, or null if the timezone will not
* be provided by the client. Valid timezones are specified in tz * be provided by the client. Valid timezones are specified in IANA zone
* database format. * key format (aka Olson time zone database or tz database).
* *
* @param timezone * @param timezone
* The string value of the timezone reported by the client, in tz * The string value of the timezone reported by the client, in tz

View File

@@ -120,36 +120,16 @@ public enum GuacamoleProtocolVersion {
*/ */
public boolean atLeast(GuacamoleProtocolVersion otherVersion) { public boolean atLeast(GuacamoleProtocolVersion otherVersion) {
// Major version is greater // If major is not the same, compare first
if (major > otherVersion.getMajor()) if (major != otherVersion.getMajor())
return true; return major > otherVersion.getMajor();
// Major version is less than or equal to. // Major is the same, but minor is not, so compare minor versions
else { if (minor != otherVersion.getMinor())
return minor > otherVersion.getMinor();
// Major version is less than // Major and minor are identical, so compare and return patch
if (major < otherVersion.getMajor()) return patch >= otherVersion.getPatch();
return false;
// Major version is equal, minor version is greater
if (minor > otherVersion.getMinor())
return true;
// Minor version is less than or equal to.
else {
// Minor version is less than
if (minor < otherVersion.getMinor())
return false;
// Patch version is greater or equal
if (patch >= otherVersion.getPatch())
return true;
}
}
// Version is either less than or equal to.
return false;
} }
@@ -162,14 +142,21 @@ public enum GuacamoleProtocolVersion {
* The String format of the version to parse. * The String format of the version to parse.
* *
* @return * @return
* The enum value that matches the specified version. * The enum value that matches the specified version, VERSION_1_0_0
* if no match is found, or null if no comparison version is provided.
*/ */
public static GuacamoleProtocolVersion getVersion(String version) { public static GuacamoleProtocolVersion getVersion(String version) {
if (version == null || version.isEmpty()) if (version == null || version.isEmpty())
return null; return null;
return valueOf(version); try {
return valueOf(version);
}
// If nothing matches, then return the most compatible version.
catch (IllegalArgumentException e) {
return GuacamoleProtocolVersion.VERSION_1_0_0;
}
} }