com.universaldevices.common
Class UDUtil

java.lang.Object
  extended by com.universaldevices.common.UDUtil

public class UDUtil
extends java.lang.Object


Method Summary
static int compare(java.lang.Comparable a, java.lang.Comparable b)
          Compare two objects both of which may be null
static java.lang.String encodeXmlText(java.lang.String str, boolean fromHtml)
          Translate special characters from XML
static java.lang.String fromXmlText(java.lang.String str)
          Translate special characters from XML (e.g.
static int[] getInts(java.lang.String str, java.lang.String sep, int base, int defVal)
          Return an array of integers given a delimited string (e.g.
static boolean isEqual(java.lang.Object a, java.lang.Object b)
          Compare two objects both of which may be null
static int parseInteger(int base, java.lang.String data)
          Convert a string to an integer.
static int parseInteger(int base, java.lang.String data, int defaultValue)
          Convert a string to an integer, allowing for 0x prefix for hexadecimal values.
static int parseInteger(java.lang.String data)
          Convert a string to an integer, allowing for 0x prefix for hexadecimal values.
static java.lang.Integer parseInteger(java.lang.String data, java.lang.Integer defaultValue)
          Convert a string to an integer, allowing for 0x prefix for hexadecimal values.
static void showError(int status, java.lang.String message)
           
static boolean sleep(int millis)
          Sleep specified number of milliseconds.
static java.lang.String toHex(int v)
           
static java.lang.String toHex(int v, int minLen)
           
static java.lang.String toXmlText(java.lang.String str)
          Translate special characters to XML (e.g.
static boolean validateNodeName(java.lang.String newName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInts

public static int[] getInts(java.lang.String str,
                            java.lang.String sep,
                            int base,
                            int defVal)
Return an array of integers given a delimited string (e.g. "12.5.34.55", return { 12, 5, 34, 55 })

Parameters:
str - String to parse
sep - Separator
base - The base (e.g. 10 for decimal, 16 for hex, etc.)
defVal - Default value if number cannot be parsed
Returns:
Array of ints

sleep

public static boolean sleep(int millis)
Sleep specified number of milliseconds.

Parameters:
millis - Milliseconds to sleep
Returns:
True entire time completed, False if interrupted.

toXmlText

public static java.lang.String toXmlText(java.lang.String str)
Translate special characters to XML (e.g. ">" to ">")

Parameters:
str - String to translate
Returns:
The translated string

fromXmlText

public static java.lang.String fromXmlText(java.lang.String str)
Translate special characters from XML (e.g. ">" to ">")

Parameters:
str - String to translate
Returns:
The translated string

encodeXmlText

public static java.lang.String encodeXmlText(java.lang.String str,
                                             boolean fromHtml)
Translate special characters from XML

Parameters:
str - String to translate
fromHtml - True the convert from XML to chars, False convert from chars to XML
Returns:
The translated string

parseInteger

public static java.lang.Integer parseInteger(java.lang.String data,
                                             java.lang.Integer defaultValue)
Convert a string to an integer, allowing for 0x prefix for hexadecimal values.

Parameters:
data - The string representation of the integer
defaultValue - The value to return if the string cannot be converted into an integer.
Returns:
The integer, or defaultValue if it could not be converted.

parseInteger

public static int parseInteger(java.lang.String data)
Convert a string to an integer, allowing for 0x prefix for hexadecimal values.

Parameters:
data - The string representation of the integer
Returns:
The integer value.

parseInteger

public static int parseInteger(int base,
                               java.lang.String data,
                               int defaultValue)
Convert a string to an integer, allowing for 0x prefix for hexadecimal values.

Parameters:
base - The base (e.g. 10 for decimal, 16 for hex, etc.)
data - The string representation of the integer
defaultValue - The value to return if the string cannot be converted into an integer.
Returns:
The integer, or defaultValue if it could not be converted.

parseInteger

public static int parseInteger(int base,
                               java.lang.String data)
Convert a string to an integer.

Parameters:
base - The base (e.g. 10 for decimal, 16 for hex, etc.)
data - The string representation of the integer
Returns:
The integer value.

isEqual

public static boolean isEqual(java.lang.Object a,
                              java.lang.Object b)
Compare two objects both of which may be null

Parameters:
a - Object 1
b - Object 2
Returns:
True if both objects are equal

compare

public static int compare(java.lang.Comparable a,
                          java.lang.Comparable b)
Compare two objects both of which may be null

Parameters:
a - Object 1
b - Object 2
Returns:
True if both objects are equal

toHex

public static java.lang.String toHex(int v)

toHex

public static java.lang.String toHex(int v,
                                     int minLen)

validateNodeName

public static boolean validateNodeName(java.lang.String newName)

showError

public static void showError(int status,
                             java.lang.String message)