com.amx.duet.tools.lang
Class ValidateUtil

java.lang.Object
  extended bycom.amx.duet.tools.lang.ValidateUtil

public class ValidateUtil
extends java.lang.Object

A utility class used to perform common validation routines in Duet modules.

Version:
1.0.0

Constructor Summary
ValidateUtil()
           
 
Method Summary
static int ATOI(java.lang.String str)
          Simulates the functionality of the NetLinx ATOI function.
static boolean isValidDPS(com.amx.duet.core.master.netlinx.DPS dps)
          Checks to see if the DPS passed in does not contain a 0 for the device or port numbers
static boolean isValidDPS(java.lang.String dps)
          Checks to see if the string passed in is a NetLinx D:P:S or not
static boolean isValidIP(java.lang.String ip)
          Checks to see if the string passed in is a valid IP address or not
static java.lang.String validateBaudRate(java.lang.String rate, java.lang.String[] validRates, java.lang.String defaultRate)
          Validates the current baud rate.
static java.lang.String validateDeviceID(java.lang.String deviceID, int nMinID, int nMaxID, java.lang.String defaultID)
          Validates the current device ID.
static java.lang.String validatePollTime(java.lang.String polltime, long nTime)
          Deprecated. Use validatePollTime(String, long, long, long) instead. Validates the current poll time. If the current poll time is invalid, the passed in time value (in seconds) is returned.
static java.lang.String validatePollTime(java.lang.String polltime, long lMin, long lMax, long lTime)
          Validates the current poll time.
static java.lang.String validateReconnnectTime(java.lang.String connectTime, long lMin, long lMax, long lTime)
           
static java.lang.String validateTimeoutCount(java.lang.String timeout, int nMax, int nDefault)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidateUtil

public ValidateUtil()
Method Detail

validateBaudRate

public static java.lang.String validateBaudRate(java.lang.String rate,
                                                java.lang.String[] validRates,
                                                java.lang.String defaultRate)
Validates the current baud rate. If the current baud rate is invalid or does not match one of the valid rates in the list, the passed in default baud rate is returned.

Parameters:
rate - String containing the device's current baud rate setting
validRates - an array of Strings containing all valid baud rates for the device
defaultRate - String containing the device's default baud rate
Returns:
String containing the current baud rate setting, or the default value

validateDeviceID

public static java.lang.String validateDeviceID(java.lang.String deviceID,
                                                int nMinID,
                                                int nMaxID,
                                                java.lang.String defaultID)
Validates the current device ID. If the current ID is invalid or not with the minimum and maximum ID range, the passed in default ID is returned.

Parameters:
deviceID - String containing the device's current device ID setting
nMinID - integer, represents the smallest valid ID
nMaxID - integer, represents the largest valid ID
defaultID - String containing the device's default ID
Returns:
String containing the current device ID setting, or the default value

validatePollTime

public static java.lang.String validatePollTime(java.lang.String polltime,
                                                long nTime)
Deprecated. Use validatePollTime(String, long, long, long) instead. Validates the current poll time. If the current poll time is invalid, the passed in time value (in seconds) is returned.

Parameters:
polltime - String containing the device's current poll time setting
nTime - integer, represents the default poll time in milliseconds
Returns:
String containing the current poll time setting, or the default value in milliseconds converted to seconds

validatePollTime

public static java.lang.String validatePollTime(java.lang.String polltime,
                                                long lMin,
                                                long lMax,
                                                long lTime)
Validates the current poll time. If the current poll time is invalid, the passed in time value (in seconds) is returned.

Parameters:
polltime - String containing the device's current poll time setting
lMin - minimum poll time value.
lMax - maximum poll time value.
lTime - integer, represents the default poll time in milliseconds
Returns:
String containing the current poll time setting, or the default value in milliseconds converted to seconds

validateTimeoutCount

public static java.lang.String validateTimeoutCount(java.lang.String timeout,
                                                    int nMax,
                                                    int nDefault)
Parameters:
timeout -
nMax -
nDefault -
Returns:

validateReconnnectTime

public static java.lang.String validateReconnnectTime(java.lang.String connectTime,
                                                      long lMin,
                                                      long lMax,
                                                      long lTime)
Parameters:
lMin -
lMax -
lTime -
Returns:

isValidDPS

public static final boolean isValidDPS(java.lang.String dps)
Checks to see if the string passed in is a NetLinx D:P:S or not

Parameters:
dps - String containing the DPS to validate
Returns:
true if this is a valid DPS; false otherwise

isValidDPS

public static final boolean isValidDPS(com.amx.duet.core.master.netlinx.DPS dps)
Checks to see if the DPS passed in does not contain a 0 for the device or port numbers

Parameters:
dps - DPS to validate
Returns:
true if this is a valid DPS; false otherwise

isValidIP

public static final boolean isValidIP(java.lang.String ip)
Checks to see if the string passed in is a valid IP address or not

Parameters:
ip - String containing the address to validate
Returns:
true if this is a valid IP address; false otherwise

ATOI

public static int ATOI(java.lang.String str)
Simulates the functionality of the NetLinx ATOI function. This function returns Integer.MIN_VALUE if no numerical characters are found. Note: the numerical characters must be at the start of the string

Parameters:
str - - String containing an int value
Returns:
int value contained in the string


Copyright © 2008 AMX LLC. All Rights Reserved.