com.amx.duet.tools.text
Class NumericUtil

java.lang.Object
  extended bycom.amx.duet.tools.text.NumericUtil

public class NumericUtil
extends java.lang.Object

A utility class commonly used for safely converting String values to numeric values and numeric values to String values.

Version:
1.0.0

Constructor Summary
NumericUtil()
           
 
Method Summary
static boolean atob(java.lang.String value)
          Converts a character representation to a boolean value
static double atod(java.lang.String value)
          Converts a character representation (with or without exponent) of a number to a 64-bit floating point value
static float atof(java.lang.String value)
          Converts a character representation (with or without exponent) of a number to a 32-bit floating point value
static float ATOF(java.lang.String str)
          Simulates the functionality of the NetLinx ATOF function.
static int atoi(java.lang.String value)
          Converts a character representation of a number to a 32-bit integer value
static int ATOI(java.lang.String str)
          Simulates the functionality of the NetLinx ATOI function.
static long atol(java.lang.String value)
          Converts a character representation of a number to a 64-bit long value
static java.lang.String btoa(boolean value)
          Converts a boolean value to an ASCII string.
static java.lang.String dtoa(double value)
          Converts a 64-bit floating-point value to an ASCII string containing the representation of the number
static java.lang.String ftoa(float value)
          Converts a 32-bit floating-point value to an ASCII string containing the representation of the number
static boolean isNumeric(char cValue)
          Check to see if the character passed in is a numeric value.
static boolean isNumeric(java.lang.String sValue)
          Check to see if the string passed in contains all numeric values.
static java.lang.String itoa(int value)
          Converts a 32-bit integer to an ASCII string.
static java.lang.String ltoa(long value)
          Converts a 64-bit long to an ASCII string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumericUtil

public NumericUtil()
Method Detail

isNumeric

public static final boolean isNumeric(char cValue)
Check to see if the character passed in is a numeric value.

Parameters:
cValue - character value to check.
Returns:
true if this a numeric value; false otherwise.

isNumeric

public static final boolean isNumeric(java.lang.String sValue)
Check to see if the string passed in contains all numeric values.

Parameters:
sValue - String value to check.
Returns:
true if this is a numeric string; 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

ATOF

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

Parameters:
str - - String containing a float value
Returns:
float value contained in the string

atoi

public static final int atoi(java.lang.String value)
Converts a character representation of a number to a 32-bit integer value

Parameters:
value - String containing the character representation of the integer
Returns:
A 32-bit integer representing the converted string. Any non-numeric characters in the string are ignored. atoi returns the value representing the first complete set of characters that represent an integer. Valid characters are "0" through "9" as well as a prepended "-" representing a negative sign. If invalid characters are found, zero is returned as a result.

atol

public static final long atol(java.lang.String value)
Converts a character representation of a number to a 64-bit long value

Parameters:
value - String containing the character representation of the long
Returns:
A 64-bit long representing the converted string. Any non-numeric characters in the string are ignored. atol returns the value representing the first complete set of characters that represent a long. Valid characters are "0" through "9" as well as a prepended "-" representing a negative sign. If invalid characters are found, zero is returned as a result.

atof

public static final float atof(java.lang.String value)
Converts a character representation (with or without exponent) of a number to a 32-bit floating point value

Parameters:
value - String containing the character representation of the floating point number.
Returns:
A 32-bit floating point number representing the converted string. Any non-numeric characters in the string are ignored. atof returns the value representing the first complete set of characters that represents a floating point value. Valid characters are "0" through "9" and "." along with the sign designators ("+" and "-") and the exponent ("e" or "E"). If invalid characters are found, zero is returned as a result.

atod

public static final double atod(java.lang.String value)
Converts a character representation (with or without exponent) of a number to a 64-bit floating point value

Parameters:
value - String containing the character representation of the floating point number.
Returns:
A 64-bit floating point number representing the converted string. Any non-numeric characters in the string are ignored. atod returns the value representing the first complete set of characters that represents a floating point value. Valid characters are "0" through "9" and "." along with the sign designators ("+" and "-") and the exponent ("e" or "E"). If invalid characters are found, zero is returned as a result.

atob

public static final boolean atob(java.lang.String value)
Converts a character representation to a boolean value

Parameters:
value - String containing the character representation of the boolean value.
Returns:
A boolean value (either true or false) representing the converted string. atob returns the value representing the first complete set of characters that represent a boolean like value. Valid true characters are "1" or "true" (case sensitive). Everything else is considered false.

itoa

public static final java.lang.String itoa(int value)
Converts a 32-bit integer to an ASCII string.

Parameters:
value - a 32-bit integer to convert to a string.
Returns:
A character string that contains the representation of the specified integer.

ltoa

public static final java.lang.String ltoa(long value)
Converts a 64-bit long to an ASCII string.

Parameters:
value - a 64-bit long to convert to a string.
Returns:
A character string that contains the representation of the specified long.

ftoa

public static final java.lang.String ftoa(float value)
Converts a 32-bit floating-point value to an ASCII string containing the representation of the number

Parameters:
value - a 32-bit floating-point number to convert to a string.
Returns:
A character string that contains the representation of the specified floating point number. The character representation will use exponents if necessary.

dtoa

public static final java.lang.String dtoa(double value)
Converts a 64-bit floating-point value to an ASCII string containing the representation of the number

Parameters:
value - a 64-bit floating-point number to convert to a string.
Returns:
A character string that contains the representation of the specified double value. The character representation will use exponents if necessary.

btoa

public static final java.lang.String btoa(boolean value)
Converts a boolean value to an ASCII string.

Parameters:
value - a boolean to convert to a string.
Returns:
A character string that contains the representation of the specified boolean. If value is true, a "1" will be returned. Otherwise, "0" will be returned.


Copyright © 2008 AMX LLC. All Rights Reserved.