/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* {@code CalendarBuilder} keeps field-value pairs for setting
* the calendar fields of the given {@code Calendar}. It has the
* {@link Calendar#FIELD_COUNT FIELD_COUNT}-th field for the week year
* support. Also {@code ISO_DAY_OF_WEEK} is used to specify
* {@code DAY_OF_WEEK} in the ISO day of week numbering.
*
* <p>{@code CalendarBuilder} retains the semantic of the pseudo
* timestamp for fields. {@code CalendarBuilder} uses a single
* int array combining fields[] and stamp[] of {@code Calendar}.
*
* @author Masayoshi Okutsu
*/
class CalendarBuilder {
/*
* Pseudo time stamp constants used in java.util.Calendar
*/
// stamp[] (lower half) and field[] (upper half) combined
private final int[] field;
private int nextStamp;
private int maxFieldIndex;
CalendarBuilder() {
maxFieldIndex = -1;
}
if (index == ISO_DAY_OF_WEEK) {
index = DAY_OF_WEEK;
}
}
return this;
}
return this;
}
if (index == ISO_DAY_OF_WEEK) {
index = DAY_OF_WEEK;
}
}
if (index == ISO_DAY_OF_WEEK) {
index = DAY_OF_WEEK;
}
return this;
}
// Use YEAR instead
}
weekDate = false;
}
// Set the fields from the min stamp to the max stamp so that
// the field resolution works in the Calendar.
break;
}
}
}
if (weekDate) {
if (dayOfWeek >= 8) {
dayOfWeek--;
} else {
while (dayOfWeek <= 0) {
dayOfWeek += 7;
weekOfYear--;
}
}
}
}
return cal;
}
if (isSet(i)) {
}
}
}
}
}
if (!isValidDayOfWeek(isoDayOfWeek)) {
// adjust later for lenient mode
return isoDayOfWeek;
}
}
}
}