class StringUtilities {

    public static boolean isInteger(String s)
    {
        if (s == null)
        {
            return false;
        }

        final int radix = 10;
        int result = 0;
        int i = 0;
        final int len = s.length();
        int limit = -Integer.MAX_VALUE;
        int multmin;
        int digit;

        if (len > 0)
        {
            final char firstChar = s.charAt(0);
            if (firstChar < '0')
            {
                // Possible leading "+" or "-"
                if (firstChar == '-')
                {
                    limit = Integer.MIN_VALUE;
                }
                else if (firstChar != '+')
                {
                    return false;
                }

                if (len == 1)
                {
                    return false;
                }
                i++;
            }
            multmin = limit / radix;
            while (i < len)
            {
                // Accumulating negatively avoids surprises near MAX_VALUE
                digit = Character.digit(s.charAt(i++), radix);
                if (digit < 0)
                {
                    return false;
                }
                if (result < multmin)
                {
                    return false;
                }
                result *= radix;
                if (result < limit + digit)
                {
                    return false;
                }
                result -= digit;
            }
        }
        else
        {
            return false;
        }
        return true;
    }

    private  StringUtilities();

}