rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
return null;
float[] wp = new float[3]; wp[0] = whitePoint[0]; wp[1] = whitePoint[1]; wp[2] = whitePoint[2]; return wp;
public float[] getMediaWhitePoint() { return null; }
return null;
short[] data = getCurve(icSigGrayTRCTag); if (data == null) throw new IllegalArgumentException("Couldn't read Gray TRC data."); if (data.length <= 1) throw new ProfileDataException("Gamma value, not a TRC table."); return data;
public short[] getTRC() { return null; }
this.profileID = profileID;
header = null; tagTable = null; createProfile(profileID);
ICC_Profile(int profileID) { this.profileID = profileID; }
super(toolkit, checkBox, new JCheckBox()); this.checkBox = checkBox; final JCheckBox jcb = (JCheckBox)jComponent;
super(toolkit, checkBox, new SwingCheckBox(checkBox)); final JCheckBox jcb = (JCheckBox) jComponent;
public SwingCheckboxPeer(SwingToolkit toolkit, Checkbox checkBox) { super(toolkit, checkBox, new JCheckBox()); this.checkBox = checkBox; final JCheckBox jcb = (JCheckBox)jComponent; SwingToolkit.add(checkBox, jcb); SwingToolkit.copyAwtProperties(checkBox, jcb); jcb.setText(checkBox.getLabel()); setState(checkBox.getState()); }
g.setClip(portBounds);
g.setClip(new Rectangle(0, 0, portBounds.width, portBounds.height));
private void paintSimple(Graphics g, JViewport v, Component view, Point pos, Rectangle viewBounds, Rectangle portBounds) { Rectangle oldClip = g.getClipBounds(); g.setClip(portBounds); g.translate (-pos.x, -pos.y); try { view.paint(g); } finally { g.translate (pos.x, pos.y); g.setClip (oldClip); } }
if (pixel < map_size)
if (pixel >= 0 && pixel < map_size)
public final int getRGB (int pixel) { if (pixel < map_size) return rgb[pixel]; return 0; }
Address sf = VmMagic.getCurrentFrame();
final VmStackFrameEnumerator sfEnum = new VmStackFrameEnumerator(reader);
public static void checkPermission(Permission perm) throws AccessControlException { if (!Unsafe.getCurrentProcessor().isThreadSwitchActive()) { // getContext().checkPermission(perm); // This is an optimized version of // getContext().checkPermission() // that does not require any memory allocations. final VmStackReader reader = Unsafe.getCurrentProcessor() .getArchitecture().getStackReader(); Address sf = VmMagic.getCurrentFrame(); int recursionCount = 0; while (reader.isValid(sf)) { final VmMethod method = reader.getMethod(sf); if (method.hasDoPrivilegedPragma()) { // Stop here with the current thread's stacktrace. break; } else if (method.hasCheckPermissionPragma()) { // Be paranoia for now, let's check for recursive // checkPermission calls. recursionCount++; if (recursionCount > 2) { reader.debugStackTrace(); Unsafe.die("Recursive checkPermission"); } } else { final VmType<?> declClass = method.getDeclaringClass(); final ProtectionDomain pd = declClass.getProtectionDomain(); if (pd != null) { // Unsafe.debug(":pd"); if (!pd.implies(perm)) { // Unsafe.debug("Permission denied"); throw new AccessControlException("Permission \"" + perm + "\" not granted due to " + declClass.getName()); } } } if (method.hasPrivilegedActionPragma()) { // Break here, do not include inherited thread context return; } sf = reader.getPrevious(sf); } final VmThread thread = VmThread.currentThread(); final VmAccessControlContext inheritedCtx = thread.getContext(); if (inheritedCtx != null) { inheritedCtx.checkPermission(perm); } } }
while (reader.isValid(sf)) { final VmMethod method = reader.getMethod(sf);
while (sfEnum.isValid()) { final VmMethod method = sfEnum.getMethod();
public static void checkPermission(Permission perm) throws AccessControlException { if (!Unsafe.getCurrentProcessor().isThreadSwitchActive()) { // getContext().checkPermission(perm); // This is an optimized version of // getContext().checkPermission() // that does not require any memory allocations. final VmStackReader reader = Unsafe.getCurrentProcessor() .getArchitecture().getStackReader(); Address sf = VmMagic.getCurrentFrame(); int recursionCount = 0; while (reader.isValid(sf)) { final VmMethod method = reader.getMethod(sf); if (method.hasDoPrivilegedPragma()) { // Stop here with the current thread's stacktrace. break; } else if (method.hasCheckPermissionPragma()) { // Be paranoia for now, let's check for recursive // checkPermission calls. recursionCount++; if (recursionCount > 2) { reader.debugStackTrace(); Unsafe.die("Recursive checkPermission"); } } else { final VmType<?> declClass = method.getDeclaringClass(); final ProtectionDomain pd = declClass.getProtectionDomain(); if (pd != null) { // Unsafe.debug(":pd"); if (!pd.implies(perm)) { // Unsafe.debug("Permission denied"); throw new AccessControlException("Permission \"" + perm + "\" not granted due to " + declClass.getName()); } } } if (method.hasPrivilegedActionPragma()) { // Break here, do not include inherited thread context return; } sf = reader.getPrevious(sf); } final VmThread thread = VmThread.currentThread(); final VmAccessControlContext inheritedCtx = thread.getContext(); if (inheritedCtx != null) { inheritedCtx.checkPermission(perm); } } }
sf = reader.getPrevious(sf);
sfEnum.next();
public static void checkPermission(Permission perm) throws AccessControlException { if (!Unsafe.getCurrentProcessor().isThreadSwitchActive()) { // getContext().checkPermission(perm); // This is an optimized version of // getContext().checkPermission() // that does not require any memory allocations. final VmStackReader reader = Unsafe.getCurrentProcessor() .getArchitecture().getStackReader(); Address sf = VmMagic.getCurrentFrame(); int recursionCount = 0; while (reader.isValid(sf)) { final VmMethod method = reader.getMethod(sf); if (method.hasDoPrivilegedPragma()) { // Stop here with the current thread's stacktrace. break; } else if (method.hasCheckPermissionPragma()) { // Be paranoia for now, let's check for recursive // checkPermission calls. recursionCount++; if (recursionCount > 2) { reader.debugStackTrace(); Unsafe.die("Recursive checkPermission"); } } else { final VmType<?> declClass = method.getDeclaringClass(); final ProtectionDomain pd = declClass.getProtectionDomain(); if (pd != null) { // Unsafe.debug(":pd"); if (!pd.implies(perm)) { // Unsafe.debug("Permission denied"); throw new AccessControlException("Permission \"" + perm + "\" not granted due to " + declClass.getName()); } } } if (method.hasPrivilegedActionPragma()) { // Break here, do not include inherited thread context return; } sf = reader.getPrevious(sf); } final VmThread thread = VmThread.currentThread(); final VmAccessControlContext inheritedCtx = thread.getContext(); if (inheritedCtx != null) { inheritedCtx.checkPermission(perm); } } }
public final void pop(int type) {
public final int pop() {
public final void pop(int type) { if (tos <= 0) { throw new Error("Stack is empty"); } if (stack[ --tos] != type) { throw new Error("TypeStack[" + tos + "] is not the expected element " + type + " but " + stack[ tos]); } }
if (stack[ --tos] != type) { throw new Error("TypeStack[" + tos + "] is not the expected element " + type + " but " + stack[ tos]); }
return stack[ --tos];
public final void pop(int type) { if (tos <= 0) { throw new Error("Stack is empty"); } if (stack[ --tos] != type) { throw new Error("TypeStack[" + tos + "] is not the expected element " + type + " but " + stack[ tos]); } }
? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1) : ((day - 100) * 4) / (365 * 4 + 1));
? ((day - 100L) * 400L) / (365L * 400L + 100L - 4L + 1L) : ((day - 100L) * 4L) / (365L * 4L + 1L));
private void calculateDay(int[] fields, long day, boolean gregorian) { // the epoch is a Thursday. int weekday = (int) (day + THURSDAY) % 7; if (weekday <= 0) weekday += 7; fields[DAY_OF_WEEK] = weekday; // get a first approximation of the year. This may be one // year too big. int year = 1970 + (int) (gregorian ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1) : ((day - 100) * 4) / (365 * 4 + 1)); if (day >= 0) year++; long firstDayOfYear = getLinearDay(year, 1, gregorian); // Now look in which year day really lies. if (day < firstDayOfYear) { year--; firstDayOfYear = getLinearDay(year, 1, gregorian); } day -= firstDayOfYear - 1; // day of year, one based. fields[DAY_OF_YEAR] = (int) day; if (year <= 0) { fields[ERA] = BC; fields[YEAR] = 1 - year; } else { fields[ERA] = AD; fields[YEAR] = year; } int leapday = isLeapYear(year, gregorian) ? 1 : 0; if (day <= 31 + 28 + leapday) { fields[MONTH] = (int) day / 32; // 31->JANUARY, 32->FEBRUARY fields[DAY_OF_MONTH] = (int) day - 31 * fields[MONTH]; } else { // A few more magic formulas int scaledDay = ((int) day - leapday) * 5 + 8; fields[MONTH] = scaledDay / (31 + 30 + 31 + 30 + 31); fields[DAY_OF_MONTH] = (scaledDay % (31 + 30 + 31 + 30 + 31)) / 5 + 1; } }
int leapday = isLeapYear(year, gregorian) ? 1 : 0;
int leapday = isLeapYear(year) ? 1 : 0;
private void calculateDay(int[] fields, long day, boolean gregorian) { // the epoch is a Thursday. int weekday = (int) (day + THURSDAY) % 7; if (weekday <= 0) weekday += 7; fields[DAY_OF_WEEK] = weekday; // get a first approximation of the year. This may be one // year too big. int year = 1970 + (int) (gregorian ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1) : ((day - 100) * 4) / (365 * 4 + 1)); if (day >= 0) year++; long firstDayOfYear = getLinearDay(year, 1, gregorian); // Now look in which year day really lies. if (day < firstDayOfYear) { year--; firstDayOfYear = getLinearDay(year, 1, gregorian); } day -= firstDayOfYear - 1; // day of year, one based. fields[DAY_OF_YEAR] = (int) day; if (year <= 0) { fields[ERA] = BC; fields[YEAR] = 1 - year; } else { fields[ERA] = AD; fields[YEAR] = year; } int leapday = isLeapYear(year, gregorian) ? 1 : 0; if (day <= 31 + 28 + leapday) { fields[MONTH] = (int) day / 32; // 31->JANUARY, 32->FEBRUARY fields[DAY_OF_MONTH] = (int) day - 31 * fields[MONTH]; } else { // A few more magic formulas int scaledDay = ((int) day - leapday) * 5 + 8; fields[MONTH] = scaledDay / (31 + 30 + 31 + 30 + 31); fields[DAY_OF_MONTH] = (scaledDay % (31 + 30 + 31 + 30 + 31)) / 5 + 1; } }
int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH])
int millisInDay = 0; int era = fields[ERA]; int year = fields[YEAR]; int month = fields[MONTH]; int day = fields[DAY_OF_MONTH]; int minute = fields[MINUTE]; int second = fields[SECOND]; int millis = fields[MILLISECOND]; int[] month_days = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int[] dayCount = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; int hour = 0; if (! isLenient()) nonLeniencyCheck(); if (! isSet[MONTH]) { if (isSet[DAY_OF_WEEK] || isSet[WEEK_OF_YEAR]) { int first = getFirstDayOfMonth(year, 0); int offs; if ((8 - first) >= getMinimalDaysInFirstWeek()) offs = 1; else offs = 1 + (8 - first); month = 0; day = offs + 7 * (fields[WEEK_OF_YEAR] - 1); day += fields[DAY_OF_WEEK] - first; } else { month = 0; day = fields[DAY_OF_YEAR]; } } else
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0)
if (isSet[DAY_OF_WEEK])
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
month += 12; year--;
int first = getFirstDayOfMonth(year, month); if (isSet[DAY_OF_WEEK_IN_MONTH]) { int offs = fields[DAY_OF_WEEK] - first; if (offs < 0) offs += 7; day = 1 + 7 * (fields[DAY_OF_WEEK_IN_MONTH] - 1); day += offs; } else { day = 1 + 7 * (fields[WEEK_OF_MONTH] - 1); day += fields[DAY_OF_WEEK] - first; }
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year;
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0;
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay;
long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; day += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L));
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
if (isLenient())
if (month < 0)
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L));
year += (int) month / 12; month = month % 12; if (month < 0) { month += 12; year--;
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
else
} if (month > 11)
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--;
year += (month / 12); month = month % 12;
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true;
month_days[1] = isLeapYear(year) ? 29 : 28; while (day <= 0) { if (month == 0) { year--; month_days[1] = isLeapYear(year) ? 29 : 28; } month = (month + 11) % 12; day += month_days[month];
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
while (day > month_days[month]) { day -= (month_days[month]); month = (month + 1) % 12; if (month == 0) { year++; month_days[1] = isLeapYear(year) ? 29 : 28; } } int dayOfYear = dayCount[month] + day - 1; if (isLeapYear(year) && month > 1) dayOfYear++; int relativeDay = (year - 1) * 365 + ((year - 1) >> 2) + dayOfYear - EPOCH_DAYS; int gregFactor = (int) Math.floor((double) (year - 1) / 400.) - (int) Math.floor((double) (year - 1) / 100.); if ((relativeDay + gregFactor) * 60L * 60L * 24L * 1000L >= gregorianCutover) relativeDay += gregFactor; else relativeDay -= 2; time = relativeDay * (24 * 60 * 60 * 1000L) + millisInDay; int weekday = (int) (relativeDay + THURSDAY) % 7; if (weekday <= 0) weekday += 7; fields[DAY_OF_WEEK] = weekday; TimeZone zone = getTimeZone(); int rawOffset = zone.getRawOffset(); int dstOffset = zone.getOffset((year < 1) ? BC : AD, (year < 1) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset(); time -= (rawOffset + dstOffset); isTimeSet = true; }
protected synchronized void computeTime() { int era = isSet[ERA] ? fields[ERA] : AD; int year = isSet[YEAR] ? fields[YEAR] : 1970; if (isLenient() && isSet[MONTH]) { int month = fields[MONTH]; year += month / 12; month %= 12; if (month < 0) { month += 12; year--; } fields[MONTH] = month; isSet[YEAR] = true; fields[YEAR] = year; } if (era == BC) year = 1 - year; int[] daysOfYear = getDayOfYear(year); int hour = 0; if (isSet[HOUR_OF_DAY]) hour = fields[HOUR_OF_DAY]; else if (isSet[HOUR]) { hour = fields[HOUR]; if (isSet[AM_PM] && fields[AM_PM] == PM) if (hour != 12) /* not Noon */ hour += 12; /* Fix the problem of the status of 12:00 AM (midnight). */ if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12) hour = 0; } int minute = isSet[MINUTE] ? fields[MINUTE] : 0; int second = isSet[SECOND] ? fields[SECOND] : 0; int millis = isSet[MILLISECOND] ? fields[MILLISECOND] : 0; int millisInDay; if (isLenient()) { // prevent overflow long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L + millis; daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L); millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L)); } else { if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0 || second > 59 || millis < 0 || millis >= 1000) throw new IllegalArgumentException(); millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis; } time = getLinearTime(year, daysOfYear[0], millisInDay); // Add the relative days after calculating the linear time, to // get right behaviour when jumping over the gregorianCutover. time += daysOfYear[1] * (24 * 60 * 60 * 1000L); TimeZone zone = getTimeZone(); int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET] : zone.getRawOffset(); int day = (int) (time / (24 * 60 * 60 * 1000L)); millisInDay = (int) (time % (24 * 60 * 60 * 1000L)); if (millisInDay < 0) { millisInDay += (24 * 60 * 60 * 1000); day--; } int[] f = new int[FIELD_COUNT]; calculateDay(f, day, time - rawOffset >= gregorianCutover); year = f[YEAR]; int month = f[MONTH]; day = f[DAY_OF_MONTH]; int weekday = f[DAY_OF_WEEK]; int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD, (year < 0) ? 1 - year : year, month, day, weekday, millisInDay) - zone.getRawOffset()); time -= rawOffset + dstOffset; isTimeSet = true; }
long julianDay = ((year * (365L * 4 + 1)) >> 2) + dayOfYear - ((1970 * (365 * 4 + 1)) / 4 + 1 - 13);
long julianDay = (year - 1) * 365L + ((year - 1) >> 2) + (dayOfYear - 1) - EPOCH_DAYS;
private long getLinearDay(int year, int dayOfYear, boolean gregorian) { // The 13 is the number of days, that were omitted in the Gregorian // Calender until the epoch. // We shift right by 2 instead of dividing by 4, to get correct // results for negative years (and this is even more efficient). long julianDay = ((year * (365L * 4 + 1)) >> 2) + dayOfYear - ((1970 * (365 * 4 + 1)) / 4 + 1 - 13); if (gregorian) { // subtract the days that are missing in gregorian calendar // with respect to julian calendar. // // Okay, here we rely on the fact that the gregorian // calendar was introduced in the AD era. This doesn't work // with negative years. // // The additional leap year factor accounts for the fact that // a leap day is not seen on Jan 1 of the leap year. int gregOffset = (year / 400) - (year / 100) + 2; if (isLeapYear(year, true) && dayOfYear < 31 + 29) --gregOffset; julianDay += gregOffset; } return julianDay; }
int gregOffset = (year / 400) - (year / 100) + 2; if (isLeapYear(year, true) && dayOfYear < 31 + 29) --gregOffset; julianDay += gregOffset;
int gregOffset = (int) Math.floor((double) (year - 1) / 400.) - (int) Math.floor((double) (year - 1) / 100.); return julianDay + gregOffset;
private long getLinearDay(int year, int dayOfYear, boolean gregorian) { // The 13 is the number of days, that were omitted in the Gregorian // Calender until the epoch. // We shift right by 2 instead of dividing by 4, to get correct // results for negative years (and this is even more efficient). long julianDay = ((year * (365L * 4 + 1)) >> 2) + dayOfYear - ((1970 * (365 * 4 + 1)) / 4 + 1 - 13); if (gregorian) { // subtract the days that are missing in gregorian calendar // with respect to julian calendar. // // Okay, here we rely on the fact that the gregorian // calendar was introduced in the AD era. This doesn't work // with negative years. // // The additional leap year factor accounts for the fact that // a leap day is not seen on Jan 1 of the leap year. int gregOffset = (year / 400) - (year / 100) + 2; if (isLeapYear(year, true) && dayOfYear < 31 + 29) --gregOffset; julianDay += gregOffset; } return julianDay; }
else julianDay -= 2;
private long getLinearDay(int year, int dayOfYear, boolean gregorian) { // The 13 is the number of days, that were omitted in the Gregorian // Calender until the epoch. // We shift right by 2 instead of dividing by 4, to get correct // results for negative years (and this is even more efficient). long julianDay = ((year * (365L * 4 + 1)) >> 2) + dayOfYear - ((1970 * (365 * 4 + 1)) / 4 + 1 - 13); if (gregorian) { // subtract the days that are missing in gregorian calendar // with respect to julian calendar. // // Okay, here we rely on the fact that the gregorian // calendar was introduced in the AD era. This doesn't work // with negative years. // // The additional leap year factor accounts for the fact that // a leap day is not seen on Jan 1 of the leap year. int gregOffset = (year / 400) - (year / 100) + 2; if (isLeapYear(year, true) && dayOfYear < 31 + 29) --gregOffset; julianDay += gregOffset; } return julianDay; }
int day = (int) (getLinearTime(year, dayOfYear, 0) / (24 * 60 * 60 * 1000L));
boolean greg = isGregorian(year, dayOfYear); int day = (int) getLinearDay(year, dayOfYear, greg);
private int getWeekDay(int year, int dayOfYear) { int day = (int) (getLinearTime(year, dayOfYear, 0) / (24 * 60 * 60 * 1000L)); // The epoch was a thursday. int weekday = (day + THURSDAY) % 7; if (weekday <= 0) weekday += 7; return weekday; }
if ((year & 3) != 0)
public boolean isLeapYear(int year) { if ((year & 3) != 0) // Only years divisible by 4 can be leap years return false; // compute the linear day of the 29. February of that year. // The 13 is the number of days, that were omitted in the Gregorian // Calender until the epoch. int julianDay = (((year - 1) * (365 * 4 + 1)) >> 2) + (31 + 29 - (((1970 - 1) * (365 * 4 + 1)) / 4 + 1 - 13)); // If that day is smaller than the gregorianChange the julian // rule applies: This is a leap year since it is divisible by 4. if (julianDay * (24 * 60 * 60 * 1000L) < gregorianCutover) return true; return ((year % 100) != 0 || (year % 400) == 0); }
int julianDay = (((year - 1) * (365 * 4 + 1)) >> 2) + (31 + 29 - (((1970 - 1) * (365 * 4 + 1)) / 4 + 1 - 13)); if (julianDay * (24 * 60 * 60 * 1000L) < gregorianCutover)
if (! isGregorian(year, 31 + 29 - 1))
public boolean isLeapYear(int year) { if ((year & 3) != 0) // Only years divisible by 4 can be leap years return false; // compute the linear day of the 29. February of that year. // The 13 is the number of days, that were omitted in the Gregorian // Calender until the epoch. int julianDay = (((year - 1) * (365 * 4 + 1)) >> 2) + (31 + 29 - (((1970 - 1) * (365 * 4 + 1)) / 4 + 1 - 13)); // If that day is smaller than the gregorianChange the julian // rule applies: This is a leap year since it is divisible by 4. if (julianDay * (24 * 60 * 60 * 1000L) < gregorianCutover) return true; return ((year % 100) != 0 || (year % 400) == 0); }
protected Calendar(TimeZone zone, Locale locale)
protected Calendar()
protected Calendar(TimeZone zone, Locale locale) { this.zone = zone; lenient = true; ResourceBundle rb = getBundle(locale); firstDayOfWeek = ((Integer) rb.getObject("firstDayOfWeek")).intValue(); minimalDaysInFirstWeek = ((Integer) rb.getObject("minimalDaysInFirstWeek")).intValue(); }
this.zone = zone; lenient = true; ResourceBundle rb = getBundle(locale); firstDayOfWeek = ((Integer) rb.getObject("firstDayOfWeek")).intValue(); minimalDaysInFirstWeek = ((Integer) rb.getObject("minimalDaysInFirstWeek")).intValue();
this(TimeZone.getDefault(), Locale.getDefault());
protected Calendar(TimeZone zone, Locale locale) { this.zone = zone; lenient = true; ResourceBundle rb = getBundle(locale); firstDayOfWeek = ((Integer) rb.getObject("firstDayOfWeek")).intValue(); minimalDaysInFirstWeek = ((Integer) rb.getObject("minimalDaysInFirstWeek")).intValue(); }
int index = BasicListUI.this.locationToIndex(list, click);
int index = locationToIndex(list, click);
public void mouseClicked(MouseEvent event) { Point click = event.getPoint(); int index = BasicListUI.this.locationToIndex(list, click); if (index == -1) return; if (event.isShiftDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_INTERVAL_SELECTION) // COMPAT: the IBM VM is compatible with the following line of code. // However, compliance with Sun's VM would correspond to replacing // getAnchorSelectionIndex() with getLeadSelectionIndex().This is // both unnatural and contradictory to the way they handle other // similar UI interactions. BasicListUI.this.list.setSelectionInterval (BasicListUI.this.list.getAnchorSelectionIndex(), index); else // COMPAT: both Sun and IBM are compatible instead with: // BasicListUI.this.list.setSelectionInterval // (BasicListUI.this.list.getLeadSelectionIndex(),index); // Note that for IBM this is contradictory to what they did in // the above situation for SINGLE_INTERVAL_SELECTION. // The most natural thing to do is the following: BasicListUI.this.list.getSelectionModel(). setLeadSelectionIndex(index); } else if (event.isControlDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.isSelectedIndex(index)) BasicListUI.this.list.removeSelectionInterval(index,index); else BasicListUI.this.list.addSelectionInterval(index,index); } else BasicListUI.this.list.setSelectedIndex(index); BasicListUI.this.list.ensureIndexIsVisible (BasicListUI.this.list.getLeadSelectionIndex()); }
if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.getSelectionMode() ==
if (list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) list.setSelectedIndex(index); else if (list.getSelectionMode() ==
public void mouseClicked(MouseEvent event) { Point click = event.getPoint(); int index = BasicListUI.this.locationToIndex(list, click); if (index == -1) return; if (event.isShiftDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_INTERVAL_SELECTION) // COMPAT: the IBM VM is compatible with the following line of code. // However, compliance with Sun's VM would correspond to replacing // getAnchorSelectionIndex() with getLeadSelectionIndex().This is // both unnatural and contradictory to the way they handle other // similar UI interactions. BasicListUI.this.list.setSelectionInterval (BasicListUI.this.list.getAnchorSelectionIndex(), index); else // COMPAT: both Sun and IBM are compatible instead with: // BasicListUI.this.list.setSelectionInterval // (BasicListUI.this.list.getLeadSelectionIndex(),index); // Note that for IBM this is contradictory to what they did in // the above situation for SINGLE_INTERVAL_SELECTION. // The most natural thing to do is the following: BasicListUI.this.list.getSelectionModel(). setLeadSelectionIndex(index); } else if (event.isControlDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.isSelectedIndex(index)) BasicListUI.this.list.removeSelectionInterval(index,index); else BasicListUI.this.list.addSelectionInterval(index,index); } else BasicListUI.this.list.setSelectedIndex(index); BasicListUI.this.list.ensureIndexIsVisible (BasicListUI.this.list.getLeadSelectionIndex()); }
BasicListUI.this.list.setSelectionInterval (BasicListUI.this.list.getAnchorSelectionIndex(), index);
list.setSelectionInterval(list.getAnchorSelectionIndex(), index);
public void mouseClicked(MouseEvent event) { Point click = event.getPoint(); int index = BasicListUI.this.locationToIndex(list, click); if (index == -1) return; if (event.isShiftDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_INTERVAL_SELECTION) // COMPAT: the IBM VM is compatible with the following line of code. // However, compliance with Sun's VM would correspond to replacing // getAnchorSelectionIndex() with getLeadSelectionIndex().This is // both unnatural and contradictory to the way they handle other // similar UI interactions. BasicListUI.this.list.setSelectionInterval (BasicListUI.this.list.getAnchorSelectionIndex(), index); else // COMPAT: both Sun and IBM are compatible instead with: // BasicListUI.this.list.setSelectionInterval // (BasicListUI.this.list.getLeadSelectionIndex(),index); // Note that for IBM this is contradictory to what they did in // the above situation for SINGLE_INTERVAL_SELECTION. // The most natural thing to do is the following: BasicListUI.this.list.getSelectionModel(). setLeadSelectionIndex(index); } else if (event.isControlDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.isSelectedIndex(index)) BasicListUI.this.list.removeSelectionInterval(index,index); else BasicListUI.this.list.addSelectionInterval(index,index); } else BasicListUI.this.list.setSelectedIndex(index); BasicListUI.this.list.ensureIndexIsVisible (BasicListUI.this.list.getLeadSelectionIndex()); }
BasicListUI.this.list.getSelectionModel(). setLeadSelectionIndex(index);
if (list.isSelectedIndex(list.getAnchorSelectionIndex())) list.getSelectionModel().setLeadSelectionIndex(index); else list.addSelectionInterval(list.getAnchorSelectionIndex(), index);
public void mouseClicked(MouseEvent event) { Point click = event.getPoint(); int index = BasicListUI.this.locationToIndex(list, click); if (index == -1) return; if (event.isShiftDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_INTERVAL_SELECTION) // COMPAT: the IBM VM is compatible with the following line of code. // However, compliance with Sun's VM would correspond to replacing // getAnchorSelectionIndex() with getLeadSelectionIndex().This is // both unnatural and contradictory to the way they handle other // similar UI interactions. BasicListUI.this.list.setSelectionInterval (BasicListUI.this.list.getAnchorSelectionIndex(), index); else // COMPAT: both Sun and IBM are compatible instead with: // BasicListUI.this.list.setSelectionInterval // (BasicListUI.this.list.getLeadSelectionIndex(),index); // Note that for IBM this is contradictory to what they did in // the above situation for SINGLE_INTERVAL_SELECTION. // The most natural thing to do is the following: BasicListUI.this.list.getSelectionModel(). setLeadSelectionIndex(index); } else if (event.isControlDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.isSelectedIndex(index)) BasicListUI.this.list.removeSelectionInterval(index,index); else BasicListUI.this.list.addSelectionInterval(index,index); } else BasicListUI.this.list.setSelectedIndex(index); BasicListUI.this.list.ensureIndexIsVisible (BasicListUI.this.list.getLeadSelectionIndex()); }
if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.isSelectedIndex(index)) BasicListUI.this.list.removeSelectionInterval(index,index);
if (list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) list.setSelectedIndex(index); else if (list.isSelectedIndex(index)) list.removeSelectionInterval(index,index);
public void mouseClicked(MouseEvent event) { Point click = event.getPoint(); int index = BasicListUI.this.locationToIndex(list, click); if (index == -1) return; if (event.isShiftDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_INTERVAL_SELECTION) // COMPAT: the IBM VM is compatible with the following line of code. // However, compliance with Sun's VM would correspond to replacing // getAnchorSelectionIndex() with getLeadSelectionIndex().This is // both unnatural and contradictory to the way they handle other // similar UI interactions. BasicListUI.this.list.setSelectionInterval (BasicListUI.this.list.getAnchorSelectionIndex(), index); else // COMPAT: both Sun and IBM are compatible instead with: // BasicListUI.this.list.setSelectionInterval // (BasicListUI.this.list.getLeadSelectionIndex(),index); // Note that for IBM this is contradictory to what they did in // the above situation for SINGLE_INTERVAL_SELECTION. // The most natural thing to do is the following: BasicListUI.this.list.getSelectionModel(). setLeadSelectionIndex(index); } else if (event.isControlDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.isSelectedIndex(index)) BasicListUI.this.list.removeSelectionInterval(index,index); else BasicListUI.this.list.addSelectionInterval(index,index); } else BasicListUI.this.list.setSelectedIndex(index); BasicListUI.this.list.ensureIndexIsVisible (BasicListUI.this.list.getLeadSelectionIndex()); }
BasicListUI.this.list.addSelectionInterval(index,index);
list.addSelectionInterval(index,index);
public void mouseClicked(MouseEvent event) { Point click = event.getPoint(); int index = BasicListUI.this.locationToIndex(list, click); if (index == -1) return; if (event.isShiftDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_INTERVAL_SELECTION) // COMPAT: the IBM VM is compatible with the following line of code. // However, compliance with Sun's VM would correspond to replacing // getAnchorSelectionIndex() with getLeadSelectionIndex().This is // both unnatural and contradictory to the way they handle other // similar UI interactions. BasicListUI.this.list.setSelectionInterval (BasicListUI.this.list.getAnchorSelectionIndex(), index); else // COMPAT: both Sun and IBM are compatible instead with: // BasicListUI.this.list.setSelectionInterval // (BasicListUI.this.list.getLeadSelectionIndex(),index); // Note that for IBM this is contradictory to what they did in // the above situation for SINGLE_INTERVAL_SELECTION. // The most natural thing to do is the following: BasicListUI.this.list.getSelectionModel(). setLeadSelectionIndex(index); } else if (event.isControlDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.isSelectedIndex(index)) BasicListUI.this.list.removeSelectionInterval(index,index); else BasicListUI.this.list.addSelectionInterval(index,index); } else BasicListUI.this.list.setSelectedIndex(index); BasicListUI.this.list.ensureIndexIsVisible (BasicListUI.this.list.getLeadSelectionIndex()); }
BasicListUI.this.list.setSelectedIndex(index);
list.setSelectedIndex(index);
public void mouseClicked(MouseEvent event) { Point click = event.getPoint(); int index = BasicListUI.this.locationToIndex(list, click); if (index == -1) return; if (event.isShiftDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_INTERVAL_SELECTION) // COMPAT: the IBM VM is compatible with the following line of code. // However, compliance with Sun's VM would correspond to replacing // getAnchorSelectionIndex() with getLeadSelectionIndex().This is // both unnatural and contradictory to the way they handle other // similar UI interactions. BasicListUI.this.list.setSelectionInterval (BasicListUI.this.list.getAnchorSelectionIndex(), index); else // COMPAT: both Sun and IBM are compatible instead with: // BasicListUI.this.list.setSelectionInterval // (BasicListUI.this.list.getLeadSelectionIndex(),index); // Note that for IBM this is contradictory to what they did in // the above situation for SINGLE_INTERVAL_SELECTION. // The most natural thing to do is the following: BasicListUI.this.list.getSelectionModel(). setLeadSelectionIndex(index); } else if (event.isControlDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.isSelectedIndex(index)) BasicListUI.this.list.removeSelectionInterval(index,index); else BasicListUI.this.list.addSelectionInterval(index,index); } else BasicListUI.this.list.setSelectedIndex(index); BasicListUI.this.list.ensureIndexIsVisible (BasicListUI.this.list.getLeadSelectionIndex()); }
BasicListUI.this.list.ensureIndexIsVisible (BasicListUI.this.list.getLeadSelectionIndex());
list.ensureIndexIsVisible(list.getLeadSelectionIndex());
public void mouseClicked(MouseEvent event) { Point click = event.getPoint(); int index = BasicListUI.this.locationToIndex(list, click); if (index == -1) return; if (event.isShiftDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_INTERVAL_SELECTION) // COMPAT: the IBM VM is compatible with the following line of code. // However, compliance with Sun's VM would correspond to replacing // getAnchorSelectionIndex() with getLeadSelectionIndex().This is // both unnatural and contradictory to the way they handle other // similar UI interactions. BasicListUI.this.list.setSelectionInterval (BasicListUI.this.list.getAnchorSelectionIndex(), index); else // COMPAT: both Sun and IBM are compatible instead with: // BasicListUI.this.list.setSelectionInterval // (BasicListUI.this.list.getLeadSelectionIndex(),index); // Note that for IBM this is contradictory to what they did in // the above situation for SINGLE_INTERVAL_SELECTION. // The most natural thing to do is the following: BasicListUI.this.list.getSelectionModel(). setLeadSelectionIndex(index); } else if (event.isControlDown()) { if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) BasicListUI.this.list.setSelectedIndex(index); else if (BasicListUI.this.list.isSelectedIndex(index)) BasicListUI.this.list.removeSelectionInterval(index,index); else BasicListUI.this.list.addSelectionInterval(index,index); } else BasicListUI.this.list.setSelectedIndex(index); BasicListUI.this.list.ensureIndexIsVisible (BasicListUI.this.list.getLeadSelectionIndex()); }
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); InputMap focusInputMap = (InputMap)defaults.get("List.focusInputMap"); InputMapUIResource parentInputMap = new InputMapUIResource(); ActionMap parentActionMap = new ActionMap(); action = new ListAction(); Object keys[] = focusInputMap.allKeys(); for (int i = 0; i < keys.length; i++) { parentInputMap.put(KeyStroke.getKeyStroke (((KeyStroke)keys[i]).getKeyCode(), convertModifiers (((KeyStroke)keys[i]).getModifiers())), (String)focusInputMap.get((KeyStroke)keys[i])); parentInputMap.put(KeyStroke.getKeyStroke (((KeyStroke)keys[i]).getKeyCode(), ((KeyStroke)keys[i]).getModifiers()), (String)focusInputMap.get((KeyStroke)keys[i])); parentActionMap.put ((String)focusInputMap.get((KeyStroke)keys[i]), new ActionListenerProxy (action, (String)focusInputMap.get((KeyStroke)keys[i]))); } parentInputMap.setParent(list.getInputMap().getParent()); parentActionMap.setParent(list.getActionMap().getParent()); list.getInputMap().setParent(parentInputMap); list.getActionMap().setParent(parentActionMap);
protected void installKeyboardActions() { }
keyListener = new KeyHandler();
protected void installListeners() { if (focusListener == null) focusListener = createFocusListener(); list.addFocusListener(focusListener); if (listDataListener == null) listDataListener = createListDataListener(); list.getModel().addListDataListener(listDataListener); if (listSelectionListener == null) listSelectionListener = createListSelectionListener(); list.addListSelectionListener(listSelectionListener); if (mouseInputListener == null) mouseInputListener = createMouseInputListener(); list.addMouseListener(mouseInputListener); list.addMouseMotionListener(mouseInputListener); if (propertyChangeListener == null) propertyChangeListener = createPropertyChangeListener(); list.addPropertyChangeListener(propertyChangeListener); // FIXME: Are these two really needed? At least they are not documented. keyListener = new KeyHandler(); list.addComponentListener(componentListener); componentListener = new ComponentHandler(); list.addKeyListener(keyListener); }
list.addKeyListener(keyListener);
protected void installListeners() { if (focusListener == null) focusListener = createFocusListener(); list.addFocusListener(focusListener); if (listDataListener == null) listDataListener = createListDataListener(); list.getModel().addListDataListener(listDataListener); if (listSelectionListener == null) listSelectionListener = createListSelectionListener(); list.addListSelectionListener(listSelectionListener); if (mouseInputListener == null) mouseInputListener = createMouseInputListener(); list.addMouseListener(mouseInputListener); list.addMouseMotionListener(mouseInputListener); if (propertyChangeListener == null) propertyChangeListener = createPropertyChangeListener(); list.addPropertyChangeListener(propertyChangeListener); // FIXME: Are these two really needed? At least they are not documented. keyListener = new KeyHandler(); list.addComponentListener(componentListener); componentListener = new ComponentHandler(); list.addKeyListener(keyListener); }
int index = list.getSelectedIndex();
int index = list.getSelectionModel().getLeadSelectionIndex(); if (index < list.getModel().getSize() - 1) {
protected void selectNextIndex() { int index = list.getSelectedIndex(); index++; list.setSelectedIndex(index); list.ensureIndexIsVisible(index); }
}
protected void selectNextIndex() { int index = list.getSelectedIndex(); index++; list.setSelectedIndex(index); list.ensureIndexIsVisible(index); }
int index = list.getSelectedIndex();
int index = list.getSelectionModel().getLeadSelectionIndex(); if (index > 0) {
protected void selectPreviousIndex() { int index = list.getSelectedIndex(); index--; list.setSelectedIndex(index); list.ensureIndexIsVisible(index); }
}
protected void selectPreviousIndex() { int index = list.getSelectedIndex(); index--; list.setSelectedIndex(index); list.ensureIndexIsVisible(index); }
list.removeKeyListener(keyListener);
protected void uninstallListeners() { list.removeFocusListener(focusListener); list.getModel().removeListDataListener(listDataListener); list.removeListSelectionListener(listSelectionListener); list.removeMouseListener(mouseInputListener); list.removeKeyListener(keyListener); list.removeMouseMotionListener(mouseInputListener); list.removePropertyChangeListener(propertyChangeListener); }
(sb.charAt(len) < ' ' || sb.charAt(len) >= '\uff20' )) {
(sb.charAt(len) < ' ' || sb.charAt(len) >= '\uff20')) { if (sb.charAt(len) == 0x1C && sf.isDupEnabled()) break;
protected void readFormatTable(ByteArrayOutputStream baosp,int readType, CodePage codePage) { ScreenField sf; boolean isSigned = false; char c; if (masterMDT) { StringBuffer sb = new StringBuffer(); for (int x = 0; x < sizeFields; x++) { isSigned = false; sf = screenFields[x]; if (sf.mdt || (readType == CMD_READ_INPUT_FIELDS)) { sb.setLength(0); sb.append(sf.getText()); if (readType == CMD_READ_MDT_FIELDS || readType == CMD_READ_MDT_IMMEDIATE_ALT) { int len = sb.length() - 1; // we strip out all '\u0020' and less while (len >= 0 &&// (sb.charAt(len) <= ' ' || sb.charAt(len) >= '\uff20' )) { (sb.charAt(len) < ' ' || sb.charAt(len) >= '\uff20' )) { sb.deleteCharAt(len--); } }// System.out.println("field " + sf.toString());// System.out.println(">" + sb.toString() + "<");// System.out.println(" field is all nulls"); if (sf.isSignedNumeric() && sb.length() > 0 && sb.charAt(sb.length() - 1) == '-') { isSigned = true; sb.setLength(sb.length() - 1); } int len3 = sb.length(); if (len3 > 0 || (readType == CMD_READ_MDT_FIELDS || readType == CMD_READ_MDT_IMMEDIATE_ALT)) { if ((readType == CMD_READ_MDT_FIELDS || readType == CMD_READ_MDT_IMMEDIATE_ALT)) { baosp.write(17); // start of field data baosp.write(sf.startRow()+1); baosp.write(sf.startCol()+1); }// int len = sb.length(); for (int k = 0; k < len3; k++) { c = sb.charAt(k); // here we have to check for special instances of the // characters in the string field. Attribute bytes // are encoded with an offset of \uff00 // This is a hack !!!!!!!!!!! // See ScreenField object for a description if (c < ' ' || c >= '\uff20') { // if it is an offset attribute byte we just pass // it straight on to the output stream if (c >= '\uff20' && c <= '\uff3f') { baosp.write(c - '\uff00'); } else baosp.write(codePage.getEBCDIC(' ')); } else { if (isSigned && k == len3 - 1) { baosp.write(0xd0 | (0x0f & c)); } else baosp.write(codePage.uni2ebcdic(c)); } } } } } } }
baosp.write(codePage.getEBCDIC(' '));
if (c == 0x1C) baosp.write(c); else baosp.write(codePage.getEBCDIC(' '));
protected void readFormatTable(ByteArrayOutputStream baosp,int readType, CodePage codePage) { ScreenField sf; boolean isSigned = false; char c; if (masterMDT) { StringBuffer sb = new StringBuffer(); for (int x = 0; x < sizeFields; x++) { isSigned = false; sf = screenFields[x]; if (sf.mdt || (readType == CMD_READ_INPUT_FIELDS)) { sb.setLength(0); sb.append(sf.getText()); if (readType == CMD_READ_MDT_FIELDS || readType == CMD_READ_MDT_IMMEDIATE_ALT) { int len = sb.length() - 1; // we strip out all '\u0020' and less while (len >= 0 &&// (sb.charAt(len) <= ' ' || sb.charAt(len) >= '\uff20' )) { (sb.charAt(len) < ' ' || sb.charAt(len) >= '\uff20' )) { sb.deleteCharAt(len--); } }// System.out.println("field " + sf.toString());// System.out.println(">" + sb.toString() + "<");// System.out.println(" field is all nulls"); if (sf.isSignedNumeric() && sb.length() > 0 && sb.charAt(sb.length() - 1) == '-') { isSigned = true; sb.setLength(sb.length() - 1); } int len3 = sb.length(); if (len3 > 0 || (readType == CMD_READ_MDT_FIELDS || readType == CMD_READ_MDT_IMMEDIATE_ALT)) { if ((readType == CMD_READ_MDT_FIELDS || readType == CMD_READ_MDT_IMMEDIATE_ALT)) { baosp.write(17); // start of field data baosp.write(sf.startRow()+1); baosp.write(sf.startCol()+1); }// int len = sb.length(); for (int k = 0; k < len3; k++) { c = sb.charAt(k); // here we have to check for special instances of the // characters in the string field. Attribute bytes // are encoded with an offset of \uff00 // This is a hack !!!!!!!!!!! // See ScreenField object for a description if (c < ' ' || c >= '\uff20') { // if it is an offset attribute byte we just pass // it straight on to the output stream if (c >= '\uff20' && c <= '\uff3f') { baosp.write(c - '\uff00'); } else baosp.write(codePage.getEBCDIC(' ')); } else { if (isSigned && k == len3 - 1) { baosp.write(0xd0 | (0x0f & c)); } else baosp.write(codePage.uni2ebcdic(c)); } } } } } } }
super ("UTF-8", null);
super ("UTF-8", new String[] { "ibm-1208", "ibm-1209", "ibm-5304", "ibm-5305", "windows-65001", "cp1208", "UTF8" });
UTF_8 () { super ("UTF-8", null); }
catch (ThreadDeath death) { return; }
public void run() { while (true) { try { AWTEvent evt = queue.getNextEvent(); if (isInterrupted ()) { // We are interrupted when we should finish executing return; } KeyboardFocusManager manager; manager = KeyboardFocusManager.getCurrentKeyboardFocusManager (); // Try to dispatch this event to the current keyboard focus // manager. It will dispatch all FocusEvents, all // WindowEvents related to focus, and all KeyEvents, // returning true. Otherwise, it returns false and we // dispatch the event normally. if (!manager.dispatchEvent (evt)) queue.dispatchEvent(evt); } catch (InterruptedException ie) { // We are interrupted when we should finish executing return; } catch (Throwable x) { System.err.println("Exception during event dispatch:"); x.printStackTrace(System.err); } } }
public void connect(org.omg.CORBA.Object object, byte[] key)
public void connect(org.omg.CORBA.Object object)
public void connect(org.omg.CORBA.Object object, byte[] key) { int a_port = getFreePort(); Connected_objects.cObject ref = connected_objects.add(key, object, a_port, null); IOR ior = createIOR(ref); prepareObject(object, ior); if (running) startService(ior); }
Connected_objects.cObject ref = connected_objects.add(key, object, a_port, null);
Connected_objects.cObject ref = connected_objects.add(object, a_port);
public void connect(org.omg.CORBA.Object object, byte[] key) { int a_port = getFreePort(); Connected_objects.cObject ref = connected_objects.add(key, object, a_port, null); IOR ior = createIOR(ref); prepareObject(object, ior); if (running) startService(ior); }
try { ior.Internet.host = InetAddress.getLocalHost().getHostAddress();
ior.Internet.host = CollocatedOrbs.localHost;
protected IOR createIOR(Connected_objects.cObject ref) throws BAD_OPERATION { IOR ior = new IOR(); ior.key = ref.key; ior.Internet.port = ref.port; if (ref.object instanceof ObjectImpl) { ObjectImpl imp = (ObjectImpl) ref.object; if (imp._ids().length > 0) ior.Id = imp._ids() [ 0 ]; } if (ior.Id == null) ior.Id = ref.object.getClass().getName(); try { ior.Internet.host = InetAddress.getLocalHost().getHostAddress(); ior.Internet.port = ref.port; } catch (UnknownHostException ex) { throw new BAD_OPERATION("Cannot resolve the local host address"); } return ior; }
} catch (UnknownHostException ex) { throw new BAD_OPERATION("Cannot resolve the local host address"); }
protected IOR createIOR(Connected_objects.cObject ref) throws BAD_OPERATION { IOR ior = new IOR(); ior.key = ref.key; ior.Internet.port = ref.port; if (ref.object instanceof ObjectImpl) { ObjectImpl imp = (ObjectImpl) ref.object; if (imp._ids().length > 0) ior.Id = imp._ids() [ 0 ]; } if (ior.Id == null) ior.Id = ref.object.getClass().getName(); try { ior.Internet.host = InetAddress.getLocalHost().getHostAddress(); ior.Internet.port = ref.port; } catch (UnknownHostException ex) { throw new BAD_OPERATION("Cannot resolve the local host address"); } return ior; }
}
public org.omg.CORBA.Object ior_to_object(IOR ior) { org.omg.CORBA.Object object = find_local_object(ior); if (object == null) { ObjectImpl impl = StubLocator.search(this, ior); try { if (impl._get_delegate() == null) impl._set_delegate(new IorDelegate(this, ior)); } catch (BAD_OPERATION ex) { // Some colaborants may throw this exception // in response to the attempt to get the unset delegate. impl._set_delegate(new IorDelegate(this, ior)); } object = impl; // TODO remove commented out code below. // connected_objects.add(ior.key, impl, ior.Internet.port, null); } return object; }
finally { CollocatedOrbs.unregisterOrb(this); } }
public void run() { running = true; // Instantiate the port server for each socket. Iterator iter = connected_objects.entrySet().iterator(); Map.Entry m; Connected_objects.cObject obj; while (iter.hasNext()) { m = (Map.Entry) iter.next(); obj = (Connected_objects.cObject) m.getValue(); portServer subserver; if (obj.identity == null) { subserver = new portServer(obj.port); portServers.add(subserver); } else subserver = (portServer) identities.get(obj.identity); if (!subserver.isAlive()) { // Reuse the current thread for the last portServer. if (!iter.hasNext()) { // Discard the iterator, eliminating lock checks. iter = null; subserver.run(); return; } else subserver.start(); } } }
String exIDL = toIDL(ex.getClass().getName());
String exIDL = getRepositoryId(ex.getClass());
public static void writeSystemException(OutputStream output, SystemException ex ) { String exIDL = toIDL(ex.getClass().getName()); output.write_string(exIDL); output.write_ulong(ex.minor); CompletionStatusHelper.write(output, ex.completed); }
return Class.forName(toClassName(idl) + suffix).newInstance();
return Class.forName(toClassName(JAVA_PREFIX, idl) + suffix) .newInstance();
public static java.lang.Object createObject(String idl, String suffix) { try { return Class.forName(toClassName(idl) + suffix).newInstance(); } catch (Exception ex) { return null; } }
}
public static java.lang.Object createObject(String idl, String suffix) { try { return Class.forName(toClassName(idl) + suffix).newInstance(); } catch (Exception ex) { return null; } }
String cl = toClassName(idl);
String cl = toClassName(JAVA_PREFIX, idl);
public static SystemException createSystemException(String idl, int minor, CompletionStatus completed ) { try { String cl = toClassName(idl); Class exClass = Class.forName(cl); Constructor constructor = exClass.getConstructor(new Class[] { String.class, int.class, CompletionStatus.class } ); Object exception = constructor.newInstance(new Object[] { " Remote exception " + idl + ", minor " + minor + ", " + completed + ".", new Integer(minor), completed } ); return (SystemException) exception; } catch (Exception ex) { ex.printStackTrace(); return new UNKNOWN("Unsupported system exception", minor, completed); } }
protected static String toClassName(String IDL)
protected static String toClassName(String prefix, String IDL)
protected static String toClassName(String IDL) { String s = IDL; int a = s.indexOf(':') + 1; int b = s.lastIndexOf(':'); s = IDL.substring(a, b); if (s.startsWith(OMG_PREFIX)) s = JAVA_PREFIX + s.substring(OMG_PREFIX.length()); return s.replace('/', '.'); }
s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
s = prefix + s.substring(OMG_PREFIX.length());
protected static String toClassName(String IDL) { String s = IDL; int a = s.indexOf(':') + 1; int b = s.lastIndexOf(':'); s = IDL.substring(a, b); if (s.startsWith(OMG_PREFIX)) s = JAVA_PREFIX + s.substring(OMG_PREFIX.length()); return s.replace('/', '.'); }
if (response.getCodeClass() == 3 && getInstanceFollowRedirects()) {
if (isRedirect(response) && getInstanceFollowRedirects()) { InputStream body = response.getBody(); if (body != null) { byte[] ignore = new byte[1024]; while (true) { int n = body.read(ignore, 0, ignore.length); if (n == -1) break; } }
public void connect() throws IOException { if (connected) { return; } String protocol = url.getProtocol(); boolean secure = "https".equals(protocol); String host = url.getHost(); int port = url.getPort(); if (port < 0) { port = secure ? HTTPConnection.HTTPS_PORT : HTTPConnection.HTTP_PORT; } String file = url.getFile(); String username = url.getUserInfo(); String password = null; if (username != null) { int ci = username.indexOf(':'); if (ci != -1) { password = username.substring(ci + 1); username = username.substring(0, ci); } } final Credentials creds = (username == null) ? null : new Credentials (username, password); boolean retry; do { retry = false; if (connection == null) { connection = getConnection(host, port, secure); if (secure) { SSLSocketFactory factory = getSSLSocketFactory(); HostnameVerifier verifier = getHostnameVerifier(); if (factory != null) { connection.setSSLSocketFactory(factory); } connection.addHandshakeCompletedListener(this); // TODO verifier } } if (proxyHostname != null) { if (proxyPort < 0) { proxyPort = secure ? HTTPConnection.HTTPS_PORT : HTTPConnection.HTTP_PORT; } connection.setProxy(proxyHostname, proxyPort); } try { request = connection.newRequest(method, file); if (!keepAlive) { request.setHeader("Connection", "close"); } if (agent != null) { request.setHeader("User-Agent", agent); } request.getHeaders().putAll(requestHeaders); if (requestSink != null) { byte[] content = requestSink.toByteArray(); RequestBodyWriter writer = new ByteArrayRequestBodyWriter(content); request.setRequestBodyWriter(writer); } if (creds != null) { request.setAuthenticator(new Authenticator() { public Credentials getCredentials(String realm, int attempts) { return (attempts < 2) ? creds : null; } }); } response = request.dispatch(); } catch (IOException ioe) { if (connection.useCount > 0) { // Connection re-use failed: Try a new connection. try { connection.close(); } catch (IOException _) { // Ignore. } connection = null; retry = true; continue; } else { // First time the connection was used: Hard failure. throw ioe; } } if (response.getCodeClass() == 3 && getInstanceFollowRedirects()) { // Follow redirect String location = response.getHeader("Location"); if (location != null) { String connectionUri = connection.getURI(); int start = connectionUri.length(); if (location.startsWith(connectionUri) && location.charAt(start) == '/') { file = location.substring(start); retry = true; } else if (location.startsWith("http:")) { connection.close(); connection = null; secure = false; start = 7; int end = location.indexOf('/', start); host = location.substring(start, end); int ci = host.lastIndexOf(':'); if (ci != -1) { port = Integer.parseInt(host.substring (ci + 1)); host = host.substring(0, ci); } else { port = HTTPConnection.HTTP_PORT; } file = location.substring(end); retry = true; } else if (location.startsWith("https:")) { connection.close(); connection = null; secure = true; start = 8; int end = location.indexOf('/', start); host = location.substring(start, end); int ci = host.lastIndexOf(':'); if (ci != -1) { port = Integer.parseInt(host.substring (ci + 1)); host = host.substring(0, ci); } else { port = HTTPConnection.HTTPS_PORT; } file = location.substring(end); retry = true; } else if (location.length() > 0) { // Malformed absolute URI, treat as file part of URI if (location.charAt(0) == '/') { // Absolute path file = location; } else { // Relative path int lsi = file.lastIndexOf('/'); file = (lsi == -1) ? "/" : file.substring(0, lsi + 1); file += location; } retry = true; } } } else { responseSink = response.getBody(); if (response.getCode() == 404) { errorSink = responseSink; throw new FileNotFoundException(url.toString()); } } } while (retry); connected = true; }
focusColor = getFocusColor(); selectColor = getSelectColor(); disabledTextColor = getDisabledTextColor();
public MetalToggleButtonUI() { super(); }
public AddressPcEntry(int pc, int offset) {
public AddressPcEntry(VmMethod method, int pc, int offset) { this.method = method;
public AddressPcEntry(int pc, int offset) { this.pc = pc; this.offset = offset; }
public void add(int pc, int offset) {
public void add(VmMethod method, int pc, int offset) {
public void add(int pc, int offset) { if (table != null) { throw new RuntimeException( "Address table is locked"); } final AddressPcEntry entry = new AddressPcEntry(pc, offset); if (list == null) { list = entry; } else { // Sort on offset (from low to high) if (offset < list.offset) { entry.next = list; list = entry; } else { AddressPcEntry p = list; while ((p.next != null) && (offset > p.next.offset)) { p = p.next; } entry.next = p.next; p.next = entry; } } }
final AddressPcEntry entry = new AddressPcEntry(pc, offset);
final AddressPcEntry entry = new AddressPcEntry(method, pc, offset);
public void add(int pc, int offset) { if (table != null) { throw new RuntimeException( "Address table is locked"); } final AddressPcEntry entry = new AddressPcEntry(pc, offset); if (list == null) { list = entry; } else { // Sort on offset (from low to high) if (offset < list.offset) { entry.next = list; list = entry; } else { AddressPcEntry p = list; while ((p.next != null) && (offset > p.next.offset)) { p = p.next; } entry.next = p.next; p.next = entry; } } }
final int[] table = new int[ count * 2];
final int[] table = new int[ count * 3]; this.methodTable = (VmMethod[]) methods.toArray(new VmMethod[ methods .size()]);
final void lock() { AddressPcEntry p = list; int count = 0; while (p != null) { count++; p = p.next; } final int[] table = new int[ count * 2]; p = list; int i = 0; int lastOffset = -1; while (p != null) { table[ i + 0] = p.pc; table[ i + 1] = p.offset; if (p.offset < lastOffset) { throw new VirtualMachineError( "unordered offset found"); } lastOffset = p.offset; i += 2; p = p.next; } this.table = table; this.list = null; }
table[ i + 0] = p.pc; table[ i + 1] = p.offset;
table[ i + 0] = methods.indexOf(p.method); table[ i + 1] = p.pc; table[ i + 2] = p.offset;
final void lock() { AddressPcEntry p = list; int count = 0; while (p != null) { count++; p = p.next; } final int[] table = new int[ count * 2]; p = list; int i = 0; int lastOffset = -1; while (p != null) { table[ i + 0] = p.pc; table[ i + 1] = p.offset; if (p.offset < lastOffset) { throw new VirtualMachineError( "unordered offset found"); } lastOffset = p.offset; i += 2; p = p.next; } this.table = table; this.list = null; }
i += 2;
i += 3;
final void lock() { AddressPcEntry p = list; int count = 0; while (p != null) { count++; p = p.next; } final int[] table = new int[ count * 2]; p = list; int i = 0; int lastOffset = -1; while (p != null) { table[ i + 0] = p.pc; table[ i + 1] = p.offset; if (p.offset < lastOffset) { throw new VirtualMachineError( "unordered offset found"); } lastOffset = p.offset; i += 2; p = p.next; } this.table = table; this.list = null; }
for (int i = 0; i < table.length; i += 2) { final int pc = table[ i + 0]; final int offset = table[ i + 1];
for (int i = 0; i < table.length; i += 3) { final int methodIdx = table[ i + 0]; final int pc = table[ i + 1]; final int offset = table[ i + 2];
public void writeTo(PrintStream out) { for (int i = 0; i < table.length; i += 2) { final int pc = table[ i + 0]; final int offset = table[ i + 1]; out.println("PC[" + pc + "]\t0x" + NumberUtils.hex(offset)); } }
out.println("PC[" + pc + "]\t0x" + NumberUtils.hex(offset));
out.println(methodTable[ methodIdx].getName() + ", pc[" + pc + "]\t0x" + NumberUtils.hex(offset));
public void writeTo(PrintStream out) { for (int i = 0; i < table.length; i += 2) { final int pc = table[ i + 0]; final int offset = table[ i + 1]; out.println("PC[" + pc + "]\t0x" + NumberUtils.hex(offset)); } }
if (a0 < 0) {
if (a0 == 0) {
public static int const0(int a0, int a1) { int l0 = 0; if (a0 < 0) { l0 = -1; } if (a0 > 0) { l0 = 1; } return l0; }
if ("const1".equals(method.getName())) {
if ("terniary".equals(method.getName())) {
private static VmByteCode loadByteCode(String className) throws MalformedURLException, ClassNotFoundException { VmSystemClassLoader vmc = new VmSystemClassLoader(new File(".").toURL(), new VmX86Architecture()); VmType type = vmc.loadClass(className, true); VmMethod arithMethod = null; int nMethods = type.getNoDeclaredMethods(); for (int i=0; i<nMethods; i+=1) { VmMethod method = type.getDeclaredMethod(i); if ("const1".equals(method.getName())) { arithMethod = method; break; } } VmByteCode code = arithMethod.getBytecode(); return code; }
if (toAppend != null && toAppend.length() > 0) revalidate();
public void append(String toAppend) { try { getDocument().insertString(getText().length(), toAppend, null); } catch (BadLocationException exception) { /* This shouldn't happen in theory -- but, if it does... */ throw new RuntimeException("Unexpected exception occurred.", exception); } }
return VMSecurityManager.currentClassLoader();
Class cl = currentLoadedClass(); return cl != null ? cl.getClassLoader() : null;
protected ClassLoader currentClassLoader() { return VMSecurityManager.currentClassLoader(); }
return VMSecurityManager.getClassContext();
Class[] stack1 = VMStackWalker.getClassContext(); Class[] stack2 = new Class[stack1.length - 1]; System.arraycopy(stack1, 1, stack2, 0, stack1.length - 1); return stack2;
protected Class[] getClassContext() { return VMSecurityManager.getClassContext(); }
int type = getDataType( locator ); if (type != DOUBLE_DATA_TYPE) { throw new SetDataException ("The target dataCell is not a String"); }
public void appendData (Locator locator, String stringValue) throws SetDataException { String strData; try { strData = getStringData(locator); strData += stringValue; } catch (NoDataException e) { strData = stringValue; } setData(locator, strData); }
} else if (type == SHORT_DATA_TYPE) { longDataArray.set(longIndex+1, new short [shortAxisSize]); } else if (type == LONG_DATA_TYPE) { longDataArray.set(longIndex+1, new long [shortAxisSize]);
private void checkDataArrayBounds (int longIndex, int shortIndex, int type) throws SetDataException { if (shortIndex < 0 || longIndex < 0) { throw new SetDataException("Cant set data: passed locator/axes dont belong to this array?"); } // Does the location exist yet? If not, create the primative arrays // that lie along the short axis // int shortAxisSize = getShortAxis().getLength(); int shortAxisSize = parentArray.getShortAxisSize(); if (shortAxisSize < 1) { shortAxisSize = 1; } // is the long array too small? if (longDataArray.size() < (longIndex+1)) { int maxDeclLongArraySize = getMaxLongArraySize(); // should be held in private var int expandSize = longIndex > maxDeclLongArraySize ? longIndex : maxDeclLongArraySize; expandSize *= expandFactor; // add in additional amount to prevent us from doing this too much expandLongArray(expandSize); } // is the short array too small? has it been init'd even yet? // we perform checks here.. if (longDataArray.get(longIndex) == null) { // init/create the short array longDataArray.set( longIndex, new byte[shortAxisSize]); if (type == DOUBLE_DATA_TYPE) { longDataArray.set(longIndex+1, new double [shortAxisSize]); } else if (type == INT_DATA_TYPE) { longDataArray.set(longIndex+1, new int [shortAxisSize]); } else if (type == BYTE_DATA_TYPE) { longDataArray.set(longIndex+1, new byte [shortAxisSize]); } else if (type == SHORT_DATA_TYPE) { longDataArray.set(longIndex+1, new short [shortAxisSize]); } else if (type == LONG_DATA_TYPE) { longDataArray.set(longIndex+1, new long [shortAxisSize]); } else if (type == STRING_DATA_TYPE) { longDataArray.set(longIndex+1, new String [shortAxisSize]); } } else { int currentShortAxisSize = getLongDataArraySize(longIndex, type); // requested short axis location not exist? if (currentShortAxisSize <= shortIndex) { // should flag the user that need to add AxisValue first if (shortIndex > shortAxisSize) { throw new SetDataException("Error: axis lacks an AxisValue at location requested in setData()."); } else { // add in short axis location to local short array(s) int newsize = shortIndex+1; // need to add one for case of 1-D newsize *= expandFactor; // expand short axis by expandFactor // Log.debugln("Expanding short array at longIndex:"+longIndex+" to "+newsize); longDataArray.set(longIndex, expandArray((byte []) longDataArray.get(longIndex), newsize)); if (type == DOUBLE_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((double[]) longDataArray.get(longIndex+1), newsize)); } else if (type == INT_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((int[]) longDataArray.get(longIndex+1), newsize)); } else if (type == BYTE_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((byte[]) longDataArray.get(longIndex+1), newsize)); } else if (type == SHORT_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((short[]) longDataArray.get(longIndex+1), newsize)); } else if (type == LONG_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((long []) longDataArray.get(longIndex+1), newsize)); } else if (type == STRING_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((String []) longDataArray.get(longIndex+1), newsize)); } } } } }
} else if (type == SHORT_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((short[]) longDataArray.get(longIndex+1), newsize)); } else if (type == LONG_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((long []) longDataArray.get(longIndex+1), newsize));
private void checkDataArrayBounds (int longIndex, int shortIndex, int type) throws SetDataException { if (shortIndex < 0 || longIndex < 0) { throw new SetDataException("Cant set data: passed locator/axes dont belong to this array?"); } // Does the location exist yet? If not, create the primative arrays // that lie along the short axis // int shortAxisSize = getShortAxis().getLength(); int shortAxisSize = parentArray.getShortAxisSize(); if (shortAxisSize < 1) { shortAxisSize = 1; } // is the long array too small? if (longDataArray.size() < (longIndex+1)) { int maxDeclLongArraySize = getMaxLongArraySize(); // should be held in private var int expandSize = longIndex > maxDeclLongArraySize ? longIndex : maxDeclLongArraySize; expandSize *= expandFactor; // add in additional amount to prevent us from doing this too much expandLongArray(expandSize); } // is the short array too small? has it been init'd even yet? // we perform checks here.. if (longDataArray.get(longIndex) == null) { // init/create the short array longDataArray.set( longIndex, new byte[shortAxisSize]); if (type == DOUBLE_DATA_TYPE) { longDataArray.set(longIndex+1, new double [shortAxisSize]); } else if (type == INT_DATA_TYPE) { longDataArray.set(longIndex+1, new int [shortAxisSize]); } else if (type == BYTE_DATA_TYPE) { longDataArray.set(longIndex+1, new byte [shortAxisSize]); } else if (type == SHORT_DATA_TYPE) { longDataArray.set(longIndex+1, new short [shortAxisSize]); } else if (type == LONG_DATA_TYPE) { longDataArray.set(longIndex+1, new long [shortAxisSize]); } else if (type == STRING_DATA_TYPE) { longDataArray.set(longIndex+1, new String [shortAxisSize]); } } else { int currentShortAxisSize = getLongDataArraySize(longIndex, type); // requested short axis location not exist? if (currentShortAxisSize <= shortIndex) { // should flag the user that need to add AxisValue first if (shortIndex > shortAxisSize) { throw new SetDataException("Error: axis lacks an AxisValue at location requested in setData()."); } else { // add in short axis location to local short array(s) int newsize = shortIndex+1; // need to add one for case of 1-D newsize *= expandFactor; // expand short axis by expandFactor // Log.debugln("Expanding short array at longIndex:"+longIndex+" to "+newsize); longDataArray.set(longIndex, expandArray((byte []) longDataArray.get(longIndex), newsize)); if (type == DOUBLE_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((double[]) longDataArray.get(longIndex+1), newsize)); } else if (type == INT_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((int[]) longDataArray.get(longIndex+1), newsize)); } else if (type == BYTE_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((byte[]) longDataArray.get(longIndex+1), newsize)); } else if (type == SHORT_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((short[]) longDataArray.get(longIndex+1), newsize)); } else if (type == LONG_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((long []) longDataArray.get(longIndex+1), newsize)); } else if (type == STRING_DATA_TYPE) { longDataArray.set(longIndex+1, expandArray((String []) longDataArray.get(longIndex+1), newsize)); } } } } }
public Object getData (Locator locator) throws NoDataException
public Object getData (Locator locator) throws NoDataException, IllegalArgumentException
public Object getData (Locator locator) throws NoDataException { int longIndex = parentArray.getLongArrayIndex(locator); int shortIndex = parentArray.getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.get(longDataArray.get(longIndex+1), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
} catch (Exception e) {
} catch (IllegalArgumentException iae) { throw new IllegalArgumentException(); } catch (Exception e) {
public Object getData (Locator locator) throws NoDataException { int longIndex = parentArray.getLongArrayIndex(locator); int shortIndex = parentArray.getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.get(longDataArray.get(longIndex+1), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
throws NoDataException
throws NoDataException, IllegalArgumentException
public double getDoubleData (Locator locator) throws NoDataException { int longIndex = parentArray.getLongArrayIndex(locator); int shortIndex = parentArray.getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getDouble(longDataArray.get(longIndex+1), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
} catch (Exception e) {
} catch (IllegalArgumentException iae) { throw new IllegalArgumentException(); } catch (Exception e) {
public double getDoubleData (Locator locator) throws NoDataException { int longIndex = parentArray.getLongArrayIndex(locator); int shortIndex = parentArray.getShortArrayIndex(locator); try { if (java.lang.reflect.Array.getByte(longDataArray.get(longIndex), shortIndex) !=1) throw new NoDataException(); //the location we try to access contains noDataValue return java.lang.reflect.Array.getDouble(longDataArray.get(longIndex+1), shortIndex); } catch (Exception e) { //the location we try to access is not allocated, //i.e., no data in the cell throw new NoDataException(); } }
} else if (type == SHORT_DATA_TYPE) { size = ((short []) longDataArray.get(longIndex+1)).length; } else if (type == LONG_DATA_TYPE) { size = ((long []) longDataArray.get(longIndex+1)).length;
private int getLongDataArraySize (int longIndex, int type) { int size = 0; if (type == DOUBLE_DATA_TYPE) { size = ((double[]) longDataArray.get(longIndex+1)).length; } else if (type == INT_DATA_TYPE) { size = ((int []) longDataArray.get(longIndex+1)).length; } else if (type == BYTE_DATA_TYPE) { size = ((byte []) longDataArray.get(longIndex+1)).length; } else if (type == SHORT_DATA_TYPE) { size = ((short []) longDataArray.get(longIndex+1)).length; } else if (type == LONG_DATA_TYPE) { size = ((long []) longDataArray.get(longIndex+1)).length; } else if (type == STRING_DATA_TYPE) { size = ((String []) longDataArray.get(longIndex+1)).length; } return size; }
JLabel fieldsLabel = new JLabel(LangTool.getString("xtfr.labelFields"));
fieldsLabel = new JLabel(LangTool.getString("xtfr.labelFields"));
private void initXTFRInfo() { // create some reusable borders and layouts BorderLayout borderLayout = new BorderLayout(); Border emptyBorder = BorderFactory.createEmptyBorder(10, 10, 0, 10); // main panel JPanel mp = new JPanel(); mp.setLayout(borderLayout); // system panel JPanel sp = new JPanel(); sp.setLayout(new BorderLayout()); sp.setBorder(emptyBorder); // host panel for as400 as400p = new JPanel(); as400p.setBorder( BorderFactory.createTitledBorder( LangTool.getString("xtfr.labelAS400"))); as400p.setLayout(new GridBagLayout()); JLabel snpLabel = new JLabel(LangTool.getString("xtfr.labelSystemName")); systemName = new JTextField(vt.getHostName()); systemName.setColumns(30); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy =0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(snpLabel, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 10); as400p.add(systemName,gbc); JLabel hfnpLabel = new JLabel(LangTool.getString("xtfr.labelHostFile")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(hfnpLabel, gbc); hostFile = new JTextField(); hostFile.setColumns(30); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 10); as400p.add(hostFile, gbc); JLabel idpLabel = new JLabel(LangTool.getString("xtfr.labelUserId")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(idpLabel, gbc); user = new JTextField(); user.setColumns(15); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 5); as400p.add(user, gbc); // password panel JLabel pwpLabel = new JLabel(LangTool.getString("xtfr.labelPassword")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 3; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(pwpLabel, gbc); password = new JPasswordField(); password.setColumns(15); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 3; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 5); as400p.add(password, gbc); // Query Wizard useQuery = new JCheckBox(LangTool.getString("xtfr.labelUseQuery")); useQuery.addItemListener(this); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 4; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(useQuery, gbc); //query button queryWizard = new JButton(LangTool.getString("xtfr.labelQueryWizard")); queryWizard.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { startWizard(); } }); queryWizard.setEnabled(false); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 4; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 0, 5); as400p.add(queryWizard, gbc); // Field Selection panel JLabel fieldsLabel = new JLabel(LangTool.getString("xtfr.labelFields")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 5; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(fieldsLabel, gbc); allFields = new JRadioButton(LangTool.getString("xtfr.labelAllFields")); allFields.setSelected(true); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 5; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 0, 5); as400p.add(allFields, gbc); selectedFields = new JRadioButton(LangTool.getString("xtfr.labelSelectedFields")); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 5; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 0, 10); as400p.add(selectedFields, gbc); ButtonGroup fieldGroup = new ButtonGroup(); fieldGroup.add(allFields); fieldGroup.add(selectedFields); // Field Text Description panel JLabel textDescLabel = new JLabel(LangTool.getString("xtfr.labelTxtDesc")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 6; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(textDescLabel, gbc); txtDesc = new JRadioButton(LangTool.getString("xtfr.labelTxtDescFull")); txtDesc.setSelected(true); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 6; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 5, 5); as400p.add(txtDesc, gbc); intDesc = new JRadioButton(LangTool.getString("xtfr.labelTxtDescInt")); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 6; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 5, 10); as400p.add(intDesc, gbc); ButtonGroup txtDescGroup = new ButtonGroup(); txtDescGroup.add(txtDesc); txtDescGroup.add(intDesc); // pc panel for pc information JPanel pcp = new JPanel(new GridBagLayout()); pcp.setBorder( BorderFactory.createTitledBorder( LangTool.getString("xtfr.labelpc"))); JLabel pffLabel = new JLabel(LangTool.getString("xtfr.labelFileFormat")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); pcp.add(pffLabel, gbc); fileFormat = new JComboBox(); fileFormat.setPreferredSize(new Dimension(220, 25)); fileFormat.addItem(htmlFilter.getDescription()); fileFormat.addItem(OOFilter.getDescription()); fileFormat.addItem(ExcelFilter.getDescription()); fileFormat.addItem(KSpreadFilter.getDescription()); fileFormat.addItem(DelimitedFilter.getDescription()); fileFormat.addItem(FixedWidthFilter.getDescription()); fileFormat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); filter = getFilterByDescription(); if (filter.getOutputFilterInstance().isCustomizable()) customize.setEnabled(true); else customize.setEnabled(false); } }); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(0, 5, 0, 5); pcp.add(fileFormat, gbc); customize = new JButton(LangTool.getString("xtfr.labelCustomize")); customize.setPreferredSize(new Dimension(110, 25)); customize.setActionCommand("CUSTOMIZE"); customize.addActionListener(this); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(0, 5, 0, 10); pcp.add(customize, gbc); // now make sure we set the customizable button enabled or not // depending on the filter. fileFormat.setSelectedIndex(0); JLabel pcpLabel = new JLabel(LangTool.getString("xtfr.labelPCFile")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); pcp.add(pcpLabel, gbc); localFile = new JTextField(); localFile.setColumns(15); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 0, 5); pcp.add(localFile, gbc); JButton browsePC = new JButton(LangTool.getString("xtfr.labelPCBrowse")); browsePC.setActionCommand("BROWSEPC"); browsePC.addActionListener(this); browsePC.setPreferredSize(new Dimension(110, 25)); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 0, 10); pcp.add(browsePC, gbc); decimalSeparator = new JComboBox(); decimalSeparator.setPreferredSize(new Dimension(220, 25)); decimalSeparator.addItem(LangTool.getString("xtfr.period")); decimalSeparator.addItem(LangTool.getString("xtfr.comma")); // obtain the decimal separator for the machine locale DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.getDefault()); if (formatter.getDecimalFormatSymbols().getDecimalSeparator() == '.') decimalSeparator.setSelectedIndex(0); else decimalSeparator.setSelectedIndex(1); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 10, 5); pcp.add(new JLabel(LangTool.getString("xtfr.labelDecimal")), gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 5, 5); pcp.add(decimalSeparator, gbc); sp.add(as400p, BorderLayout.NORTH); sp.add(pcp, BorderLayout.SOUTH); // options panel JPanel op = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); JButton xtfrButton = new JButton(LangTool.getString("xtfr.labelXTFR")); xtfrButton.addActionListener(this); xtfrButton.setActionCommand("XTFR"); op.add(xtfrButton); JButton emailButton = new JButton(LangTool.getString("xtfr.labelXTFREmail")); emailButton.addActionListener(this); emailButton.setActionCommand("EMAIL"); op.add(emailButton); mp.add(sp, BorderLayout.CENTER); mp.add(op, BorderLayout.SOUTH); this.getContentPane().add(mp, BorderLayout.CENTER); // this.setModal(false); // this.setModal(true); this.setTitle(LangTool.getString("xtfr.title")); initXTFRFields(); // pack it and center it on the screen pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize(); if (frameSize.height > screenSize.height) frameSize.height = screenSize.height; if (frameSize.width > screenSize.width) frameSize.width = screenSize.width; setLocation( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); //QueryPanel when Use Query selected as400QueryP = new JPanel(); as400QueryP.setLayout(new BorderLayout()); queryStatement = new JTextArea(5, 40); JScrollPane scrollPane = new JScrollPane(queryStatement); queryStatement.setLineWrap(true); as400QueryP.add(scrollPane, BorderLayout.CENTER); as400FieldP = new JPanel(); AlignLayout as400fLayout = new AlignLayout(); as400FieldP.setLayout(as400fLayout); // now show the world what we can do show(); }
JLabel textDescLabel =
textDescLabel =
private void initXTFRInfo() { // create some reusable borders and layouts BorderLayout borderLayout = new BorderLayout(); Border emptyBorder = BorderFactory.createEmptyBorder(10, 10, 0, 10); // main panel JPanel mp = new JPanel(); mp.setLayout(borderLayout); // system panel JPanel sp = new JPanel(); sp.setLayout(new BorderLayout()); sp.setBorder(emptyBorder); // host panel for as400 as400p = new JPanel(); as400p.setBorder( BorderFactory.createTitledBorder( LangTool.getString("xtfr.labelAS400"))); as400p.setLayout(new GridBagLayout()); JLabel snpLabel = new JLabel(LangTool.getString("xtfr.labelSystemName")); systemName = new JTextField(vt.getHostName()); systemName.setColumns(30); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy =0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(snpLabel, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 10); as400p.add(systemName,gbc); JLabel hfnpLabel = new JLabel(LangTool.getString("xtfr.labelHostFile")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(hfnpLabel, gbc); hostFile = new JTextField(); hostFile.setColumns(30); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 10); as400p.add(hostFile, gbc); JLabel idpLabel = new JLabel(LangTool.getString("xtfr.labelUserId")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(idpLabel, gbc); user = new JTextField(); user.setColumns(15); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 5); as400p.add(user, gbc); // password panel JLabel pwpLabel = new JLabel(LangTool.getString("xtfr.labelPassword")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 3; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(pwpLabel, gbc); password = new JPasswordField(); password.setColumns(15); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 3; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 5); as400p.add(password, gbc); // Query Wizard useQuery = new JCheckBox(LangTool.getString("xtfr.labelUseQuery")); useQuery.addItemListener(this); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 4; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(useQuery, gbc); //query button queryWizard = new JButton(LangTool.getString("xtfr.labelQueryWizard")); queryWizard.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { startWizard(); } }); queryWizard.setEnabled(false); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 4; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 0, 5); as400p.add(queryWizard, gbc); // Field Selection panel JLabel fieldsLabel = new JLabel(LangTool.getString("xtfr.labelFields")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 5; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(fieldsLabel, gbc); allFields = new JRadioButton(LangTool.getString("xtfr.labelAllFields")); allFields.setSelected(true); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 5; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 0, 5); as400p.add(allFields, gbc); selectedFields = new JRadioButton(LangTool.getString("xtfr.labelSelectedFields")); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 5; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 0, 10); as400p.add(selectedFields, gbc); ButtonGroup fieldGroup = new ButtonGroup(); fieldGroup.add(allFields); fieldGroup.add(selectedFields); // Field Text Description panel JLabel textDescLabel = new JLabel(LangTool.getString("xtfr.labelTxtDesc")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 6; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(textDescLabel, gbc); txtDesc = new JRadioButton(LangTool.getString("xtfr.labelTxtDescFull")); txtDesc.setSelected(true); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 6; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 5, 5); as400p.add(txtDesc, gbc); intDesc = new JRadioButton(LangTool.getString("xtfr.labelTxtDescInt")); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 6; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 5, 10); as400p.add(intDesc, gbc); ButtonGroup txtDescGroup = new ButtonGroup(); txtDescGroup.add(txtDesc); txtDescGroup.add(intDesc); // pc panel for pc information JPanel pcp = new JPanel(new GridBagLayout()); pcp.setBorder( BorderFactory.createTitledBorder( LangTool.getString("xtfr.labelpc"))); JLabel pffLabel = new JLabel(LangTool.getString("xtfr.labelFileFormat")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); pcp.add(pffLabel, gbc); fileFormat = new JComboBox(); fileFormat.setPreferredSize(new Dimension(220, 25)); fileFormat.addItem(htmlFilter.getDescription()); fileFormat.addItem(OOFilter.getDescription()); fileFormat.addItem(ExcelFilter.getDescription()); fileFormat.addItem(KSpreadFilter.getDescription()); fileFormat.addItem(DelimitedFilter.getDescription()); fileFormat.addItem(FixedWidthFilter.getDescription()); fileFormat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); filter = getFilterByDescription(); if (filter.getOutputFilterInstance().isCustomizable()) customize.setEnabled(true); else customize.setEnabled(false); } }); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(0, 5, 0, 5); pcp.add(fileFormat, gbc); customize = new JButton(LangTool.getString("xtfr.labelCustomize")); customize.setPreferredSize(new Dimension(110, 25)); customize.setActionCommand("CUSTOMIZE"); customize.addActionListener(this); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(0, 5, 0, 10); pcp.add(customize, gbc); // now make sure we set the customizable button enabled or not // depending on the filter. fileFormat.setSelectedIndex(0); JLabel pcpLabel = new JLabel(LangTool.getString("xtfr.labelPCFile")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); pcp.add(pcpLabel, gbc); localFile = new JTextField(); localFile.setColumns(15); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 0, 5); pcp.add(localFile, gbc); JButton browsePC = new JButton(LangTool.getString("xtfr.labelPCBrowse")); browsePC.setActionCommand("BROWSEPC"); browsePC.addActionListener(this); browsePC.setPreferredSize(new Dimension(110, 25)); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 0, 10); pcp.add(browsePC, gbc); decimalSeparator = new JComboBox(); decimalSeparator.setPreferredSize(new Dimension(220, 25)); decimalSeparator.addItem(LangTool.getString("xtfr.period")); decimalSeparator.addItem(LangTool.getString("xtfr.comma")); // obtain the decimal separator for the machine locale DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.getDefault()); if (formatter.getDecimalFormatSymbols().getDecimalSeparator() == '.') decimalSeparator.setSelectedIndex(0); else decimalSeparator.setSelectedIndex(1); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 10, 5); pcp.add(new JLabel(LangTool.getString("xtfr.labelDecimal")), gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 5, 5); pcp.add(decimalSeparator, gbc); sp.add(as400p, BorderLayout.NORTH); sp.add(pcp, BorderLayout.SOUTH); // options panel JPanel op = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); JButton xtfrButton = new JButton(LangTool.getString("xtfr.labelXTFR")); xtfrButton.addActionListener(this); xtfrButton.setActionCommand("XTFR"); op.add(xtfrButton); JButton emailButton = new JButton(LangTool.getString("xtfr.labelXTFREmail")); emailButton.addActionListener(this); emailButton.setActionCommand("EMAIL"); op.add(emailButton); mp.add(sp, BorderLayout.CENTER); mp.add(op, BorderLayout.SOUTH); this.getContentPane().add(mp, BorderLayout.CENTER); // this.setModal(false); // this.setModal(true); this.setTitle(LangTool.getString("xtfr.title")); initXTFRFields(); // pack it and center it on the screen pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize(); if (frameSize.height > screenSize.height) frameSize.height = screenSize.height; if (frameSize.width > screenSize.width) frameSize.width = screenSize.width; setLocation( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); //QueryPanel when Use Query selected as400QueryP = new JPanel(); as400QueryP.setLayout(new BorderLayout()); queryStatement = new JTextArea(5, 40); JScrollPane scrollPane = new JScrollPane(queryStatement); queryStatement.setLineWrap(true); as400QueryP.add(scrollPane, BorderLayout.CENTER); as400FieldP = new JPanel(); AlignLayout as400fLayout = new AlignLayout(); as400FieldP.setLayout(as400fLayout); // now show the world what we can do show(); }
queryStatement = new JTextArea(5, 40);
queryStatement = new JTextArea(2, 40);
private void initXTFRInfo() { // create some reusable borders and layouts BorderLayout borderLayout = new BorderLayout(); Border emptyBorder = BorderFactory.createEmptyBorder(10, 10, 0, 10); // main panel JPanel mp = new JPanel(); mp.setLayout(borderLayout); // system panel JPanel sp = new JPanel(); sp.setLayout(new BorderLayout()); sp.setBorder(emptyBorder); // host panel for as400 as400p = new JPanel(); as400p.setBorder( BorderFactory.createTitledBorder( LangTool.getString("xtfr.labelAS400"))); as400p.setLayout(new GridBagLayout()); JLabel snpLabel = new JLabel(LangTool.getString("xtfr.labelSystemName")); systemName = new JTextField(vt.getHostName()); systemName.setColumns(30); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy =0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(snpLabel, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 10); as400p.add(systemName,gbc); JLabel hfnpLabel = new JLabel(LangTool.getString("xtfr.labelHostFile")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(hfnpLabel, gbc); hostFile = new JTextField(); hostFile.setColumns(30); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 10); as400p.add(hostFile, gbc); JLabel idpLabel = new JLabel(LangTool.getString("xtfr.labelUserId")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(idpLabel, gbc); user = new JTextField(); user.setColumns(15); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 5); as400p.add(user, gbc); // password panel JLabel pwpLabel = new JLabel(LangTool.getString("xtfr.labelPassword")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 3; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(pwpLabel, gbc); password = new JPasswordField(); password.setColumns(15); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 3; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 5); as400p.add(password, gbc); // Query Wizard useQuery = new JCheckBox(LangTool.getString("xtfr.labelUseQuery")); useQuery.addItemListener(this); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 4; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(useQuery, gbc); //query button queryWizard = new JButton(LangTool.getString("xtfr.labelQueryWizard")); queryWizard.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { startWizard(); } }); queryWizard.setEnabled(false); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 4; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 0, 5); as400p.add(queryWizard, gbc); // Field Selection panel JLabel fieldsLabel = new JLabel(LangTool.getString("xtfr.labelFields")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 5; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(fieldsLabel, gbc); allFields = new JRadioButton(LangTool.getString("xtfr.labelAllFields")); allFields.setSelected(true); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 5; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 0, 5); as400p.add(allFields, gbc); selectedFields = new JRadioButton(LangTool.getString("xtfr.labelSelectedFields")); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 5; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 0, 10); as400p.add(selectedFields, gbc); ButtonGroup fieldGroup = new ButtonGroup(); fieldGroup.add(allFields); fieldGroup.add(selectedFields); // Field Text Description panel JLabel textDescLabel = new JLabel(LangTool.getString("xtfr.labelTxtDesc")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 6; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(textDescLabel, gbc); txtDesc = new JRadioButton(LangTool.getString("xtfr.labelTxtDescFull")); txtDesc.setSelected(true); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 6; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 5, 5); as400p.add(txtDesc, gbc); intDesc = new JRadioButton(LangTool.getString("xtfr.labelTxtDescInt")); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 6; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 5, 10); as400p.add(intDesc, gbc); ButtonGroup txtDescGroup = new ButtonGroup(); txtDescGroup.add(txtDesc); txtDescGroup.add(intDesc); // pc panel for pc information JPanel pcp = new JPanel(new GridBagLayout()); pcp.setBorder( BorderFactory.createTitledBorder( LangTool.getString("xtfr.labelpc"))); JLabel pffLabel = new JLabel(LangTool.getString("xtfr.labelFileFormat")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); pcp.add(pffLabel, gbc); fileFormat = new JComboBox(); fileFormat.setPreferredSize(new Dimension(220, 25)); fileFormat.addItem(htmlFilter.getDescription()); fileFormat.addItem(OOFilter.getDescription()); fileFormat.addItem(ExcelFilter.getDescription()); fileFormat.addItem(KSpreadFilter.getDescription()); fileFormat.addItem(DelimitedFilter.getDescription()); fileFormat.addItem(FixedWidthFilter.getDescription()); fileFormat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); filter = getFilterByDescription(); if (filter.getOutputFilterInstance().isCustomizable()) customize.setEnabled(true); else customize.setEnabled(false); } }); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(0, 5, 0, 5); pcp.add(fileFormat, gbc); customize = new JButton(LangTool.getString("xtfr.labelCustomize")); customize.setPreferredSize(new Dimension(110, 25)); customize.setActionCommand("CUSTOMIZE"); customize.addActionListener(this); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(0, 5, 0, 10); pcp.add(customize, gbc); // now make sure we set the customizable button enabled or not // depending on the filter. fileFormat.setSelectedIndex(0); JLabel pcpLabel = new JLabel(LangTool.getString("xtfr.labelPCFile")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); pcp.add(pcpLabel, gbc); localFile = new JTextField(); localFile.setColumns(15); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 0, 5); pcp.add(localFile, gbc); JButton browsePC = new JButton(LangTool.getString("xtfr.labelPCBrowse")); browsePC.setActionCommand("BROWSEPC"); browsePC.addActionListener(this); browsePC.setPreferredSize(new Dimension(110, 25)); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 0, 10); pcp.add(browsePC, gbc); decimalSeparator = new JComboBox(); decimalSeparator.setPreferredSize(new Dimension(220, 25)); decimalSeparator.addItem(LangTool.getString("xtfr.period")); decimalSeparator.addItem(LangTool.getString("xtfr.comma")); // obtain the decimal separator for the machine locale DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.getDefault()); if (formatter.getDecimalFormatSymbols().getDecimalSeparator() == '.') decimalSeparator.setSelectedIndex(0); else decimalSeparator.setSelectedIndex(1); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 10, 5); pcp.add(new JLabel(LangTool.getString("xtfr.labelDecimal")), gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 5, 5); pcp.add(decimalSeparator, gbc); sp.add(as400p, BorderLayout.NORTH); sp.add(pcp, BorderLayout.SOUTH); // options panel JPanel op = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); JButton xtfrButton = new JButton(LangTool.getString("xtfr.labelXTFR")); xtfrButton.addActionListener(this); xtfrButton.setActionCommand("XTFR"); op.add(xtfrButton); JButton emailButton = new JButton(LangTool.getString("xtfr.labelXTFREmail")); emailButton.addActionListener(this); emailButton.setActionCommand("EMAIL"); op.add(emailButton); mp.add(sp, BorderLayout.CENTER); mp.add(op, BorderLayout.SOUTH); this.getContentPane().add(mp, BorderLayout.CENTER); // this.setModal(false); // this.setModal(true); this.setTitle(LangTool.getString("xtfr.title")); initXTFRFields(); // pack it and center it on the screen pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize(); if (frameSize.height > screenSize.height) frameSize.height = screenSize.height; if (frameSize.width > screenSize.width) frameSize.width = screenSize.width; setLocation( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); //QueryPanel when Use Query selected as400QueryP = new JPanel(); as400QueryP.setLayout(new BorderLayout()); queryStatement = new JTextArea(5, 40); JScrollPane scrollPane = new JScrollPane(queryStatement); queryStatement.setLineWrap(true); as400QueryP.add(scrollPane, BorderLayout.CENTER); as400FieldP = new JPanel(); AlignLayout as400fLayout = new AlignLayout(); as400FieldP.setLayout(as400fLayout); // now show the world what we can do show(); }
as400FieldP = new JPanel(); AlignLayout as400fLayout = new AlignLayout(); as400FieldP.setLayout(as400fLayout);
private void initXTFRInfo() { // create some reusable borders and layouts BorderLayout borderLayout = new BorderLayout(); Border emptyBorder = BorderFactory.createEmptyBorder(10, 10, 0, 10); // main panel JPanel mp = new JPanel(); mp.setLayout(borderLayout); // system panel JPanel sp = new JPanel(); sp.setLayout(new BorderLayout()); sp.setBorder(emptyBorder); // host panel for as400 as400p = new JPanel(); as400p.setBorder( BorderFactory.createTitledBorder( LangTool.getString("xtfr.labelAS400"))); as400p.setLayout(new GridBagLayout()); JLabel snpLabel = new JLabel(LangTool.getString("xtfr.labelSystemName")); systemName = new JTextField(vt.getHostName()); systemName.setColumns(30); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy =0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(snpLabel, gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 10); as400p.add(systemName,gbc); JLabel hfnpLabel = new JLabel(LangTool.getString("xtfr.labelHostFile")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(hfnpLabel, gbc); hostFile = new JTextField(); hostFile.setColumns(30); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 10); as400p.add(hostFile, gbc); JLabel idpLabel = new JLabel(LangTool.getString("xtfr.labelUserId")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(idpLabel, gbc); user = new JTextField(); user.setColumns(15); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 5); as400p.add(user, gbc); // password panel JLabel pwpLabel = new JLabel(LangTool.getString("xtfr.labelPassword")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 3; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(pwpLabel, gbc); password = new JPasswordField(); password.setColumns(15); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 3; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 5, 5, 5); as400p.add(password, gbc); // Query Wizard useQuery = new JCheckBox(LangTool.getString("xtfr.labelUseQuery")); useQuery.addItemListener(this); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 4; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(useQuery, gbc); //query button queryWizard = new JButton(LangTool.getString("xtfr.labelQueryWizard")); queryWizard.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { startWizard(); } }); queryWizard.setEnabled(false); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 4; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 0, 5); as400p.add(queryWizard, gbc); // Field Selection panel JLabel fieldsLabel = new JLabel(LangTool.getString("xtfr.labelFields")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 5; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(fieldsLabel, gbc); allFields = new JRadioButton(LangTool.getString("xtfr.labelAllFields")); allFields.setSelected(true); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 5; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 0, 5); as400p.add(allFields, gbc); selectedFields = new JRadioButton(LangTool.getString("xtfr.labelSelectedFields")); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 5; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 0, 10); as400p.add(selectedFields, gbc); ButtonGroup fieldGroup = new ButtonGroup(); fieldGroup.add(allFields); fieldGroup.add(selectedFields); // Field Text Description panel JLabel textDescLabel = new JLabel(LangTool.getString("xtfr.labelTxtDesc")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 6; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(textDescLabel, gbc); txtDesc = new JRadioButton(LangTool.getString("xtfr.labelTxtDescFull")); txtDesc.setSelected(true); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 6; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 5, 5); as400p.add(txtDesc, gbc); intDesc = new JRadioButton(LangTool.getString("xtfr.labelTxtDescInt")); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 6; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 5, 10); as400p.add(intDesc, gbc); ButtonGroup txtDescGroup = new ButtonGroup(); txtDescGroup.add(txtDesc); txtDescGroup.add(intDesc); // pc panel for pc information JPanel pcp = new JPanel(new GridBagLayout()); pcp.setBorder( BorderFactory.createTitledBorder( LangTool.getString("xtfr.labelpc"))); JLabel pffLabel = new JLabel(LangTool.getString("xtfr.labelFileFormat")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); pcp.add(pffLabel, gbc); fileFormat = new JComboBox(); fileFormat.setPreferredSize(new Dimension(220, 25)); fileFormat.addItem(htmlFilter.getDescription()); fileFormat.addItem(OOFilter.getDescription()); fileFormat.addItem(ExcelFilter.getDescription()); fileFormat.addItem(KSpreadFilter.getDescription()); fileFormat.addItem(DelimitedFilter.getDescription()); fileFormat.addItem(FixedWidthFilter.getDescription()); fileFormat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); filter = getFilterByDescription(); if (filter.getOutputFilterInstance().isCustomizable()) customize.setEnabled(true); else customize.setEnabled(false); } }); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(0, 5, 0, 5); pcp.add(fileFormat, gbc); customize = new JButton(LangTool.getString("xtfr.labelCustomize")); customize.setPreferredSize(new Dimension(110, 25)); customize.setActionCommand("CUSTOMIZE"); customize.addActionListener(this); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(0, 5, 0, 10); pcp.add(customize, gbc); // now make sure we set the customizable button enabled or not // depending on the filter. fileFormat.setSelectedIndex(0); JLabel pcpLabel = new JLabel(LangTool.getString("xtfr.labelPCFile")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); pcp.add(pcpLabel, gbc); localFile = new JTextField(); localFile.setColumns(15); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 0, 5); pcp.add(localFile, gbc); JButton browsePC = new JButton(LangTool.getString("xtfr.labelPCBrowse")); browsePC.setActionCommand("BROWSEPC"); browsePC.addActionListener(this); browsePC.setPreferredSize(new Dimension(110, 25)); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 0, 10); pcp.add(browsePC, gbc); decimalSeparator = new JComboBox(); decimalSeparator.setPreferredSize(new Dimension(220, 25)); decimalSeparator.addItem(LangTool.getString("xtfr.period")); decimalSeparator.addItem(LangTool.getString("xtfr.comma")); // obtain the decimal separator for the machine locale DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.getDefault()); if (formatter.getDecimalFormatSymbols().getDecimalSeparator() == '.') decimalSeparator.setSelectedIndex(0); else decimalSeparator.setSelectedIndex(1); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 10, 5); pcp.add(new JLabel(LangTool.getString("xtfr.labelDecimal")), gbc); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 5, 5, 5); pcp.add(decimalSeparator, gbc); sp.add(as400p, BorderLayout.NORTH); sp.add(pcp, BorderLayout.SOUTH); // options panel JPanel op = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); JButton xtfrButton = new JButton(LangTool.getString("xtfr.labelXTFR")); xtfrButton.addActionListener(this); xtfrButton.setActionCommand("XTFR"); op.add(xtfrButton); JButton emailButton = new JButton(LangTool.getString("xtfr.labelXTFREmail")); emailButton.addActionListener(this); emailButton.setActionCommand("EMAIL"); op.add(emailButton); mp.add(sp, BorderLayout.CENTER); mp.add(op, BorderLayout.SOUTH); this.getContentPane().add(mp, BorderLayout.CENTER); // this.setModal(false); // this.setModal(true); this.setTitle(LangTool.getString("xtfr.title")); initXTFRFields(); // pack it and center it on the screen pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize(); if (frameSize.height > screenSize.height) frameSize.height = screenSize.height; if (frameSize.width > screenSize.width) frameSize.width = screenSize.width; setLocation( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); //QueryPanel when Use Query selected as400QueryP = new JPanel(); as400QueryP.setLayout(new BorderLayout()); queryStatement = new JTextArea(5, 40); JScrollPane scrollPane = new JScrollPane(queryStatement); queryStatement.setLineWrap(true); as400QueryP.add(scrollPane, BorderLayout.CENTER); as400FieldP = new JPanel(); AlignLayout as400fLayout = new AlignLayout(); as400FieldP.setLayout(as400fLayout); // now show the world what we can do show(); }
as400p.remove(as400FieldP); as400p.add(as400QueryP, BorderLayout.SOUTH);
as400p.remove(fieldsLabel); as400p.remove(allFields); as400p.remove(selectedFields); as400p.remove(textDescLabel); as400p.remove(txtDesc); as400p.remove(intDesc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 5; gbc.gridheight = 2; gbc.gridwidth = 3; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 10, 10); as400p.add(as400QueryP, gbc);
public void itemStateChanged(ItemEvent e) { Object source = e.getItemSelectable(); if (source == useQuery) { if (useQuery.isSelected()) { queryWizard.setEnabled(true); as400p.remove(as400FieldP); as400p.add(as400QueryP, BorderLayout.SOUTH); } else { queryWizard.setEnabled(false); as400p.remove(as400QueryP); as400p.add(as400FieldP, BorderLayout.SOUTH); } this.validate(); this.repaint(); } }
as400p.add(as400FieldP, BorderLayout.SOUTH);
gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 5; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(fieldsLabel, gbc); allFields.setSelected(true); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 5; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 0, 5); as400p.add(allFields, gbc); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 5; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 0, 10); as400p.add(selectedFields, gbc); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 6; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(5, 10, 5, 5); as400p.add(textDescLabel, gbc); txtDesc.setSelected(true); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 6; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 5, 5); as400p.add(txtDesc, gbc); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 6; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(0, 5, 5, 10); as400p.add(intDesc, gbc);
public void itemStateChanged(ItemEvent e) { Object source = e.getItemSelectable(); if (source == useQuery) { if (useQuery.isSelected()) { queryWizard.setEnabled(true); as400p.remove(as400FieldP); as400p.add(as400QueryP, BorderLayout.SOUTH); } else { queryWizard.setEnabled(false); as400p.remove(as400QueryP); as400p.add(as400FieldP, BorderLayout.SOUTH); } this.validate(); this.repaint(); } }
moveToFront();
public void show() { if (! isVisible()) { moveToFront(); super.show(); JDesktopPane pane = getDesktopPane(); if (pane != null) pane.setSelectedFrame(this); else { try { setSelected(true); } catch (PropertyVetoException e) { // Do nothing. if they don't want to be selected. } } if (isFirstTimeVisible) { isFirstTimeVisible = false; fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_OPENED); } } }
cloneObj.fieldGroupOwnedHash.add(iter.next());
cloneObj.fieldGroupOwnedHash.add(((Group)iter.next()).clone());
public Object clone() throws CloneNotSupportedException { FieldAxis cloneObj = (FieldAxis) super.clone(); synchronized (this.fieldGroupOwnedHash) { synchronized(cloneObj.fieldGroupOwnedHash) { cloneObj.fieldGroupOwnedHash = Collections.synchronizedSet(new HashSet(this.fieldGroupOwnedHash.size())); Iterator iter = this.fieldGroupOwnedHash.iterator(); while (iter.hasNext()) { cloneObj.fieldGroupOwnedHash.add(iter.next()); } } } return cloneObj; }
darkShadowColor = MetalLookAndFeel.getControlDarkShadow(); highlightColor = MetalLookAndFeel.getControlHighlight();
public MetalSliderUI() { super(null); filledSlider = UIManager.getBoolean(SLIDER_FILL); }
return super.createPropertyChangeListener(slider);
return new MetalPropertyListener();
protected PropertyChangeListener createPropertyChangeListener(JSlider slider) { // TODO: try to figure out why it might be necessary to override this // method as is done in Sun's implementation return super.createPropertyChangeListener(slider); }
if (instances == null) instances = new HashMap(); Object o = instances.get(component); MetalSliderUI instance; if (o == null) { instance = new MetalSliderUI(); instances.put(component, instance); } else instance = (MetalSliderUI) o; return instance;
return new MetalSliderUI();
public static ComponentUI createUI(JComponent component) { if (instances == null) instances = new HashMap(); Object o = instances.get(component); MetalSliderUI instance; if (o == null) { instance = new MetalSliderUI(); instances.put(component, instance); } else instance = (MetalSliderUI) o; return instance; }
g.setColor(new Color(153, 153, 204));
if (slider.isEnabled()) g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); else g.setColor(MetalLookAndFeel.getControlDisabled());
protected void paintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) { // Note the incoming 'g' has a translation in place to get us to the // start of the tick rect already... // TODO: get color from UIManager... g.setColor(new Color(153, 153, 204)); g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + tickLength); }