Class RadixUtils.NumberPattern
- java.lang.Object
-
- net.emustudio.emulib.runtime.helpers.RadixUtils.NumberPattern
-
- Enclosing class:
- RadixUtils
public static class RadixUtils.NumberPattern extends java.lang.Object
This class represents a number pattern in single radix
-
-
Constructor Summary
Constructors Constructor Description NumberPattern(java.lang.String regex, int radix, int cutFromStart, int cutFromEnd)
Create instance of the NumberPattern
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getRadix()
Get radix of this NumberPatternboolean
matches(java.lang.String number)
Determines if a number represented as String matches this NumberPattern.java.lang.String
prepareNumber(java.lang.String number)
Prepares the number for radix conversion.
-
-
-
Constructor Detail
-
NumberPattern
public NumberPattern(java.lang.String regex, int radix, int cutFromStart, int cutFromEnd)
Create instance of the NumberPattern- Parameters:
regex
- Regular expression for the number parserradix
- The radix that the pattern representscutFromStart
- Count of characters that will be cut from the beginning of a number by callingprepareNumber
method.cutFromEnd
- Count of characters that will be cut from the end of a number by callingprepareNumber
method.
-
-
Method Detail
-
matches
public boolean matches(java.lang.String number)
Determines if a number represented as String matches this NumberPattern.- Parameters:
number
- the number String representation- Returns:
- true if the number matches this pattern, false otherwise
-
getRadix
public int getRadix()
Get radix of this NumberPattern- Returns:
- radix of this pattern
-
prepareNumber
public java.lang.String prepareNumber(java.lang.String number)
Prepares the number for radix conversion.It formats given number into a form that does not contain any additional characters for radix recognition.
For example, pattern
0x[0-9a-fA-F]+
, representing hexadecimal number, contains some characters needed for pattern recognition, they are the first two (0x
).The numbers of left and right cut are defined in the constructor.
- Parameters:
number
- the number String representation- Returns:
- String number prepared for radix conversion.
-
-