< prev index next >

src/java.base/share/classes/java/text/DateFormatSymbols.java

Print this page
rev 56290 : 8230648: Replace @exception tag with @throws in java.base
Summary: Minor coding style update of javadoc tag in any file in java.base
Reviewed-by: prappo, lancea


 105  * @author       Chen-Lieh Huang
 106  * @since 1.1
 107  */
 108 public class DateFormatSymbols implements Serializable, Cloneable {
 109 
 110     /**
 111      * Construct a DateFormatSymbols object by loading format data from
 112      * resources for the default {@link java.util.Locale.Category#FORMAT FORMAT}
 113      * locale. This constructor can only
 114      * construct instances for the locales supported by the Java
 115      * runtime environment, not for those supported by installed
 116      * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
 117      * implementations. For full locale coverage, use the
 118      * {@link #getInstance(Locale) getInstance} method.
 119      * <p>This is equivalent to calling
 120      * {@link #DateFormatSymbols(Locale)
 121      *     DateFormatSymbols(Locale.getDefault(Locale.Category.FORMAT))}.
 122      * @see #getInstance()
 123      * @see java.util.Locale#getDefault(java.util.Locale.Category)
 124      * @see java.util.Locale.Category#FORMAT
 125      * @exception  java.util.MissingResourceException
 126      *             if the resources for the default locale cannot be
 127      *             found or cannot be loaded.
 128      */
 129     public DateFormatSymbols()
 130     {
 131         initializeData(Locale.getDefault(Locale.Category.FORMAT));
 132     }
 133 
 134     /**
 135      * Construct a DateFormatSymbols object by loading format data from
 136      * resources for the given locale. This constructor can only
 137      * construct instances for the locales supported by the Java
 138      * runtime environment, not for those supported by installed
 139      * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
 140      * implementations. For full locale coverage, use the
 141      * {@link #getInstance(Locale) getInstance} method.
 142      *
 143      * @param locale the desired locale
 144      * @see #getInstance(Locale)
 145      * @exception  java.util.MissingResourceException
 146      *             if the resources for the specified locale cannot be
 147      *             found or cannot be loaded.
 148      */
 149     public DateFormatSymbols(Locale locale)
 150     {
 151         initializeData(locale);
 152     }
 153 
 154     /**
 155      * Constructs an uninitialized DateFormatSymbols.
 156      */
 157     private DateFormatSymbols(boolean flag) {
 158     }
 159 
 160     /**
 161      * Era strings. For example: "AD" and "BC".  An array of 2 strings,
 162      * indexed by <code>Calendar.BC</code> and <code>Calendar.AD</code>.
 163      * @serial
 164      */
 165     String eras[] = null;


 323      * <p>This is equivalent to calling {@link #getInstance(Locale)
 324      *     getInstance(Locale.getDefault(Locale.Category.FORMAT))}.
 325      * @see java.util.Locale#getDefault(java.util.Locale.Category)
 326      * @see java.util.Locale.Category#FORMAT
 327      * @return a <code>DateFormatSymbols</code> instance.
 328      * @since 1.6
 329      */
 330     public static final DateFormatSymbols getInstance() {
 331         return getInstance(Locale.getDefault(Locale.Category.FORMAT));
 332     }
 333 
 334     /**
 335      * Gets the <code>DateFormatSymbols</code> instance for the specified
 336      * locale.  This method provides access to <code>DateFormatSymbols</code>
 337      * instances for locales supported by the Java runtime itself as well
 338      * as for those supported by installed
 339      * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
 340      * implementations.
 341      * @param locale the given locale.
 342      * @return a <code>DateFormatSymbols</code> instance.
 343      * @exception NullPointerException if <code>locale</code> is null
 344      * @since 1.6
 345      */
 346     public static final DateFormatSymbols getInstance(Locale locale) {
 347         DateFormatSymbols dfs = getProviderInstance(locale);
 348         if (dfs != null) {
 349             return dfs;
 350         }
 351         throw new RuntimeException("DateFormatSymbols instance creation failed.");
 352     }
 353 
 354     /**
 355      * Returns a DateFormatSymbols provided by a provider or found in
 356      * the cache. Note that this method returns a cached instance,
 357      * not its clone. Therefore, the instance should never be given to
 358      * an application.
 359      */
 360     static final DateFormatSymbols getInstanceRef(Locale locale) {
 361         DateFormatSymbols dfs = getProviderInstance(locale);
 362         if (dfs != null) {
 363             return dfs;


 579      * entry containing the localized names for a single <code>TimeZone</code>.
 580      * Each such row contains (with <code>i</code> ranging from
 581      * 0..<em>n</em>-1):
 582      * <ul>
 583      * <li><code>zoneStrings[i][0]</code> - time zone ID</li>
 584      * <li><code>zoneStrings[i][1]</code> - long name of zone in standard
 585      * time</li>
 586      * <li><code>zoneStrings[i][2]</code> - short name of zone in
 587      * standard time</li>
 588      * <li><code>zoneStrings[i][3]</code> - long name of zone in daylight
 589      * saving time</li>
 590      * <li><code>zoneStrings[i][4]</code> - short name of zone in daylight
 591      * saving time</li>
 592      * </ul>
 593      * The zone ID is <em>not</em> localized; it's one of the valid IDs of
 594      * the {@link java.util.TimeZone TimeZone} class that are not
 595      * <a href="../util/TimeZone.html#CustomID">custom IDs</a>.
 596      * All other entries are localized names.
 597      *
 598      * @param newZoneStrings the new time zone strings.
 599      * @exception IllegalArgumentException if the length of any row in
 600      *    <code>newZoneStrings</code> is less than 5
 601      * @exception NullPointerException if <code>newZoneStrings</code> is null
 602      * @see #getZoneStrings()
 603      */
 604     public void setZoneStrings(String[][] newZoneStrings) {
 605         String[][] aCopy = new String[newZoneStrings.length][];
 606         for (int i = 0; i < newZoneStrings.length; ++i) {
 607             int len = newZoneStrings[i].length;
 608             if (len < 5) {
 609                 throw new IllegalArgumentException();
 610             }
 611             aCopy[i] = Arrays.copyOf(newZoneStrings[i], len);
 612         }
 613         zoneStrings = aCopy;
 614         isZoneStringsSet = true;
 615         cachedHashCode = 0;
 616     }
 617 
 618     /**
 619      * Gets localized date-time pattern characters. For example: 'u', 't', etc.
 620      * @return the localized date-time pattern characters.
 621      */




 105  * @author       Chen-Lieh Huang
 106  * @since 1.1
 107  */
 108 public class DateFormatSymbols implements Serializable, Cloneable {
 109 
 110     /**
 111      * Construct a DateFormatSymbols object by loading format data from
 112      * resources for the default {@link java.util.Locale.Category#FORMAT FORMAT}
 113      * locale. This constructor can only
 114      * construct instances for the locales supported by the Java
 115      * runtime environment, not for those supported by installed
 116      * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
 117      * implementations. For full locale coverage, use the
 118      * {@link #getInstance(Locale) getInstance} method.
 119      * <p>This is equivalent to calling
 120      * {@link #DateFormatSymbols(Locale)
 121      *     DateFormatSymbols(Locale.getDefault(Locale.Category.FORMAT))}.
 122      * @see #getInstance()
 123      * @see java.util.Locale#getDefault(java.util.Locale.Category)
 124      * @see java.util.Locale.Category#FORMAT
 125      * @throws     java.util.MissingResourceException
 126      *             if the resources for the default locale cannot be
 127      *             found or cannot be loaded.
 128      */
 129     public DateFormatSymbols()
 130     {
 131         initializeData(Locale.getDefault(Locale.Category.FORMAT));
 132     }
 133 
 134     /**
 135      * Construct a DateFormatSymbols object by loading format data from
 136      * resources for the given locale. This constructor can only
 137      * construct instances for the locales supported by the Java
 138      * runtime environment, not for those supported by installed
 139      * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
 140      * implementations. For full locale coverage, use the
 141      * {@link #getInstance(Locale) getInstance} method.
 142      *
 143      * @param locale the desired locale
 144      * @see #getInstance(Locale)
 145      * @throws     java.util.MissingResourceException
 146      *             if the resources for the specified locale cannot be
 147      *             found or cannot be loaded.
 148      */
 149     public DateFormatSymbols(Locale locale)
 150     {
 151         initializeData(locale);
 152     }
 153 
 154     /**
 155      * Constructs an uninitialized DateFormatSymbols.
 156      */
 157     private DateFormatSymbols(boolean flag) {
 158     }
 159 
 160     /**
 161      * Era strings. For example: "AD" and "BC".  An array of 2 strings,
 162      * indexed by <code>Calendar.BC</code> and <code>Calendar.AD</code>.
 163      * @serial
 164      */
 165     String eras[] = null;


 323      * <p>This is equivalent to calling {@link #getInstance(Locale)
 324      *     getInstance(Locale.getDefault(Locale.Category.FORMAT))}.
 325      * @see java.util.Locale#getDefault(java.util.Locale.Category)
 326      * @see java.util.Locale.Category#FORMAT
 327      * @return a <code>DateFormatSymbols</code> instance.
 328      * @since 1.6
 329      */
 330     public static final DateFormatSymbols getInstance() {
 331         return getInstance(Locale.getDefault(Locale.Category.FORMAT));
 332     }
 333 
 334     /**
 335      * Gets the <code>DateFormatSymbols</code> instance for the specified
 336      * locale.  This method provides access to <code>DateFormatSymbols</code>
 337      * instances for locales supported by the Java runtime itself as well
 338      * as for those supported by installed
 339      * {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
 340      * implementations.
 341      * @param locale the given locale.
 342      * @return a <code>DateFormatSymbols</code> instance.
 343      * @throws    NullPointerException if <code>locale</code> is null
 344      * @since 1.6
 345      */
 346     public static final DateFormatSymbols getInstance(Locale locale) {
 347         DateFormatSymbols dfs = getProviderInstance(locale);
 348         if (dfs != null) {
 349             return dfs;
 350         }
 351         throw new RuntimeException("DateFormatSymbols instance creation failed.");
 352     }
 353 
 354     /**
 355      * Returns a DateFormatSymbols provided by a provider or found in
 356      * the cache. Note that this method returns a cached instance,
 357      * not its clone. Therefore, the instance should never be given to
 358      * an application.
 359      */
 360     static final DateFormatSymbols getInstanceRef(Locale locale) {
 361         DateFormatSymbols dfs = getProviderInstance(locale);
 362         if (dfs != null) {
 363             return dfs;


 579      * entry containing the localized names for a single <code>TimeZone</code>.
 580      * Each such row contains (with <code>i</code> ranging from
 581      * 0..<em>n</em>-1):
 582      * <ul>
 583      * <li><code>zoneStrings[i][0]</code> - time zone ID</li>
 584      * <li><code>zoneStrings[i][1]</code> - long name of zone in standard
 585      * time</li>
 586      * <li><code>zoneStrings[i][2]</code> - short name of zone in
 587      * standard time</li>
 588      * <li><code>zoneStrings[i][3]</code> - long name of zone in daylight
 589      * saving time</li>
 590      * <li><code>zoneStrings[i][4]</code> - short name of zone in daylight
 591      * saving time</li>
 592      * </ul>
 593      * The zone ID is <em>not</em> localized; it's one of the valid IDs of
 594      * the {@link java.util.TimeZone TimeZone} class that are not
 595      * <a href="../util/TimeZone.html#CustomID">custom IDs</a>.
 596      * All other entries are localized names.
 597      *
 598      * @param newZoneStrings the new time zone strings.
 599      * @throws    IllegalArgumentException if the length of any row in
 600      *    <code>newZoneStrings</code> is less than 5
 601      * @throws    NullPointerException if <code>newZoneStrings</code> is null
 602      * @see #getZoneStrings()
 603      */
 604     public void setZoneStrings(String[][] newZoneStrings) {
 605         String[][] aCopy = new String[newZoneStrings.length][];
 606         for (int i = 0; i < newZoneStrings.length; ++i) {
 607             int len = newZoneStrings[i].length;
 608             if (len < 5) {
 609                 throw new IllegalArgumentException();
 610             }
 611             aCopy[i] = Arrays.copyOf(newZoneStrings[i], len);
 612         }
 613         zoneStrings = aCopy;
 614         isZoneStringsSet = true;
 615         cachedHashCode = 0;
 616     }
 617 
 618     /**
 619      * Gets localized date-time pattern characters. For example: 'u', 't', etc.
 620      * @return the localized date-time pattern characters.
 621      */


< prev index next >