(
CharSequence text,
ParseLog status,
AttributeQuery attributes
)
| 40 | //~ Methoden ---------------------------------------------------------- |
| 41 | |
| 42 | @Override |
| 43 | public Integer parse( |
| 44 | CharSequence text, |
| 45 | ParseLog status, |
| 46 | AttributeQuery attributes |
| 47 | ) { |
| 48 | |
| 49 | Leniency leniency = attributes.get(Attributes.LENIENCY, Leniency.SMART); |
| 50 | |
| 51 | int effectiveMin = 1; |
| 52 | int effectiveMax = 9; |
| 53 | |
| 54 | if (!leniency.isLax()) { |
| 55 | effectiveMin = 4; |
| 56 | } |
| 57 | |
| 58 | int len = text.length(); |
| 59 | int start = status.getPosition(); |
| 60 | int pos = start; |
| 61 | |
| 62 | int protectedChars = |
| 63 | attributes.get(Attributes.PROTECTED_CHARACTERS, 0).intValue(); |
| 64 | |
| 65 | if (protectedChars > 0) { |
| 66 | len -= protectedChars; |
| 67 | } |
| 68 | |
| 69 | if (pos >= len) { |
| 70 | status.setError(start, "Missing digits for: " + this.name()); |
| 71 | status.setWarning(); |
| 72 | return null; |
| 73 | } |
| 74 | |
| 75 | boolean negative = false; |
| 76 | char sign = text.charAt(pos); |
| 77 | |
| 78 | if ( |
| 79 | (sign == '-') |
| 80 | || (sign == '+') |
| 81 | ) { |
| 82 | negative = (sign == '-'); |
| 83 | pos++; |
| 84 | start++; |
| 85 | } |
| 86 | |
| 87 | if (pos >= len) { |
| 88 | status.setError(start, "Missing digits for: " + this.name()); |
| 89 | return null; |
| 90 | } |
| 91 | |
| 92 | int minPos = pos + effectiveMin; |
| 93 | int maxPos = Math.min(len, pos + effectiveMax); |
| 94 | int total = 0; |
| 95 | boolean first = true; |
| 96 | |
| 97 | while (pos < maxPos) { |
| 98 | int digit = text.charAt(pos) - '0'; |
| 99 |
nothing calls this directly
no test coverage detected