Package host.fai.lib.faiNumber
Class numberConverter
- java.lang.Object
-
- host.fai.lib.faiNumber.numberConverter
-
public final class numberConverter extends java.lang.ObjectThe
numberConvertis 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 inttoInt(java.lang.String input)Parse a string of decimal value without a floating point value into an integer int value.static inttoInt(java.lang.String input, int base)Parse the input string to an integer int value with the defined base number for the conversion.static longtoLong(java.lang.String input)Parse a string of decimal value without a floating point value into an integer long value.static longtoLong(java.lang.String input, int base)Parse the input string to an integer long value with the defined base number for the conversion.
-
-
-
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, thebase10Util.toIntmethod 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
inputstring. - 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 theinputstring.- Returns:
- An integer int value of the
inputstring. - Throws:
java.lang.UnsupportedOperationException- If thebaseis 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, thebase10Util.toLongmethod 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
inputstring. - 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 useOctalUtil.soct2long()orHexUtil.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 theinputstring.- Returns:
- An integer long value of the
inputstring. - Throws:
java.lang.UnsupportedOperationException- If thebaseis a value that is not supported.- See Also:
base2Util.toLong(String),base8Util.toLong(String),base10Util.toLong(String),base16Util.toLong(String)
-
-