1 /*
   2  * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /*
  27  * This file is available under and governed by the GNU General Public
  28  * License version 2 only, as published by the Free Software Foundation.
  29  * However, the following notice accompanied the original version of this
  30  * file:
  31  *
  32  * Copyright (c) 2011-2012, Stephen Colebourne & Michael Nascimento Santos
  33  *
  34  * All rights reserved.
  35  *
  36  * Redistribution and use in source and binary forms, with or without
  37  * modification, are permitted provided that the following conditions are met:
  38  *
  39  *  * Redistributions of source code must retain the above copyright notice,
  40  *    this list of conditions and the following disclaimer.
  41  *
  42  *  * Redistributions in binary form must reproduce the above copyright notice,
  43  *    this list of conditions and the following disclaimer in the documentation
  44  *    and/or other materials provided with the distribution.
  45  *
  46  *  * Neither the name of JSR-310 nor the names of its contributors
  47  *    may be used to endorse or promote products derived from this software
  48  *    without specific prior written permission.
  49  *
  50  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  51  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  52  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  53  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  54  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  55  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  56  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  57  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  58  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  59  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  60  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  61  */
  62 package java.time.format;
  63 
  64 import static java.time.temporal.ChronoField.AMPM_OF_DAY;
  65 import static java.time.temporal.ChronoField.DAY_OF_WEEK;
  66 import static java.time.temporal.ChronoField.ERA;
  67 import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
  68 
  69 import java.time.chrono.Chronology;
  70 import java.time.chrono.IsoChronology;
  71 import java.time.chrono.JapaneseChronology;
  72 import java.time.temporal.ChronoField;
  73 import java.time.temporal.IsoFields;
  74 import java.time.temporal.TemporalField;
  75 import java.util.AbstractMap.SimpleImmutableEntry;
  76 import java.util.ArrayList;
  77 import java.util.Calendar;
  78 import java.util.Collections;
  79 import java.util.Comparator;
  80 import java.util.HashMap;
  81 import java.util.Iterator;
  82 import java.util.List;
  83 import java.util.Locale;
  84 import java.util.Map;
  85 import java.util.Map.Entry;
  86 import java.util.ResourceBundle;
  87 import java.util.concurrent.ConcurrentHashMap;
  88 import java.util.concurrent.ConcurrentMap;
  89 
  90 import sun.util.locale.provider.CalendarDataUtility;
  91 import sun.util.locale.provider.LocaleProviderAdapter;
  92 import sun.util.locale.provider.LocaleResources;
  93 
  94 /**
  95  * A provider to obtain the textual form of a date-time field.
  96  *
  97  * @implSpec
  98  * Implementations must be thread-safe.
  99  * Implementations should cache the textual information.
 100  *
 101  * @since 1.8
 102  */
 103 class DateTimeTextProvider {
 104 
 105     /** Cache. */
 106     private static final ConcurrentMap<Entry<TemporalField, Locale>, Object> CACHE = new ConcurrentHashMap<>(16, 0.75f, 2);
 107     /** Comparator. */
 108     private static final Comparator<Entry<String, Long>> COMPARATOR = new Comparator<Entry<String, Long>>() {
 109         @Override
 110         public int compare(Entry<String, Long> obj1, Entry<String, Long> obj2) {
 111             return obj2.getKey().length() - obj1.getKey().length();  // longest to shortest
 112         }
 113     };
 114 
 115     DateTimeTextProvider() {}
 116 
 117     /**
 118      * Gets the provider of text.
 119      *
 120      * @return the provider, not null
 121      */
 122     static DateTimeTextProvider getInstance() {
 123         return new DateTimeTextProvider();
 124     }
 125 
 126     /**
 127      * Gets the text for the specified field, locale and style
 128      * for the purpose of formatting.
 129      * <p>
 130      * The text associated with the value is returned.
 131      * The null return value should be used if there is no applicable text, or
 132      * if the text would be a numeric representation of the value.
 133      *
 134      * @param field  the field to get text for, not null
 135      * @param value  the field value to get text for, not null
 136      * @param style  the style to get text for, not null
 137      * @param locale  the locale to get text for, not null
 138      * @return the text for the field value, null if no text found
 139      */
 140     public String getText(TemporalField field, long value, TextStyle style, Locale locale) {
 141         Object store = findStore(field, locale);
 142         if (store instanceof LocaleStore) {
 143             return ((LocaleStore) store).getText(value, style);
 144         }
 145         return null;
 146     }
 147 
 148     /**
 149      * Gets the text for the specified chrono, field, locale and style
 150      * for the purpose of formatting.
 151      * <p>
 152      * The text associated with the value is returned.
 153      * The null return value should be used if there is no applicable text, or
 154      * if the text would be a numeric representation of the value.
 155      *
 156      * @param chrono  the Chronology to get text for, not null
 157      * @param field  the field to get text for, not null
 158      * @param value  the field value to get text for, not null
 159      * @param style  the style to get text for, not null
 160      * @param locale  the locale to get text for, not null
 161      * @return the text for the field value, null if no text found
 162      */
 163     public String getText(Chronology chrono, TemporalField field, long value,
 164                                     TextStyle style, Locale locale) {
 165         if (chrono == IsoChronology.INSTANCE
 166                 || !(field instanceof ChronoField)) {
 167             return getText(field, value, style, locale);
 168         }
 169 
 170         int fieldIndex;
 171         int fieldValue;
 172         if (field == ERA) {
 173             fieldIndex = Calendar.ERA;
 174             if (chrono == JapaneseChronology.INSTANCE) {
 175                 if (value == -999) {
 176                     fieldValue = 0;
 177                 } else {
 178                     fieldValue = (int) value + 2;
 179                 }
 180             } else {
 181                 fieldValue = (int) value;
 182             }
 183         } else if (field == MONTH_OF_YEAR) {
 184             fieldIndex = Calendar.MONTH;
 185             fieldValue = (int) value - 1;
 186         } else if (field == DAY_OF_WEEK) {
 187             fieldIndex = Calendar.DAY_OF_WEEK;
 188             fieldValue = (int) value + 1;
 189             if (fieldValue > 7) {
 190                 fieldValue = Calendar.SUNDAY;
 191             }
 192         } else if (field == AMPM_OF_DAY) {
 193             fieldIndex = Calendar.AM_PM;
 194             fieldValue = (int) value;
 195         } else {
 196             return null;
 197         }
 198         return CalendarDataUtility.retrieveJavaTimeFieldValueName(
 199                 chrono.getCalendarType(), fieldIndex, fieldValue, style.toCalendarStyle(), locale);
 200     }
 201 
 202     /**
 203      * Gets an iterator of text to field for the specified field, locale and style
 204      * for the purpose of parsing.
 205      * <p>
 206      * The iterator must be returned in order from the longest text to the shortest.
 207      * <p>
 208      * The null return value should be used if there is no applicable parsable text, or
 209      * if the text would be a numeric representation of the value.
 210      * Text can only be parsed if all the values for that field-style-locale combination are unique.
 211      *
 212      * @param field  the field to get text for, not null
 213      * @param style  the style to get text for, null for all parsable text
 214      * @param locale  the locale to get text for, not null
 215      * @return the iterator of text to field pairs, in order from longest text to shortest text,
 216      *  null if the field or style is not parsable
 217      */
 218     public Iterator<Entry<String, Long>> getTextIterator(TemporalField field, TextStyle style, Locale locale) {
 219         Object store = findStore(field, locale);
 220         if (store instanceof LocaleStore) {
 221             return ((LocaleStore) store).getTextIterator(style);
 222         }
 223         return null;
 224     }
 225 
 226     /**
 227      * Gets an iterator of text to field for the specified chrono, field, locale and style
 228      * for the purpose of parsing.
 229      * <p>
 230      * The iterator must be returned in order from the longest text to the shortest.
 231      * <p>
 232      * The null return value should be used if there is no applicable parsable text, or
 233      * if the text would be a numeric representation of the value.
 234      * Text can only be parsed if all the values for that field-style-locale combination are unique.
 235      *
 236      * @param chrono  the Chronology to get text for, not null
 237      * @param field  the field to get text for, not null
 238      * @param style  the style to get text for, null for all parsable text
 239      * @param locale  the locale to get text for, not null
 240      * @return the iterator of text to field pairs, in order from longest text to shortest text,
 241      *  null if the field or style is not parsable
 242      */
 243     public Iterator<Entry<String, Long>> getTextIterator(Chronology chrono, TemporalField field,
 244                                                          TextStyle style, Locale locale) {
 245         if (chrono == IsoChronology.INSTANCE
 246                 || !(field instanceof ChronoField)) {
 247             return getTextIterator(field, style, locale);
 248         }
 249 
 250         int fieldIndex;
 251         switch ((ChronoField)field) {
 252         case ERA:
 253             fieldIndex = Calendar.ERA;
 254             break;
 255         case MONTH_OF_YEAR:
 256             fieldIndex = Calendar.MONTH;
 257             break;
 258         case DAY_OF_WEEK:
 259             fieldIndex = Calendar.DAY_OF_WEEK;
 260             break;
 261         case AMPM_OF_DAY:
 262             fieldIndex = Calendar.AM_PM;
 263             break;
 264         default:
 265             return null;
 266         }
 267 
 268         int calendarStyle = (style == null) ? Calendar.ALL_STYLES : style.toCalendarStyle();
 269         Map<String, Integer> map = CalendarDataUtility.retrieveJavaTimeFieldValueNames(
 270                 chrono.getCalendarType(), fieldIndex, calendarStyle, locale);
 271         if (map == null) {
 272             return null;
 273         }
 274         List<Entry<String, Long>> list = new ArrayList<>(map.size());
 275         switch (fieldIndex) {
 276         case Calendar.ERA:
 277             for (Map.Entry<String, Integer> entry : map.entrySet()) {
 278                 int era = entry.getValue();
 279                 if (chrono == JapaneseChronology.INSTANCE) {
 280                     if (era == 0) {
 281                         era = -999;
 282                     } else {
 283                         era -= 2;
 284                     }
 285                 }
 286                 list.add(createEntry(entry.getKey(), (long)era));
 287             }
 288             break;
 289         case Calendar.MONTH:
 290             for (Map.Entry<String, Integer> entry : map.entrySet()) {
 291                 list.add(createEntry(entry.getKey(), (long)(entry.getValue() + 1)));
 292             }
 293             break;
 294         case Calendar.DAY_OF_WEEK:
 295             for (Map.Entry<String, Integer> entry : map.entrySet()) {
 296                 list.add(createEntry(entry.getKey(), (long)toWeekDay(entry.getValue())));
 297             }
 298             break;
 299         default:
 300             for (Map.Entry<String, Integer> entry : map.entrySet()) {
 301                 list.add(createEntry(entry.getKey(), (long)entry.getValue()));
 302             }
 303             break;
 304         }
 305         return list.iterator();
 306     }
 307 
 308     private Object findStore(TemporalField field, Locale locale) {
 309         Entry<TemporalField, Locale> key = createEntry(field, locale);
 310         Object store = CACHE.get(key);
 311         if (store == null) {
 312             store = createStore(field, locale);
 313             CACHE.putIfAbsent(key, store);
 314             store = CACHE.get(key);
 315         }
 316         return store;
 317     }
 318 
 319     private static int toWeekDay(int calWeekDay) {
 320         if (calWeekDay == Calendar.SUNDAY) {
 321             return 7;
 322         } else {
 323             return calWeekDay - 1;
 324         }
 325     }
 326 
 327     private Object createStore(TemporalField field, Locale locale) {
 328         Map<TextStyle, Map<Long, String>> styleMap = new HashMap<>();
 329         if (field == ERA) {
 330             for (TextStyle textStyle : TextStyle.values()) {
 331                 if (textStyle.isStandalone()) {
 332                     // Stand-alone isn't applicable to era names.
 333                     continue;
 334                 }
 335                 Map<String, Integer> displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames(
 336                         "gregory", Calendar.ERA, textStyle.toCalendarStyle(), locale);
 337                 if (displayNames != null) {
 338                     Map<Long, String> map = new HashMap<>();
 339                     for (Entry<String, Integer> entry : displayNames.entrySet()) {
 340                         map.put((long) entry.getValue(), entry.getKey());
 341                     }
 342                     if (!map.isEmpty()) {
 343                         styleMap.put(textStyle, map);
 344                     }
 345                 }
 346             }
 347             return new LocaleStore(styleMap);
 348         }
 349 
 350         if (field == MONTH_OF_YEAR) {
 351             for (TextStyle textStyle : TextStyle.values()) {
 352                 Map<Long, String> map = new HashMap<>();
 353                 // Narrow names may have duplicated names, such as "J" for January, June, July.
 354                 // Get names one by one in that case.
 355                 if ((textStyle.equals(TextStyle.NARROW) ||
 356                         textStyle.equals(TextStyle.NARROW_STANDALONE))) {
 357                     for (int month = Calendar.JANUARY; month <= Calendar.DECEMBER; month++) {
 358                         String name;
 359                         name = CalendarDataUtility.retrieveJavaTimeFieldValueName(
 360                                 "gregory", Calendar.MONTH,
 361                                 month, textStyle.toCalendarStyle(), locale);
 362                         if (name == null) {
 363                             break;
 364                         }
 365                         map.put((month + 1L), name);
 366                     }
 367                 } else {
 368                     Map<String, Integer> displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames(
 369                             "gregory", Calendar.MONTH, textStyle.toCalendarStyle(), locale);
 370                     if (displayNames != null) {
 371                         for (Entry<String, Integer> entry : displayNames.entrySet()) {
 372                             map.put((long)(entry.getValue() + 1), entry.getKey());
 373                         }
 374                     } else {
 375                         // Although probability is very less, but if other styles have duplicate names.
 376                         // Get names one by one in that case.
 377                         for (int month = Calendar.JANUARY; month <= Calendar.DECEMBER; month++) {
 378                             String name;
 379                             name = CalendarDataUtility.retrieveJavaTimeFieldValueName(
 380                                     "gregory", Calendar.MONTH, month, textStyle.toCalendarStyle(), locale);
 381                             if (name == null) {
 382                                 break;
 383                             }
 384                             map.put((month + 1L), name);
 385                         }
 386                     }
 387                 }
 388                 if (!map.isEmpty()) {
 389                     styleMap.put(textStyle, map);
 390                 }
 391             }
 392             return new LocaleStore(styleMap);
 393         }
 394 
 395         if (field == DAY_OF_WEEK) {
 396             for (TextStyle textStyle : TextStyle.values()) {
 397                 Map<Long, String> map = new HashMap<>();
 398                 // Narrow names may have duplicated names, such as "S" for Sunday and Saturday.
 399                 // Get names one by one in that case.
 400                 if ((textStyle.equals(TextStyle.NARROW) ||
 401                         textStyle.equals(TextStyle.NARROW_STANDALONE))) {
 402                     for (int wday = Calendar.SUNDAY; wday <= Calendar.SATURDAY; wday++) {
 403                         String name;
 404                         name = CalendarDataUtility.retrieveJavaTimeFieldValueName(
 405                                 "gregory", Calendar.DAY_OF_WEEK,
 406                                 wday, textStyle.toCalendarStyle(), locale);
 407                         if (name == null) {
 408                             break;
 409                         }
 410                         map.put((long)toWeekDay(wday), name);
 411                     }
 412                 } else {
 413                     Map<String, Integer> displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames(
 414                             "gregory", Calendar.DAY_OF_WEEK, textStyle.toCalendarStyle(), locale);
 415                     if (displayNames != null) {
 416                         for (Entry<String, Integer> entry : displayNames.entrySet()) {
 417                             map.put((long)toWeekDay(entry.getValue()), entry.getKey());
 418                         }
 419                     } else {
 420                         // Although probability is very less, but if other styles have duplicate names.
 421                         // Get names one by one in that case.
 422                         for (int wday = Calendar.SUNDAY; wday <= Calendar.SATURDAY; wday++) {
 423                             String name;
 424                             name = CalendarDataUtility.retrieveJavaTimeFieldValueName(
 425                                     "gregory", Calendar.DAY_OF_WEEK, wday, textStyle.toCalendarStyle(), locale);
 426                             if (name == null) {
 427                                 break;
 428                             }
 429                             map.put((long)toWeekDay(wday), name);
 430                         }
 431                     }
 432                 }
 433                 if (!map.isEmpty()) {
 434                     styleMap.put(textStyle, map);
 435                 }
 436             }
 437             return new LocaleStore(styleMap);
 438         }
 439 
 440         if (field == AMPM_OF_DAY) {
 441             for (TextStyle textStyle : TextStyle.values()) {
 442                 if (textStyle.isStandalone()) {
 443                     // Stand-alone isn't applicable to AM/PM.
 444                     continue;
 445                 }
 446                 Map<String, Integer> displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames(
 447                         "gregory", Calendar.AM_PM, textStyle.toCalendarStyle(), locale);
 448                 if (displayNames != null) {
 449                     Map<Long, String> map = new HashMap<>();
 450                     for (Entry<String, Integer> entry : displayNames.entrySet()) {
 451                         map.put((long) entry.getValue(), entry.getKey());
 452                     }
 453                     if (!map.isEmpty()) {
 454                         styleMap.put(textStyle, map);
 455                     }
 456                 }
 457             }
 458             return new LocaleStore(styleMap);
 459         }
 460 
 461         if (field == IsoFields.QUARTER_OF_YEAR) {
 462             // The order of keys must correspond to the TextStyle.values() order.
 463             final String[] keys = {
 464                 "QuarterNames",
 465                 "standalone.QuarterNames",
 466                 "QuarterAbbreviations",
 467                 "standalone.QuarterAbbreviations",
 468                 "QuarterNarrows",
 469                 "standalone.QuarterNarrows",
 470             };
 471             for (int i = 0; i < keys.length; i++) {
 472                 String[] names = getLocalizedResource(keys[i], locale);
 473                 if (names != null) {
 474                     Map<Long, String> map = new HashMap<>();
 475                     for (int q = 0; q < names.length; q++) {
 476                         map.put((long) (q + 1), names[q]);
 477                     }
 478                     styleMap.put(TextStyle.values()[i], map);
 479                 }
 480             }
 481             return new LocaleStore(styleMap);
 482         }
 483 
 484         return "";  // null marker for map
 485     }
 486 
 487     /**
 488      * Helper method to create an immutable entry.
 489      *
 490      * @param text  the text, not null
 491      * @param field  the field, not null
 492      * @return the entry, not null
 493      */
 494     private static <A, B> Entry<A, B> createEntry(A text, B field) {
 495         return new SimpleImmutableEntry<>(text, field);
 496     }
 497 
 498     /**
 499      * Returns the localized resource of the given key and locale, or null
 500      * if no localized resource is available.
 501      *
 502      * @param key  the key of the localized resource, not null
 503      * @param locale  the locale, not null
 504      * @return the localized resource, or null if not available
 505      * @throws NullPointerException if key or locale is null
 506      */
 507     @SuppressWarnings("unchecked")
 508     static <T> T getLocalizedResource(String key, Locale locale) {
 509         LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased()
 510                                     .getLocaleResources(locale);
 511         ResourceBundle rb = lr.getJavaTimeFormatData();
 512         return rb.containsKey(key) ? (T) rb.getObject(key) : null;
 513     }
 514 
 515     /**
 516      * Stores the text for a single locale.
 517      * <p>
 518      * Some fields have a textual representation, such as day-of-week or month-of-year.
 519      * These textual representations can be captured in this class for printing
 520      * and parsing.
 521      * <p>
 522      * This class is immutable and thread-safe.
 523      */
 524     static final class LocaleStore {
 525         /**
 526          * Map of value to text.
 527          */
 528         private final Map<TextStyle, Map<Long, String>> valueTextMap;
 529         /**
 530          * Parsable data.
 531          */
 532         private final Map<TextStyle, List<Entry<String, Long>>> parsable;
 533 
 534         /**
 535          * Constructor.
 536          *
 537          * @param valueTextMap  the map of values to text to store, assigned and not altered, not null
 538          */
 539         LocaleStore(Map<TextStyle, Map<Long, String>> valueTextMap) {
 540             this.valueTextMap = valueTextMap;
 541             Map<TextStyle, List<Entry<String, Long>>> map = new HashMap<>();
 542             List<Entry<String, Long>> allList = new ArrayList<>();
 543             for (Map.Entry<TextStyle, Map<Long, String>> vtmEntry : valueTextMap.entrySet()) {
 544                 Map<String, Entry<String, Long>> reverse = new HashMap<>();
 545                 for (Map.Entry<Long, String> entry : vtmEntry.getValue().entrySet()) {
 546                     if (reverse.put(entry.getValue(), createEntry(entry.getValue(), entry.getKey())) != null) {
 547                         // TODO: BUG: this has no effect
 548                         continue;  // not parsable, try next style
 549                     }
 550                 }
 551                 List<Entry<String, Long>> list = new ArrayList<>(reverse.values());
 552                 Collections.sort(list, COMPARATOR);
 553                 map.put(vtmEntry.getKey(), list);
 554                 allList.addAll(list);
 555                 map.put(null, allList);
 556             }
 557             Collections.sort(allList, COMPARATOR);
 558             this.parsable = map;
 559         }
 560 
 561         /**
 562          * Gets the text for the specified field value, locale and style
 563          * for the purpose of printing.
 564          *
 565          * @param value  the value to get text for, not null
 566          * @param style  the style to get text for, not null
 567          * @return the text for the field value, null if no text found
 568          */
 569         String getText(long value, TextStyle style) {
 570             Map<Long, String> map = valueTextMap.get(style);
 571             return map != null ? map.get(value) : null;
 572         }
 573 
 574         /**
 575          * Gets an iterator of text to field for the specified style for the purpose of parsing.
 576          * <p>
 577          * The iterator must be returned in order from the longest text to the shortest.
 578          *
 579          * @param style  the style to get text for, null for all parsable text
 580          * @return the iterator of text to field pairs, in order from longest text to shortest text,
 581          *  null if the style is not parsable
 582          */
 583         Iterator<Entry<String, Long>> getTextIterator(TextStyle style) {
 584             List<Entry<String, Long>> list = parsable.get(style);
 585             return list != null ? list.iterator() : null;
 586         }
 587     }
 588 }