(
CharSequence text,
ParsePosition status,
AttributeQuery attributes
)
| 170 | } |
| 171 | |
| 172 | @Override |
| 173 | public EastAsianMonth parse( |
| 174 | CharSequence text, |
| 175 | ParsePosition status, |
| 176 | AttributeQuery attributes |
| 177 | ) { |
| 178 | |
| 179 | Locale loc = attributes.get(Attributes.LANGUAGE, Locale.ROOT); |
| 180 | int len = text.length(); |
| 181 | int start = status.getIndex(); |
| 182 | |
| 183 | if (start >= len) { |
| 184 | status.setErrorIndex(len); |
| 185 | return null; |
| 186 | } |
| 187 | |
| 188 | boolean leap = false; |
| 189 | EastAsianMonth eam; |
| 190 | |
| 191 | if (attributes.contains(DualFormatElement.COUNT_OF_PATTERN_SYMBOLS)) { // numeric case |
| 192 | Map<String, String> textForms = CalendarText.getInstance("generic", loc).getTextForms(); |
| 193 | NumberSystem numsys = attributes.get(Attributes.NUMBER_SYSTEM, NumberSystem.ARABIC); |
| 194 | int pos = start; |
| 195 | char zeroDigit = attributes.get(Attributes.ZERO_DIGIT, numsys.getDigits().charAt(0)); |
| 196 | |
| 197 | boolean trailing = |
| 198 | attributes.get(EastAsianMonth.LEAP_MONTH_IS_TRAILING, "R".equals(textForms.get("leap-alignment"))); |
| 199 | char indicator = |
| 200 | attributes.get(EastAsianMonth.LEAP_MONTH_INDICATOR, textForms.get("leap-indicator").charAt(0)); |
| 201 | |
| 202 | if (!trailing && (text.charAt(pos) == indicator)) { |
| 203 | pos++; |
| 204 | leap = true; |
| 205 | } |
| 206 | |
| 207 | if (numsys.isDecimal()) { |
| 208 | // ignore possible padding |
| 209 | while ((pos < len) && (text.charAt(pos) == zeroDigit)) { |
| 210 | pos++; |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | int m = 0; |
| 215 | |
| 216 | for (int num = 12; (num >= 1) && (m == 0); num--) { |
| 217 | String display = DualFormatElement.toNumeral(numsys, zeroDigit, num); |
| 218 | int numlen = display.length(); |
| 219 | for (int i = 0; ; i++) { |
| 220 | if ((len > pos + i) && (text.charAt(pos + i) != display.charAt(i))) { |
| 221 | break; |
| 222 | } else if (i + 1 == numlen) { |
| 223 | m = num; |
| 224 | pos += numlen; |
| 225 | break; |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 |
nothing calls this directly
no test coverage detected