Class numberConverter


  • public final class numberConverter
    extends java.lang.Object

    The numberConvert is a final class that provide methods for converting numbers in String format to a Java Primitive Type. This class currently support converting numbers in string representation to integer long and integer int values. This class utilized methods from other class in this package and should not be as fast as when calling other classes directly.

    • Constructor Summary

      Constructors 
      Constructor Description
      numberConverter()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int toInt​(java.lang.String input)
      Parse a string of decimal value without a floating point value into an integer int value.
      static int toInt​(java.lang.String input, int base)
      Parse the input string to an integer int value with the defined base number for the conversion.
      static long toLong​(java.lang.String input)
      Parse a string of decimal value without a floating point value into an integer long value.
      static long toLong​(java.lang.String input, int base)
      Parse the input string to an integer long value with the defined base number for the conversion.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • numberConverter

        public numberConverter()
    • Method Detail

      • toInt

        public static final int toInt​(java.lang.String input)
        Parse a string of decimal value without a floating point value into an integer int value. This method does not throw error. However, the base10Util.toInt method that ultilizes by this method throws error.
        Parameters:
        input - A string to be converted to an integer int value.
        Returns:
        An integer int value of the decimal input string.
        See Also:
        base10Util.toInt(String)
      • toInt

        public static int toInt​(java.lang.String input,
                                int base)
        Parse the input string to an integer int value with the defined base number for the conversion. Current support bases are 2, 8, 10, 16. This method parses input as sign values. This method only throw UnsupportedOperationException, however, methods that ultilizes by this method throw errors.
        Parameters:
        input - A string to be converted to an integer int value.
        base - An integer int value that defines the number base of the input string.
        Returns:
        An integer int value of the input string.
        Throws:
        java.lang.UnsupportedOperationException - If the base is a value that is not supported.
        See Also:
        base2Util.toInt(String), base8Util.toInt(String), base10Util.toInt(String), base16Util.toInt(String)
      • toLong

        public static final long toLong​(java.lang.String input)
        Parse a string of decimal value without a floating point value into an integer long value. This method does not throw error. However, the base10Util.toLong method that ultilizes by this method throws error.
        Parameters:
        input - A string to be converted to an integer long value.
        Returns:
        An integer long value of the decimal input string.
        See Also:
        base10Util.toLong(String)
      • toLong

        public static long toLong​(java.lang.String input,
                                  int base)
        Parse the input string to an integer long value with the defined base number for the conversion. Current support bases are 2, 8, 10, 16. For octal, hexadecimal, and binary, this method parse them as unsigned. To parse them as sign use OctalUtil.soct2long() or HexUtil.shex2long(). This package is most likely not going to support signed binary. This method only throw UnsupportedOperationException, however, methods that ultilizes by this method throw errors.
        Parameters:
        input - A string to be converted to an integer long value.
        base - An integer int value that defines the number base of the input string.
        Returns:
        An integer long value of the input string.
        Throws:
        java.lang.UnsupportedOperationException - If the base is a value that is not supported.
        See Also:
        base2Util.toLong(String), base8Util.toLong(String), base10Util.toLong(String), base16Util.toLong(String)