< prev index next >

src/java.base/share/classes/java/util/JapaneseImperialCalendar.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


 401      *
 402      * <p><em>Add rule 1</em>. The value of {@code field}
 403      * after the call minus the value of {@code field} before the
 404      * call is {@code amount}, modulo any overflow that has occurred in
 405      * {@code field}. Overflow occurs when a field value exceeds its
 406      * range and, as a result, the next larger field is incremented or
 407      * decremented and the field value is adjusted back into its range.</p>
 408      *
 409      * <p><em>Add rule 2</em>. If a smaller field is expected to be
 410      * invariant, but it is impossible for it to be equal to its
 411      * prior value because of changes in its minimum or maximum after
 412      * {@code field} is changed, then its value is adjusted to be as close
 413      * as possible to its expected value. A smaller field represents a
 414      * smaller unit of time. {@code HOUR} is a smaller field than
 415      * {@code DAY_OF_MONTH}. No adjustment is made to smaller fields
 416      * that are not expected to be invariant. The calendar system
 417      * determines what fields are expected to be invariant.</p>
 418      *
 419      * @param field the calendar field.
 420      * @param amount the amount of date or time to be added to the field.
 421      * @exception IllegalArgumentException if {@code field} is
 422      * {@code ZONE_OFFSET}, {@code DST_OFFSET}, or unknown,
 423      * or if any calendar fields have out-of-range values in
 424      * non-lenient mode.
 425      */
 426     @Override
 427     public void add(int field, int amount) {
 428         // If amount == 0, do nothing even the given field is out of
 429         // range. This is tested by JCK.
 430         if (amount == 0) {
 431             return;   // Do nothing!
 432         }
 433 
 434         if (field < 0 || field >= ZONE_OFFSET) {
 435             throw new IllegalArgumentException();
 436         }
 437 
 438         // Sync the time and calendar fields.
 439         complete();
 440 
 441         if (field == YEAR) {


 552         }
 553     }
 554 
 555     @Override
 556     public void roll(int field, boolean up) {
 557         roll(field, up ? +1 : -1);
 558     }
 559 
 560     /**
 561      * Adds a signed amount to the specified calendar field without changing larger fields.
 562      * A negative roll amount means to subtract from field without changing
 563      * larger fields. If the specified amount is 0, this method performs nothing.
 564      *
 565      * <p>This method calls {@link #complete()} before adding the
 566      * amount so that all the calendar fields are normalized. If there
 567      * is any calendar field having an out-of-range value in non-lenient mode, then an
 568      * {@code IllegalArgumentException} is thrown.
 569      *
 570      * @param field the calendar field.
 571      * @param amount the signed amount to add to {@code field}.
 572      * @exception IllegalArgumentException if {@code field} is
 573      * {@code ZONE_OFFSET}, {@code DST_OFFSET}, or unknown,
 574      * or if any calendar fields have out-of-range values in
 575      * non-lenient mode.
 576      * @see #roll(int,boolean)
 577      * @see #add(int,int)
 578      * @see #set(int,int)
 579      */
 580     @Override
 581     public void roll(int field, int amount) {
 582         // If amount == 0, do nothing even the given field is out of
 583         // range. This is tested by JCK.
 584         if (amount == 0) {
 585             return;
 586         }
 587 
 588         if (field < 0 || field >= ZONE_OFFSET) {
 589             throw new IllegalArgumentException();
 590         }
 591 
 592         // Sync the time and calendar fields.


1850         // We can always use `jcal' since Julian and Gregorian are the
1851         // same thing for this calculation.
1852         long fixedDay1st = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(fixedDay1 + 6,
1853                                                                              getFirstDayOfWeek());
1854         int ndays = (int)(fixedDay1st - fixedDay1);
1855         assert ndays <= 7;
1856         if (ndays >= getMinimalDaysInFirstWeek()) {
1857             fixedDay1st -= 7;
1858         }
1859         int normalizedDayOfPeriod = (int)(fixedDate - fixedDay1st);
1860         if (normalizedDayOfPeriod >= 0) {
1861             return normalizedDayOfPeriod / 7 + 1;
1862         }
1863         return CalendarUtils.floorDivide(normalizedDayOfPeriod, 7) + 1;
1864     }
1865 
1866     /**
1867      * Converts calendar field values to the time value (millisecond
1868      * offset from the <a href="Calendar.html#Epoch">Epoch</a>).
1869      *
1870      * @exception IllegalArgumentException if any calendar fields are invalid.
1871      */
1872     protected void computeTime() {
1873         // In non-lenient mode, perform brief checking of calendar
1874         // fields which have been set externally. Through this
1875         // checking, the field values are stored in originalFields[]
1876         // to see if any of them are normalized later.
1877         if (!isLenient()) {
1878             if (originalFields == null) {
1879                 originalFields = new int[FIELD_COUNT];
1880             }
1881             for (int field = 0; field < FIELD_COUNT; field++) {
1882                 int value = internalGet(field);
1883                 if (isExternallySet(field)) {
1884                     // Quick validation for any out of range values
1885                     if (value < getMinimum(field) || value > getMaximum(field)) {
1886                         throw new IllegalArgumentException(getFieldName(field));
1887                     }
1888                 }
1889                 originalFields[field] = value;
1890             }




 401      *
 402      * <p><em>Add rule 1</em>. The value of {@code field}
 403      * after the call minus the value of {@code field} before the
 404      * call is {@code amount}, modulo any overflow that has occurred in
 405      * {@code field}. Overflow occurs when a field value exceeds its
 406      * range and, as a result, the next larger field is incremented or
 407      * decremented and the field value is adjusted back into its range.</p>
 408      *
 409      * <p><em>Add rule 2</em>. If a smaller field is expected to be
 410      * invariant, but it is impossible for it to be equal to its
 411      * prior value because of changes in its minimum or maximum after
 412      * {@code field} is changed, then its value is adjusted to be as close
 413      * as possible to its expected value. A smaller field represents a
 414      * smaller unit of time. {@code HOUR} is a smaller field than
 415      * {@code DAY_OF_MONTH}. No adjustment is made to smaller fields
 416      * that are not expected to be invariant. The calendar system
 417      * determines what fields are expected to be invariant.</p>
 418      *
 419      * @param field the calendar field.
 420      * @param amount the amount of date or time to be added to the field.
 421      * @throws    IllegalArgumentException if {@code field} is
 422      * {@code ZONE_OFFSET}, {@code DST_OFFSET}, or unknown,
 423      * or if any calendar fields have out-of-range values in
 424      * non-lenient mode.
 425      */
 426     @Override
 427     public void add(int field, int amount) {
 428         // If amount == 0, do nothing even the given field is out of
 429         // range. This is tested by JCK.
 430         if (amount == 0) {
 431             return;   // Do nothing!
 432         }
 433 
 434         if (field < 0 || field >= ZONE_OFFSET) {
 435             throw new IllegalArgumentException();
 436         }
 437 
 438         // Sync the time and calendar fields.
 439         complete();
 440 
 441         if (field == YEAR) {


 552         }
 553     }
 554 
 555     @Override
 556     public void roll(int field, boolean up) {
 557         roll(field, up ? +1 : -1);
 558     }
 559 
 560     /**
 561      * Adds a signed amount to the specified calendar field without changing larger fields.
 562      * A negative roll amount means to subtract from field without changing
 563      * larger fields. If the specified amount is 0, this method performs nothing.
 564      *
 565      * <p>This method calls {@link #complete()} before adding the
 566      * amount so that all the calendar fields are normalized. If there
 567      * is any calendar field having an out-of-range value in non-lenient mode, then an
 568      * {@code IllegalArgumentException} is thrown.
 569      *
 570      * @param field the calendar field.
 571      * @param amount the signed amount to add to {@code field}.
 572      * @throws    IllegalArgumentException if {@code field} is
 573      * {@code ZONE_OFFSET}, {@code DST_OFFSET}, or unknown,
 574      * or if any calendar fields have out-of-range values in
 575      * non-lenient mode.
 576      * @see #roll(int,boolean)
 577      * @see #add(int,int)
 578      * @see #set(int,int)
 579      */
 580     @Override
 581     public void roll(int field, int amount) {
 582         // If amount == 0, do nothing even the given field is out of
 583         // range. This is tested by JCK.
 584         if (amount == 0) {
 585             return;
 586         }
 587 
 588         if (field < 0 || field >= ZONE_OFFSET) {
 589             throw new IllegalArgumentException();
 590         }
 591 
 592         // Sync the time and calendar fields.


1850         // We can always use `jcal' since Julian and Gregorian are the
1851         // same thing for this calculation.
1852         long fixedDay1st = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(fixedDay1 + 6,
1853                                                                              getFirstDayOfWeek());
1854         int ndays = (int)(fixedDay1st - fixedDay1);
1855         assert ndays <= 7;
1856         if (ndays >= getMinimalDaysInFirstWeek()) {
1857             fixedDay1st -= 7;
1858         }
1859         int normalizedDayOfPeriod = (int)(fixedDate - fixedDay1st);
1860         if (normalizedDayOfPeriod >= 0) {
1861             return normalizedDayOfPeriod / 7 + 1;
1862         }
1863         return CalendarUtils.floorDivide(normalizedDayOfPeriod, 7) + 1;
1864     }
1865 
1866     /**
1867      * Converts calendar field values to the time value (millisecond
1868      * offset from the <a href="Calendar.html#Epoch">Epoch</a>).
1869      *
1870      * @throws    IllegalArgumentException if any calendar fields are invalid.
1871      */
1872     protected void computeTime() {
1873         // In non-lenient mode, perform brief checking of calendar
1874         // fields which have been set externally. Through this
1875         // checking, the field values are stored in originalFields[]
1876         // to see if any of them are normalized later.
1877         if (!isLenient()) {
1878             if (originalFields == null) {
1879                 originalFields = new int[FIELD_COUNT];
1880             }
1881             for (int field = 0; field < FIELD_COUNT; field++) {
1882                 int value = internalGet(field);
1883                 if (isExternallySet(field)) {
1884                     // Quick validation for any out of range values
1885                     if (value < getMinimum(field) || value > getMaximum(field)) {
1886                         throw new IllegalArgumentException(getFieldName(field));
1887                     }
1888                 }
1889                 originalFields[field] = value;
1890             }


< prev index next >