mil.dod.th.ose.utils/src/mil/dod/th/ose/utils/numbers/Integers.java
public static int parseHexOrDecimal(final String value) throws IllegalArgumentException
    {
        if (Strings.isNullOrEmpty(value))
        {
            throw new IllegalArgumentException("Unable to parse null or empty value");
        }
        
        if (value.startsWith("0x"))
        {
            // assume hex
            final int hexRadix = 16;
            
            final int maxLength = 10; // '0x' plus 2 characters for each byte
            if (value.length() > maxLength)
            {
                throw new IllegalArgumentException("Hexadecimal value is too large");
            }
            
            return (int)Long.parseLong(value.substring(2), hexRadix);
        }
        else
        {
            return Integer.parseInt(value);
        }
    }
/**
     * Parse a string as either a hexadecimal or decimal integer. If the value starts with '0x' it is treated as 
     * hexadecimal, otherwise it is treated as decimal.
     * 
     * @param value
     *      integer string to parse, values larger than an int will result in unpredictable behavior
     * @return
     *      parsed value
     * @throws IllegalArgumentException
     *      if value is null or an empty string
     */
Parse a string as either a hexadecimal or decimal integer. If the value starts with '0x' it is treated as
hexadecimal, otherwise it is treated as decimal.

@param value
integer string to parse, values larger than an int will result in unpredictable behavior
@return
parsed value
@throws IllegalArgumentException
if value is null or an empty string
Parse a string as either a hexadecimal or decimal integer . If the value starts with ' 0x ' it is treated as hexadecimal otherwise it is treated as decimal . @param value integer string to parse values larger than an int will result in unpredictable behavior @return parsed value @throws IllegalArgumentException if value is null or an empty string
public static int parseHexOrDecimal(final String value) throws IllegalArgumentException
    {
        if (Strings.isNullOrEmpty(value))
        {
            throw new IllegalArgumentException("Unable to parse null or empty value");
        }
        if (value.startsWith("0x"))
        {
            final int hexRadix = 16;
            final int maxLength = 10; 
            if (value.length() > maxLength)
            {
                throw new IllegalArgumentException("Hexadecimal value is too large");
            }
            return (int)Long.parseLong(value.substring(2), hexRadix);
        }
        else
        {
            return Integer.parseInt(value);
        }
    }
public static int parseHexOrDecimal ( final String value ) throws IllegalArgumentException { if ( Strings . isNullOrEmpty ( value ) ) { throw new IllegalArgumentException ( "Unable to parse null or empty value" ) ; } if ( value . startsWith ( "0x" ) ) { final int hexRadix = 16 ; final int maxLength = 10 ; if ( value . length ( ) > maxLength ) { throw new IllegalArgumentException ( "Hexadecimal value is too large" ) ; } return ( int ) Long . parseLong ( value . substring ( 2 ) , hexRadix ) ; } else { return Integer . parseInt ( value ) ; } }
Parse a string as either a hexadecimal or decimal integer.
Parse a string as either a hexadecimal or decimal integer .
// assume hex // '0x' plus 2 characters for each byte