getLastASCII method
Peeks ahead and returns 1 if the postfix consists of exactly two digits, 2 if the postfix consists of exactly two consecutive digits and a non extended character or of 4 digits. Returns 0 in any other case
Implementation
int getLastASCII() {
final length = input.length;
final from = fromPosition + characterLength;
if (length - from > 4 || from >= length) {
return 0;
}
if (length - from == 1) {
if (MinimalEncoder.isExtendedASCII(
input.charAt(from),
input.fnc1Character,
)) {
return 0;
}
return 1;
}
if (length - from == 2) {
if (MinimalEncoder.isExtendedASCII(
input.charAt(from),
input.fnc1Character,
) ||
MinimalEncoder.isExtendedASCII(
input.charAt(from + 1),
input.fnc1Character,
)) {
return 0;
}
if (HighLevelEncoder.isDigit(input.charAt(from)) &&
HighLevelEncoder.isDigit(input.charAt(from + 1))) {
return 1;
}
return 2;
}
if (length - from == 3) {
if (HighLevelEncoder.isDigit(input.charAt(from)) &&
HighLevelEncoder.isDigit(input.charAt(from + 1)) &&
!MinimalEncoder.isExtendedASCII(
input.charAt(from + 2),
input.fnc1Character,
)) {
return 2;
}
if (HighLevelEncoder.isDigit(input.charAt(from + 1)) &&
HighLevelEncoder.isDigit(input.charAt(from + 2)) &&
!MinimalEncoder.isExtendedASCII(
input.charAt(from),
input.fnc1Character,
)) {
return 2;
}
return 0;
}
if (HighLevelEncoder.isDigit(input.charAt(from)) &&
HighLevelEncoder.isDigit(input.charAt(from + 1)) &&
HighLevelEncoder.isDigit(input.charAt(from + 2)) &&
HighLevelEncoder.isDigit(input.charAt(from + 3))) {
return 2;
}
return 0;
}