- All Implemented Interfaces:
CharScannerRadixHandler,Serializable,Comparable<CharScannerRadixMode>,Constable
public enum CharScannerRadixMode
extends Enum<CharScannerRadixMode>
implements CharScannerRadixHandler
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionintradix(int radix, char symbol) This method will be called if the first character is '0' and will also pass a lookahead of the next character as parametersymbol.static CharScannerRadixModeReturns the enum constant of this class with the specified name.static CharScannerRadixMode[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ALL
Accept any radix (2, 8, 10, 16). -
ONLY_10
Accept only decimal raidx (10). -
NO_OCTAL
Accept all radix except octal (2, 10, 16).
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
radix
public int radix(int radix, char symbol) Description copied from interface:CharScannerRadixHandlerThis method will be called if the first character is '0' and will also pass a lookahead of the next character as parametersymbol.- Specified by:
radixin interfaceCharScannerRadixHandler- Parameters:
radix- the radix. Will be16for "0x",2for "0b",8for "0" followed by an octal digit (0-7), and0in case an unexpected character was found after the first zero.symbol- the character followed by the leading zero. E.g. 'x' or 'X' for radix 16. You could even implement custom radix mode like "0o" for octal instead of "0" by returning8ifsymbolis 'o' or 'O'.- Returns:
- the actual radix to use for further processing. If
0(or less) is returned the radix is not accepted and "0" is treated as a leading zero rather than a prefix of the radix that will remain to be10. Typically implementations will return the givenradix, but to prevent octal parsing due to a leading zero (Java/C legacy) you can return10if8was given. If8is returned, the symbol will be consumed and skipped if it is not a digit while otherwise the digit will be consumed as part of the number even if it is greater than 7 (finally leading to aNumberFormatException).
-