< prev index next >

make/src/classes/build/tools/tzdb/ZoneRulesBuilder.java

Print this page




 474                 boolean timeEndOfDay,
 475                 TimeDefinition timeDefinition,
 476                 int savingAmountSecs) {
 477 
 478             if (fixedSavingAmountSecs != null) {
 479                 throw new IllegalStateException("Window has a fixed DST saving, so cannot have DST rules");
 480             }
 481             if (ruleList.size() >= 2000) {
 482                 throw new IllegalStateException("Window has reached the maximum number of allowed rules");
 483             }
 484             boolean lastRule = false;
 485             if (endYear == YEAR_MAX_VALUE) {
 486                 lastRule = true;
 487                 endYear = startYear;
 488             }
 489             int year = startYear;
 490             while (year <= endYear) {
 491                 TZRule rule = new TZRule(year, month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay, timeDefinition, savingAmountSecs);
 492                 if (lastRule) {
 493                     lastRuleList.add(rule);
 494                     maxLastRuleStartYear = Math.max(startYear, maxLastRuleStartYear);
 495                 } else {
 496                     ruleList.add(rule);
 497                 }

 498                 year++;
 499             }
 500         }
 501 
 502         /**
 503          * Validates that this window is after the previous one.
 504          *
 505          * @param previous  the previous window, not null
 506          * @throws IllegalStateException if the window order is invalid
 507          */
 508         void validateWindowOrder(TZWindow previous) {
 509             if (windowEnd.compareTo(previous.windowEnd) < 0) {
 510                 throw new IllegalStateException("Windows must be added in date-time order: " +
 511                         windowEnd + " < " + previous.windowEnd);
 512             }
 513         }
 514 
 515         /**
 516          * Adds rules to make the last rules all start from the same year.
 517          * Also add one more year to avoid weird case where penultimate year has odd offset.




 474                 boolean timeEndOfDay,
 475                 TimeDefinition timeDefinition,
 476                 int savingAmountSecs) {
 477 
 478             if (fixedSavingAmountSecs != null) {
 479                 throw new IllegalStateException("Window has a fixed DST saving, so cannot have DST rules");
 480             }
 481             if (ruleList.size() >= 2000) {
 482                 throw new IllegalStateException("Window has reached the maximum number of allowed rules");
 483             }
 484             boolean lastRule = false;
 485             if (endYear == YEAR_MAX_VALUE) {
 486                 lastRule = true;
 487                 endYear = startYear;
 488             }
 489             int year = startYear;
 490             while (year <= endYear) {
 491                 TZRule rule = new TZRule(year, month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay, timeDefinition, savingAmountSecs);
 492                 if (lastRule) {
 493                     lastRuleList.add(rule);

 494                 } else {
 495                     ruleList.add(rule);
 496                 }
 497                 maxLastRuleStartYear = Math.max(startYear, maxLastRuleStartYear);
 498                 year++;
 499             }
 500         }
 501 
 502         /**
 503          * Validates that this window is after the previous one.
 504          *
 505          * @param previous  the previous window, not null
 506          * @throws IllegalStateException if the window order is invalid
 507          */
 508         void validateWindowOrder(TZWindow previous) {
 509             if (windowEnd.compareTo(previous.windowEnd) < 0) {
 510                 throw new IllegalStateException("Windows must be added in date-time order: " +
 511                         windowEnd + " < " + previous.windowEnd);
 512             }
 513         }
 514 
 515         /**
 516          * Adds rules to make the last rules all start from the same year.
 517          * Also add one more year to avoid weird case where penultimate year has odd offset.


< prev index next >