- All Known Subinterfaces:
CharScannerNumberParser
- All Known Implementing Classes:
CharScannerNumberParserBase,CharScannerNumberParserLang,CharScannerNumberParserString,CharScannerRadixMode
public interface CharScannerRadixHandler
Interface for
radix handling.-
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.
-
Method Details
-
radix
int radix(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.- 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).
-