bugged
stringlengths
6
599k
fixed
stringlengths
10
599k
__index_level_0__
int64
0
1.13M
public long getDate() { return (getHeaderFieldDate("date", 0)); }
public long getDate() { return (getHeaderFieldDate("date", 0)); }
1,002
public static boolean getDefaultAllowUserInteraction() { return (def_allow_user_inter); }
public static boolean getDefaultAllowUserInteraction() { return (def_allow_user_inter); }
1,003
public static String getDefaultRequestProperty(String key) { return ((String) def_req_props.get(key.toLowerCase())); }
public static String getDefaultRequestProperty(String key) { return ((String) def_req_props.get(key.toLowerCase())); }
1,004
public boolean getDefaultUseCaches() { return (def_use_caches); }
public boolean getDefaultUseCaches() { return (def_use_caches); }
1,005
public boolean getDoInput() { return (doInput); }
public boolean getDoInput() { return (doInput); }
1,006
public boolean getDoOutput() { return (doOutput); }
public boolean getDoOutput() { return (doOutput); }
1,007
public long getExpiration() { return (getHeaderFieldDate("expires", 0)); }
public long getExpiration() { return (getHeaderFieldDate("expires", 0)); }
1,008
public static FileNameMap getFileNameMap() { return (fileNameMap); }
public static FileNameMap getFileNameMap() { return (fileNameMap); }
1,009
public String getHeaderField(String name) { for (int i = 0;; i++) { String key = getHeaderFieldKey(i); if (key == null) return (null); if (key.toLowerCase().equals(name.toLowerCase())) return (getHeaderField(i)); } }
public String getHeaderField(String name) { for (int i = 0;; i++) { String key = getHeaderFieldKey(i); if (key == null) return (null); if (key.toLowerCase().equals(name.toLowerCase())) return (getHeaderField(i)); } }
1,010
public long getHeaderFieldDate(String key, long def) { String value = getHeaderField(key); if (value == null) return (def); // This needs to change since Date(String) is deprecated, but DateFormat // doesn't seem to be working for some reason //DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US); //df.setLenient(true); //Date d = df.parse(value, new ParsePosition(0)); Date d = new Date(value); if (d == null) return (def); return (d.getTime() / 1000); }
public long getHeaderFieldDate(String key, long def) { String value = getHeaderField(key); if (value == null) return (def); // This needs to change since Date(String) is deprecated, but DateFormat // doesn't seem to be working for some reason //DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US); //df.setLenient(true); //Date d = df.parse(value, new ParsePosition(0)); Date d = new Date(value); if (d == null) return (def); return (d.getTime() / 1000); }
1,011
public long getHeaderFieldDate(String key, long def) { String value = getHeaderField(key); if (value == null) return (def); // This needs to change since Date(String) is deprecated, but DateFormat // doesn't seem to be working for some reason //DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US); //df.setLenient(true); //Date d = df.parse(value, new ParsePosition(0)); Date d = new Date(value); if (d == null) return (def); return (d.getTime() / 1000); }
public long getHeaderFieldDate(String key, long def) { String value = getHeaderField(key); if (value == null) return (def); // This needs to change since Date(String) is deprecated, but DateFormat // doesn't seem to be working for some reason //DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US); //df.setLenient(true); //Date d = df.parse(value, new ParsePosition(0)); long result = defaultValue; String str = getHeaderField(name); if (d == null) return (def); return (d.getTime() / 1000); }
1,013
public long getHeaderFieldDate(String key, long def) { String value = getHeaderField(key); if (value == null) return (def); // This needs to change since Date(String) is deprecated, but DateFormat // doesn't seem to be working for some reason //DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US); //df.setLenient(true); //Date d = df.parse(value, new ParsePosition(0)); Date d = new Date(value); if (d == null) return (def); return (d.getTime() / 1000); }
public long getHeaderFieldDate(String key, long def) { String value = getHeaderField(key); if (value == null) return (def); // This needs to change since Date(String) is deprecated, but DateFormat // doesn't seem to be working for some reason //DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US); //df.setLenient(true); //Date d = df.parse(value, new ParsePosition(0)); Date d = new Date(value); if (d == null) return (def); return (d.getTime() / 1000); }
1,014
public long getHeaderFieldDate(String key, long def) { String value = getHeaderField(key); if (value == null) return (def); // This needs to change since Date(String) is deprecated, but DateFormat // doesn't seem to be working for some reason //DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US); //df.setLenient(true); //Date d = df.parse(value, new ParsePosition(0)); Date d = new Date(value); if (d == null) return (def); return (d.getTime() / 1000); }
public long getHeaderFieldDate(String key, long def) { String value = getHeaderField(key); if (value == null) return (def); // This needs to change since Date(String) is deprecated, but DateFormat // doesn't seem to be working for some reason //DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US); //df.setLenient(true); //Date d = df.parse(value, new ParsePosition(0)); Date d = new Date(value); if (d == null) return (def); return (d.getTime() / 1000); }
1,015
public int getHeaderFieldInt(String key, int def) { String value = getHeaderField(key); if (value == null) return (def); int retval = def; try { retval = Integer.parseInt(value); } catch (NumberFormatException e) { return (def); } return (retval); }
public int getHeaderFieldInt(String key, int def) { String value = getHeaderField(key); if (value == null) return (def); int retval = def; try { retval = Integer.parseInt(value); } catch (NumberFormatException e) { return (def); } return (retval); }
1,016
public int getHeaderFieldInt(String key, int def) { String value = getHeaderField(key); if (value == null) return (def); int retval = def; try { retval = Integer.parseInt(value); } catch (NumberFormatException e) { return (def); } return (retval); }
public int getHeaderFieldInt(String key, int def) { String value = getHeaderField(key); if (value == null) return (def); int retval = def; try { retval = Integer.parseInt(value); } catch (NumberFormatException e) { return (def); } return (retval); }
1,017
public int getHeaderFieldInt(String key, int def) { String value = getHeaderField(key); if (value == null) return (def); int retval = def; try { retval = Integer.parseInt(value); } catch (NumberFormatException e) { return (def); } return (retval); }
public int getHeaderFieldInt(String key, int def) { String value = getHeaderField(key); if (value == null) return (def); int retval = def; try { retval = Integer.parseInt(value); } catch (NumberFormatException e) { return (def); } try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; } }
1,018
public String getHeaderFieldKey(int index) { return (null); }
public String getHeaderFieldKey(int index) { return (null); }
1,019
public long getIfModifiedSince() { return (ifModifiedSince); }
public long getIfModifiedSince() { return (ifModifiedSince); }
1,020
public InputStream getInputStream() throws IOException { return (null); }
public InputStream getInputStream() throws IOException { return (null); }
1,021
public long getLastModified() { return (getHeaderFieldDate("last-modified", 0)); }
public long getLastModified() { return (getHeaderFieldDate("last-modified", 0)); }
1,022
public OutputStream getOutputStream() throws IOException { return (null); }
public OutputStream getOutputStream() throws IOException { return (null); }
1,023
public Permission getPermission() throws IOException { return (new java.security.AllPermission()); }
public Permission getPermission() throws IOException { return (new java.security.AllPermission()); }
1,024
public Map getRequestProperties() { return Collections.unmodifiableMap(req_props); }
public Map getRequestProperties() { return Collections.unmodifiableMap(req_props); }
1,025
public String getRequestProperty(String key) { return ((String) req_props.get(key.toLowerCase())); }
public String getRequestProperty(String key) { return ((String) req_props.get(key.toLowerCase())); }
1,026
public URL getURL() { return (url); }
public URL getURL() { return (url); }
1,027
public boolean getUseCaches() { return (useCaches); }
public boolean getUseCaches() { return (useCaches); }
1,028
public static String guessContentTypeFromName(String filename) { return (fileNameMap.getContentTypeFor(filename.toLowerCase())); }
public static String guessContentTypeFromName(String filename) { return (fileNameMap.getContentTypeFor(filename.toLowerCase())); }
1,029
public static String guessContentTypeFromStream(InputStream is) throws IOException { return ("application/octet-stream"); }
public static String guessContentTypeFromStream(InputStream is) throws IOException { return ("application/octet-stream"); }
1,030
public static synchronized void setContentHandlerFactory(ContentHandlerFactory fac) { if (factory != null) throw new Error("The ContentHandlerFactory is already set"); factory = fac; }
public static synchronized void setContentHandlerFactory(ContentHandlerFactory fac) { if (factory != null) throw new Error("The ContentHandlerFactory is already set"); factory = fac; }
1,031
public static synchronized void setContentHandlerFactory(ContentHandlerFactory fac) { if (factory != null) throw new Error("The ContentHandlerFactory is already set"); factory = fac; }
public static synchronized void setContentHandlerFactory(ContentHandlerFactory fac) { if (factory != null) throw new Error("The ContentHandlerFactory is already set"); SecurityManager s = System.getSecurityManager(); if (s != null) s.checkSetFactory(); URLConnection.factory = factory; }
1,032
public static synchronized void setDefaultAllowUserInteraction(boolean allow) { def_allow_user_inter = allow; }
public static synchronized void setDefaultAllowUserInteraction(boolean allow) { def_allow_user_inter = allow; }
1,033
public static synchronized void setDefaultRequestProperty(String key, String value) { def_req_props.put(key.toLowerCase(), value); }
public static synchronized void setDefaultRequestProperty(String key, String value) { def_req_props.put(key.toLowerCase(), value); }
1,034
public synchronized void setDefaultUseCaches(boolean use) { def_use_caches = use; }
public synchronized void setDefaultUseCaches(boolean use) { def_use_caches = use; }
1,035
public void setDoInput(boolean input) { doInput = input; }
public void setDoInput(boolean input) { if (connected) throw new IllegalStateException("Already connected"); doInput = input; }
1,036
public void setDoOutput(boolean output) { doOutput = output; }
public void setDoOutput(boolean output) { if (connected) throw new IllegalStateException("Already connected"); doOutput = output; }
1,037
public static void setFileNameMap(FileNameMap fileNameMap) { URLConnection.fileNameMap = fileNameMap; }
public static void setFileNameMap(FileNameMap fileNameMap) { URLConnection.fileNameMap = fileNameMap; }
1,038
public void setIfModifiedSince(long modified_since) { ifModifiedSince = modified_since; }
public void setIfModifiedSince(long modified_since) { ifModifiedSince = modified_since; }
1,039
public void setRequestProperty(String key, String value) { req_props.put(key.toLowerCase(), value); }
public void setRequestProperty(String key, String value) { req_props.put(key.toLowerCase(), value); }
1,040
public void setUseCaches(boolean use_caches) { useCaches = use_caches; }
public void setUseCaches(boolean use_caches) { useCaches = use_caches; }
1,041
public String toString() { return (url.toString()); }
public String toString() { return (url.toString()); }
1,042
createContentHandler(String mime_type);
ContentHandler createContentHandler(String mimeType);
1,043
public MimeTypeMapper() { }
public MimeTypeMapper() { ; }
1,044
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
1,045
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
1,046
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
1,047
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; set1 = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
1,048
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.ZONE_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
1,049
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 0; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
1,050
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
1,051
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (set1 != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
1,052
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
1,053
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } } if (!found && set2 != null) { for (i = offset; i < set2.length; ++i) { if (set2[i] != null) if (dateStr.toUpperCase().startsWith(set2[i].toUpperCase(), index)) { found = true; pos.setIndex(index + set2[i].length()); break; } } } if (!found) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
1,054
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } pos.setIndex(index + match[i].length()); value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
public Date parse (String dateStr, ParsePosition pos) { int fmt_index = 0; int fmt_max = pattern.length(); calendar.clear(); boolean saw_timezone = false; int quote_start = -1; boolean is2DigitYear = false; try { for (; fmt_index < fmt_max; ++fmt_index) { char ch = pattern.charAt(fmt_index); if (ch == '\'') { int index = pos.getIndex(); if (fmt_index < fmt_max - 1 && pattern.charAt(fmt_index + 1) == '\'') { if (! expect (dateStr, pos, ch)) return null; ++fmt_index; } else quote_start = quote_start < 0 ? fmt_index : -1; continue; } if (quote_start != -1 || ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) { if (! expect (dateStr, pos, ch)) return null; continue; } // We've arrived at a potential pattern character in the // pattern. int fmt_count = 1; while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) { ++fmt_count; } // We might need to limit the number of digits to parse in // some cases. We look to the next pattern character to // decide. boolean limit_digits = false; if (fmt_index < fmt_max && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are // numeric or are looked up in a string vector. In some cases // we need an offset. When numeric, `offset' is added to the // resulting value. When doing a string lookup, offset is the // initial index into the string array. int calendar_field; boolean is_numeric = true; String[] match = null; int offset = 0; boolean maybe2DigitYear = false; switch (ch) { case 'd': calendar_field = Calendar.DATE; break; case 'D': calendar_field = Calendar.DAY_OF_YEAR; break; case 'F': calendar_field = Calendar.DAY_OF_WEEK_IN_MONTH; break; case 'E': is_numeric = false; offset = 1; calendar_field = Calendar.DAY_OF_WEEK; match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays()); break; case 'w': calendar_field = Calendar.WEEK_OF_YEAR; break; case 'W': calendar_field = Calendar.WEEK_OF_MONTH; break; case 'M': calendar_field = Calendar.MONTH; if (fmt_count <= 2) offset = -1; else { is_numeric = false; match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths()); } break; case 'y': calendar_field = Calendar.YEAR; if (fmt_count <= 2) maybe2DigitYear = true; break; case 'K': calendar_field = Calendar.HOUR; break; case 'h': calendar_field = Calendar.HOUR; break; case 'H': calendar_field = Calendar.HOUR_OF_DAY; break; case 'k': calendar_field = Calendar.HOUR_OF_DAY; break; case 'm': calendar_field = Calendar.MINUTE; break; case 's': calendar_field = Calendar.SECOND; break; case 'S': calendar_field = Calendar.MILLISECOND; break; case 'a': is_numeric = false; calendar_field = Calendar.AM_PM; match = formatData.getAmPmStrings(); break; case 'z': // We need a special case for the timezone, because it // uses a different data structure than the other cases. is_numeric = false; calendar_field = Calendar.DST_OFFSET; String[][] zoneStrings = formatData.getZoneStrings(); int zoneCount = zoneStrings.length; int index = pos.getIndex(); boolean found_zone = false; for (int j = 0; j < zoneCount; j++) { String[] strings = zoneStrings[j]; int k; for (k = 1; k < strings.length; ++k) { if (dateStr.startsWith(strings[k], index)) break; } if (k != strings.length) { found_zone = true; saw_timezone = true; TimeZone tz = TimeZone.getTimeZone (strings[0]); calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); } pos.setIndex(index + strings[k].length()); break; } } if (! found_zone) { pos.setErrorIndex(pos.getIndex()); return null; } break; default: pos.setErrorIndex(pos.getIndex()); return null; } // Compute the value we should assign to the field. int value; int index = -1; if (is_numeric) { numberFormat.setMinimumIntegerDigits(fmt_count); if (limit_digits) numberFormat.setMaximumIntegerDigits(fmt_count); if (maybe2DigitYear) index = pos.getIndex(); Number n = numberFormat.parse(dateStr, pos); if (pos == null || ! (n instanceof Long)) return null; value = n.intValue() + offset; } else if (match != null) { index = pos.getIndex(); int i; for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(), index)) break; } if (i == match.length) { pos.setErrorIndex(index); return null; } value = i; } else value = offset; if (maybe2DigitYear) { // Parse into default century if the numeric year string has // exactly 2 digits. int digit_count = pos.getIndex() - index; if (digit_count == 2) is2DigitYear = true; } // Assign the value and move on. calendar.set(calendar_field, value); } if (is2DigitYear) { // Apply the 80-20 heuristic to dermine the full year based on // defaultCenturyStart. int year = defaultCentury + calendar.get(Calendar.YEAR); calendar.set(Calendar.YEAR, year); if (calendar.getTime().compareTo(defaultCenturyStart) < 0) calendar.set(Calendar.YEAR, year + 100); } if (! saw_timezone) { // Use the real rules to determine whether or not this // particular time is in daylight savings. calendar.clear (Calendar.DST_OFFSET); calendar.clear (Calendar.ZONE_OFFSET); } return calendar.getTime(); } catch (IllegalArgumentException x) { pos.setErrorIndex(pos.getIndex()); return null; } }
1,055
getContentTypeFor(String filename);
String getContentTypeFor(String filename);
1,056
public SimpleDateFormat(String pattern, Locale locale) { super(); calendar = new GregorianCalendar(locale); computeCenturyStart(); tokens = new ArrayList(); formatData = new DateFormatSymbols(locale); compileFormat(pattern); this.pattern = pattern; numberFormat = NumberFormat.getInstance(locale); numberFormat.setGroupingUsed (false); numberFormat.setParseIntegerOnly (true); numberFormat.setMaximumFractionDigits (0); }
public SimpleDateFormat() { super(); calendar = new GregorianCalendar(locale); computeCenturyStart(); tokens = new ArrayList(); formatData = new DateFormatSymbols(locale); compileFormat(pattern); this.pattern = pattern; numberFormat = NumberFormat.getInstance(locale); numberFormat.setGroupingUsed (false); numberFormat.setParseIntegerOnly (true); numberFormat.setMaximumFractionDigits (0); }
1,057
public SimpleDateFormat(String pattern, Locale locale) { super(); calendar = new GregorianCalendar(locale); computeCenturyStart(); tokens = new ArrayList(); formatData = new DateFormatSymbols(locale); compileFormat(pattern); this.pattern = pattern; numberFormat = NumberFormat.getInstance(locale); numberFormat.setGroupingUsed (false); numberFormat.setParseIntegerOnly (true); numberFormat.setMaximumFractionDigits (0); }
public SimpleDateFormat(String pattern, Locale locale) { super(); calendar = new GregorianCalendar(locale); computeCenturyStart(); tokens = new ArrayList(); formatData = new DateFormatSymbols(locale); compileFormat(pattern); numberFormat = NumberFormat.getInstance(locale); numberFormat.setGroupingUsed (false); numberFormat.setParseIntegerOnly (true); numberFormat.setMaximumFractionDigits (0); }
1,058
protected SystemException(String a_reason, int a_minor, CompletionStatus a_completed ) { super(a_reason); minor = a_minor; completed = a_completed; }
protected SystemException(String a_reason, int a_minor, CompletionStatus a_completed ) { super(a_reason + " Minor: " + Integer.toHexString(a_minor) + " (" + (a_minor & 0xFFF) + "). Completed: "+a_completed); minor = a_minor; completed = a_completed; }
1,059
public DDC1ParseException(String s) { super(s); }
public DDC1ParseException(String s) { super(s); }
1,060
private void jbInit() throws Exception { this.setTitle(LangTool.getString("spool.title")); this.setIconImage(My5250.tnicon.getImage()); this.getContentPane().add(createFilterPanel(), BorderLayout.NORTH); // get an instance of our table model stm = new SpoolTableModel(); // create a table using our custom table model spools = new JSortTable(stm); TableColumn column = null; for (int x = 0;x < stm.getColumnCount(); x++) { column = spools.getColumnModel().getColumn(x); column.setPreferredWidth(stm.getColumnPreferredSize(x)); } spools.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // create our mouse listener on the table spools.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { spools_mouseClicked(e); } public void mousePressed (MouseEvent event) { if (SwingUtilities.isRightMouseButton(event)) showPopupMenu(event); } public void mouseReleased (MouseEvent event) { if (SwingUtilities.isRightMouseButton(event)) showPopupMenu(event); } }); spools.setShowGrid(false); //Create the scroll pane and add the table to it. scrollPane = new JScrollPane(spools); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); // setup the number of rows we should be working with spools.setPreferredScrollableViewportSize( new Dimension( spools.getPreferredScrollableViewportSize().width, spools.getFontMetrics(spools.getFont()).getHeight() * 8) ); scrollPane.getViewport().setBackground(spools.getBackground()); scrollPane.setBackground(spools.getBackground()); //Setup our selection model listener rowSM = spools.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { //Ignore extra messages. if (e.getValueIsAdjusting()) return; ListSelectionModel lsm = (ListSelectionModel)e.getSource(); } }); rowSM.setSelectionMode(rowSM.SINGLE_SELECTION); this.getContentPane().add(scrollPane, BorderLayout.CENTER); status = new JLabel("0 " + LangTool.getString("spool.count")); status.setBorder(BorderFactory.createEtchedBorder()); this.getContentPane().add(status, BorderLayout.SOUTH); pack(); //Center the window 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); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { // close the spool file list// if (splfList != null)// splfList.close(); // close the system connection if (system != null) system.disconnectAllServices(); setVisible(false); dispose(); } }); }
private void jbInit() throws Exception { this.setTitle(LangTool.getString("spool.title")); this.setIconImage(My5250.tnicon.getImage()); this.getContentPane().add(createFilterPanel(), BorderLayout.NORTH); // get an instance of our table model stm = new SpoolTableModel(); // create a table using our custom table model spools = new JSortTable(stm); TableColumn column = null; for (int x = 0;x < stm.getColumnCount(); x++) { column = spools.getColumnModel().getColumn(x); column.setPreferredWidth(stm.getColumnPreferredSize(x)); } spools.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // create our mouse listener on the table spools.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { spools_mouseClicked(e); } public void mousePressed (MouseEvent event) { if (event.isPopupTrigger ()) showPopupMenu(event); } public void mouseReleased (MouseEvent event) { if (event.isPopupTrigger ()) showPopupMenu(event); } }); spools.setShowGrid(false); //Create the scroll pane and add the table to it. scrollPane = new JScrollPane(spools); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); // setup the number of rows we should be working with spools.setPreferredScrollableViewportSize( new Dimension( spools.getPreferredScrollableViewportSize().width, spools.getFontMetrics(spools.getFont()).getHeight() * 8) ); scrollPane.getViewport().setBackground(spools.getBackground()); scrollPane.setBackground(spools.getBackground()); //Setup our selection model listener rowSM = spools.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { //Ignore extra messages. if (e.getValueIsAdjusting()) return; ListSelectionModel lsm = (ListSelectionModel)e.getSource(); } }); rowSM.setSelectionMode(rowSM.SINGLE_SELECTION); this.getContentPane().add(scrollPane, BorderLayout.CENTER); status = new JLabel("0 " + LangTool.getString("spool.count")); status.setBorder(BorderFactory.createEtchedBorder()); this.getContentPane().add(status, BorderLayout.SOUTH); pack(); //Center the window 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); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { // close the spool file list// if (splfList != null)// splfList.close(); // close the system connection if (system != null) system.disconnectAllServices(); setVisible(false); dispose(); } }); }
1,061
public void mousePressed (MouseEvent event) { if (SwingUtilities.isRightMouseButton(event)) showPopupMenu(event); }
public void mousePressed (MouseEvent event) { if (event.isPopupTrigger ()) showPopupMenu(event); }
1,062
public void mouseReleased (MouseEvent event) { if (SwingUtilities.isRightMouseButton(event)) showPopupMenu(event); }
public void mouseReleased (MouseEvent event) { if (event.isPopupTrigger ()) showPopupMenu(event); }
1,063
getIconImage(){ return(icon);}
getIconImage(){ return(icon);}
1,064
public void setPreferredWidth(int preferredWidth) { if (preferredWidth < minWidth) this.preferredWidth = minWidth; else if (preferredWidth > maxWidth) this.preferredWidth = maxWidth; else this.preferredWidth = preferredWidth; }
public void setPreferredWidth(int preferredWidth) { if (preferredWidth < minWidth) this.preferredWidth = minWidth; else if (preferredWidth > maxWidth) this.preferredWidth = maxWidth; else this.preferredWidth = preferredWidth; firePropertyChange("preferredWidth", oldPrefWidth, this.preferredWidth); }
1,065
public boolean send() throws Exception, AddressException, MessagingException { try { if(!loadConfig(configFile)) return false; Session session = Session.getDefaultInstance(SMTPProperties, null); session.setDebug(false); // create the Multipart and its parts to it Multipart mp = new MimeMultipart(); Message msg = new MimeMessage(session); InternetAddress[] toAddrs = null, ccAddrs = null; toAddrs = InternetAddress.parse(to, false); msg.setRecipients(Message.RecipientType.TO, toAddrs); if (cc != null) { ccAddrs = InternetAddress.parse(cc, false); msg.setRecipients(Message.RecipientType.CC, ccAddrs); } if (subject != null) msg.setSubject(subject.trim()); if (from != null && from.length() > 0) msg.setFrom(new InternetAddress(from)); if (message != null && message.length() > 0) { // create and fill the attachment message part MimeBodyPart mbp = new MimeBodyPart(); mbp.setText(message,"us-ascii"); mp.addBodyPart(mbp); } msg.setSentDate(new Date()); if (attachment != null && attachment.length() > 0) { // create and fill the attachment message part MimeBodyPart abp = new MimeBodyPart(); abp.setText(attachment,"us-ascii"); if (attachmentName == null || attachmentName.length() == 0) abp.setFileName("tn5250j.txt"); else abp.setFileName(attachmentName); mp.addBodyPart(abp); } if (fileName != null && fileName.length() > 0) { // create and fill the attachment message part MimeBodyPart fbp = new MimeBodyPart(); fbp.setText("File sent using tn5250j","us-ascii"); if (attachmentName == null || attachmentName.length() == 0) fbp.setFileName("tn5250j.txt"); else fbp.setFileName(attachmentName); // Get the attachment DataSource source = new FileDataSource(fileName); // Set the data handler to the attachment fbp.setDataHandler(new DataHandler(source)); mp.addBodyPart(fbp); } // add the Multipart to the message msg.setContent(mp); // send the message Transport.send(msg); return true; } catch (SendFailedException sfe) { showFailedException(sfe); } return false; }
public boolean send() throws Exception { try { if(!loadConfig(configFile)) return false; Session session = Session.getDefaultInstance(SMTPProperties, null); session.setDebug(false); // create the Multipart and its parts to it Multipart mp = new MimeMultipart(); Message msg = new MimeMessage(session); InternetAddress[] toAddrs = null, ccAddrs = null; toAddrs = InternetAddress.parse(to, false); msg.setRecipients(Message.RecipientType.TO, toAddrs); if (cc != null) { ccAddrs = InternetAddress.parse(cc, false); msg.setRecipients(Message.RecipientType.CC, ccAddrs); } if (subject != null) msg.setSubject(subject.trim()); if (from != null && from.length() > 0) msg.setFrom(new InternetAddress(from)); if (message != null && message.length() > 0) { // create and fill the attachment message part MimeBodyPart mbp = new MimeBodyPart(); mbp.setText(message,"us-ascii"); mp.addBodyPart(mbp); } msg.setSentDate(new Date()); if (attachment != null && attachment.length() > 0) { // create and fill the attachment message part MimeBodyPart abp = new MimeBodyPart(); abp.setText(attachment,"us-ascii"); if (attachmentName == null || attachmentName.length() == 0) abp.setFileName("tn5250j.txt"); else abp.setFileName(attachmentName); mp.addBodyPart(abp); } if (fileName != null && fileName.length() > 0) { // create and fill the attachment message part MimeBodyPart fbp = new MimeBodyPart(); fbp.setText("File sent using tn5250j","us-ascii"); if (attachmentName == null || attachmentName.length() == 0) fbp.setFileName("tn5250j.txt"); else fbp.setFileName(attachmentName); // Get the attachment DataSource source = new FileDataSource(fileName); // Set the data handler to the attachment fbp.setDataHandler(new DataHandler(source)); mp.addBodyPart(fbp); } // add the Multipart to the message msg.setContent(mp); // send the message Transport.send(msg); return true; } catch (SendFailedException sfe) { showFailedException(sfe); } return false; }
1,066
public void removeAllItems() { if (dataModel instanceof DefaultComboBoxModel) { // Uses special method if we have a DefaultComboBoxModel. ((DefaultComboBoxModel) dataModel).removeAllElements(); } else if(dataModel instanceof MutableComboBoxModel){ // Iterates over all items and removes each. MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel; /* We intentionally remove the items backwards to support * models which shift their content to the beginning (e.g. * linked lists) */ for(int i=mcbm.getSize()-1; i >= 0; i--) { mcbm.removeElementAt(i); } } else { throw new RuntimeException("Unable to remove the items because the data model it is not an instance of MutableComboBoxModel."); } }
public void removeAllItems() { if (dataModel instanceof DefaultComboBoxModel) // Uses special method if we have a DefaultComboBoxModel. ((DefaultComboBoxModel) dataModel).removeAllElements(); } else if(dataModel instanceof MutableComboBoxModel){ // Iterates over all items and removes each. MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel; /* We intentionally remove the items backwards to support * models which shift their content to the beginning (e.g. * linked lists) */ for(int i=mcbm.getSize()-1; i >= 0; i--) { mcbm.removeElementAt(i); } } else { throw new RuntimeException("Unable to remove the items because the data model it is not an instance of MutableComboBoxModel."); } }
1,067
public void removeAllItems() { if (dataModel instanceof DefaultComboBoxModel) { // Uses special method if we have a DefaultComboBoxModel. ((DefaultComboBoxModel) dataModel).removeAllElements(); } else if(dataModel instanceof MutableComboBoxModel){ // Iterates over all items and removes each. MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel; /* We intentionally remove the items backwards to support * models which shift their content to the beginning (e.g. * linked lists) */ for(int i=mcbm.getSize()-1; i >= 0; i--) { mcbm.removeElementAt(i); } } else { throw new RuntimeException("Unable to remove the items because the data model it is not an instance of MutableComboBoxModel."); } }
public void removeAllItems() { if (dataModel instanceof DefaultComboBoxModel) { // Uses special method if we have a DefaultComboBoxModel. ((DefaultComboBoxModel) dataModel).removeAllElements(); else if (dataModel instanceof MutableComboBoxModel) { // Iterates over all items and removes each. MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel; /* We intentionally remove the items backwards to support * models which shift their content to the beginning (e.g. * linked lists) */ for(int i=mcbm.getSize()-1; i >= 0; i--) { mcbm.removeElementAt(i); } } else { throw new RuntimeException("Unable to remove the items because the data model it is not an instance of MutableComboBoxModel."); } }
1,068
public void removeAllItems() { if (dataModel instanceof DefaultComboBoxModel) { // Uses special method if we have a DefaultComboBoxModel. ((DefaultComboBoxModel) dataModel).removeAllElements(); } else if(dataModel instanceof MutableComboBoxModel){ // Iterates over all items and removes each. MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel; /* We intentionally remove the items backwards to support * models which shift their content to the beginning (e.g. * linked lists) */ for(int i=mcbm.getSize()-1; i >= 0; i--) { mcbm.removeElementAt(i); } } else { throw new RuntimeException("Unable to remove the items because the data model it is not an instance of MutableComboBoxModel."); } }
public void removeAllItems() { if (dataModel instanceof DefaultComboBoxModel) { // Uses special method if we have a DefaultComboBoxModel. ((DefaultComboBoxModel) dataModel).removeAllElements(); } else if(dataModel instanceof MutableComboBoxModel){ // Iterates over all items and removes each. MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel; /* We intentionally remove the items backwards to support * models which shift their content to the beginning (e.g. * linked lists) */ for (int i = mcbm.getSize() - 1; i >= 0; i--) mcbm.removeElementAt(i); } } else { throw new RuntimeException("Unable to remove the items because the data model it is not an instance of MutableComboBoxModel."); } }
1,069
public void removeAllItems() { if (dataModel instanceof DefaultComboBoxModel) { // Uses special method if we have a DefaultComboBoxModel. ((DefaultComboBoxModel) dataModel).removeAllElements(); } else if(dataModel instanceof MutableComboBoxModel){ // Iterates over all items and removes each. MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel; /* We intentionally remove the items backwards to support * models which shift their content to the beginning (e.g. * linked lists) */ for(int i=mcbm.getSize()-1; i >= 0; i--) { mcbm.removeElementAt(i); } } else { throw new RuntimeException("Unable to remove the items because the data model it is not an instance of MutableComboBoxModel."); } }
public void removeAllItems() { if (dataModel instanceof DefaultComboBoxModel) { // Uses special method if we have a DefaultComboBoxModel. ((DefaultComboBoxModel) dataModel).removeAllElements(); } else if(dataModel instanceof MutableComboBoxModel){ // Iterates over all items and removes each. MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel; /* We intentionally remove the items backwards to support * models which shift their content to the beginning (e.g. * linked lists) */ for(int i=mcbm.getSize()-1; i >= 0; i--) { mcbm.removeElementAt(i); } } else { throw new RuntimeException("Unable to remove the items because the data model it is not an instance of MutableComboBoxModel."); } }
1,070
public abstract void generateCodeFor(VarReturnQuad quad);
public abstract void generateCodeFor(ConditionalBranchQuad quad);
1,073
FileURLLoader(URLClassLoader classloader, URL url) { super(classloader, url); dir = new File(baseURL.getFile()); }
FileURLLoader(URLClassLoader classloader, URL url, URL absoluteUrl) { super(classloader, url); dir = new File(baseURL.getFile()); }
1,074
FileURLLoader(URLClassLoader classloader, URL url) { super(classloader, url); dir = new File(baseURL.getFile()); }
FileURLLoader(URLClassLoader classloader, URL url) { super(classloader, url); dir = new File(baseURL.getFile()); }
1,075
public JarURLLoader(URLClassLoader classloader, URL baseURL) { super(classloader, baseURL); // Cache url prefix for all resources in this jar url. String external = baseURL.toExternalForm(); StringBuffer sb = new StringBuffer(external.length() + 6); sb.append("jar:"); sb.append(external); sb.append("!/"); String jarURL = sb.toString(); this.classPath = null; URL baseJarURL = null; JarFile jarfile = null; try { baseJarURL = new URL(null, jarURL, classloader.getURLStreamHandler("jar")); jarfile = ((JarURLConnection) baseJarURL.openConnection()).getJarFile(); Manifest manifest; Attributes attributes; String classPathString; if ((manifest = jarfile.getManifest()) != null && (attributes = manifest.getMainAttributes()) != null && ((classPathString = attributes.getValue(Attributes.Name.CLASS_PATH)) != null)) { this.classPath = new Vector(); StringTokenizer st = new StringTokenizer(classPathString, " "); while (st.hasMoreElements ()) { String e = st.nextToken (); try { URL url = new URL(baseURL, e); this.classPath.add(url); } catch (java.net.MalformedURLException xx) { // Give up } } } } catch (IOException ioe) { /* ignored */ } this.baseJarURL = baseJarURL; this.jarfile = jarfile; }
public JarURLLoader(URLClassLoader classloader, URL baseURL, URL absoluteUrl) { super(classloader, baseURL); // Cache url prefix for all resources in this jar url. String external = baseURL.toExternalForm(); StringBuffer sb = new StringBuffer(external.length() + 6); sb.append("jar:"); sb.append(external); sb.append("!/"); String jarURL = sb.toString(); this.classPath = null; URL baseJarURL = null; JarFile jarfile = null; try { baseJarURL = new URL(null, jarURL, classloader.getURLStreamHandler("jar")); jarfile = ((JarURLConnection) baseJarURL.openConnection()).getJarFile(); Manifest manifest; Attributes attributes; String classPathString; if ((manifest = jarfile.getManifest()) != null && (attributes = manifest.getMainAttributes()) != null && ((classPathString = attributes.getValue(Attributes.Name.CLASS_PATH)) != null)) { this.classPath = new Vector(); StringTokenizer st = new StringTokenizer(classPathString, " "); while (st.hasMoreElements ()) { String e = st.nextToken (); try { URL url = new URL(baseURL, e); this.classPath.add(url); } catch (java.net.MalformedURLException xx) { // Give up } } } } catch (IOException ioe) { /* ignored */ } this.baseJarURL = baseJarURL; this.jarfile = jarfile; }
1,076
public JarURLLoader(URLClassLoader classloader, URL baseURL) { super(classloader, baseURL); // Cache url prefix for all resources in this jar url. String external = baseURL.toExternalForm(); StringBuffer sb = new StringBuffer(external.length() + 6); sb.append("jar:"); sb.append(external); sb.append("!/"); String jarURL = sb.toString(); this.classPath = null; URL baseJarURL = null; JarFile jarfile = null; try { baseJarURL = new URL(null, jarURL, classloader.getURLStreamHandler("jar")); jarfile = ((JarURLConnection) baseJarURL.openConnection()).getJarFile(); Manifest manifest; Attributes attributes; String classPathString; if ((manifest = jarfile.getManifest()) != null && (attributes = manifest.getMainAttributes()) != null && ((classPathString = attributes.getValue(Attributes.Name.CLASS_PATH)) != null)) { this.classPath = new Vector(); StringTokenizer st = new StringTokenizer(classPathString, " "); while (st.hasMoreElements ()) { String e = st.nextToken (); try { URL url = new URL(baseURL, e); this.classPath.add(url); } catch (java.net.MalformedURLException xx) { // Give up } } } } catch (IOException ioe) { /* ignored */ } this.baseJarURL = baseJarURL; this.jarfile = jarfile; }
public JarURLLoader(URLClassLoader classloader, URL baseURL) { super(classloader, baseURL, absoluteUrl); // Cache url prefix for all resources in this jar url. String external = baseURL.toExternalForm(); StringBuffer sb = new StringBuffer(external.length() + 6); sb.append("jar:"); sb.append(external); sb.append("!/"); String jarURL = sb.toString(); this.classPath = null; URL baseJarURL = null; JarFile jarfile = null; try { baseJarURL = new URL(null, jarURL, classloader.getURLStreamHandler("jar")); jarfile = ((JarURLConnection) baseJarURL.openConnection()).getJarFile(); Manifest manifest; Attributes attributes; String classPathString; if ((manifest = jarfile.getManifest()) != null && (attributes = manifest.getMainAttributes()) != null && ((classPathString = attributes.getValue(Attributes.Name.CLASS_PATH)) != null)) { this.classPath = new Vector(); StringTokenizer st = new StringTokenizer(classPathString, " "); while (st.hasMoreElements ()) { String e = st.nextToken (); try { URL url = new URL(baseURL, e); this.classPath.add(url); } catch (java.net.MalformedURLException xx) { // Give up } } } } catch (IOException ioe) { /* ignored */ } this.baseJarURL = baseJarURL; this.jarfile = jarfile; }
1,077
private void addURLImpl(URL newUrl) { synchronized (this) { if (newUrl == null) return; // Silently ignore... // Reset the toString() value. thisString = null; // Check global cache to see if there're already url loader // for this url. URLLoader loader = (URLLoader) urlloaders.get(newUrl); if (loader == null) { String file = newUrl.getFile(); String protocol = newUrl.getProtocol(); // Check that it is not a directory if (! (file.endsWith("/") || file.endsWith(File.separator))) loader = new JarURLLoader(this, newUrl); else if ("file".equals(protocol)) loader = new FileURLLoader(this, newUrl); else loader = new RemoteURLLoader(this, newUrl); // Cache it. urlloaders.put(newUrl, loader); } urlinfos.add(loader); Vector extraUrls = loader.getClassPath(); if (extraUrls != null) { Iterator it = extraUrls.iterator(); while (it.hasNext()) { URL url = (URL)it.next(); URLLoader extraLoader = (URLLoader) urlloaders.get(url); if (! urlinfos.contains (extraLoader)) addURLImpl(url); } } } }
private void addURLImpl(URL newUrl) { synchronized (this) { if (newUrl == null) return; // Silently ignore... // Reset the toString() value. thisString = null; // Check global cache to see if there're already url loader // for this url. URLLoader loader = (URLLoader) urlloaders.get(newUrl); if (loader == null) { String file = newUrl.getFile(); String protocol = newUrl.getProtocol(); // Check that it is not a directory if (! (file.endsWith("/") || file.endsWith(File.separator))) loader = new JarURLLoader(this, newUrl, absoluteURL); else if ("file".equals(protocol)) loader = new FileURLLoader(this, newUrl); else loader = new RemoteURLLoader(this, newUrl); // Cache it. urlloaders.put(newUrl, loader); } urlinfos.add(loader); Vector extraUrls = loader.getClassPath(); if (extraUrls != null) { Iterator it = extraUrls.iterator(); while (it.hasNext()) { URL url = (URL)it.next(); URLLoader extraLoader = (URLLoader) urlloaders.get(url); if (! urlinfos.contains (extraLoader)) addURLImpl(url); } } } }
1,078
private void addURLImpl(URL newUrl) { synchronized (this) { if (newUrl == null) return; // Silently ignore... // Reset the toString() value. thisString = null; // Check global cache to see if there're already url loader // for this url. URLLoader loader = (URLLoader) urlloaders.get(newUrl); if (loader == null) { String file = newUrl.getFile(); String protocol = newUrl.getProtocol(); // Check that it is not a directory if (! (file.endsWith("/") || file.endsWith(File.separator))) loader = new JarURLLoader(this, newUrl); else if ("file".equals(protocol)) loader = new FileURLLoader(this, newUrl); else loader = new RemoteURLLoader(this, newUrl); // Cache it. urlloaders.put(newUrl, loader); } urlinfos.add(loader); Vector extraUrls = loader.getClassPath(); if (extraUrls != null) { Iterator it = extraUrls.iterator(); while (it.hasNext()) { URL url = (URL)it.next(); URLLoader extraLoader = (URLLoader) urlloaders.get(url); if (! urlinfos.contains (extraLoader)) addURLImpl(url); } } } }
private void addURLImpl(URL newUrl) { synchronized (this) { if (newUrl == null) return; // Silently ignore... // Reset the toString() value. thisString = null; // Check global cache to see if there're already url loader // for this url. URLLoader loader = (URLLoader) urlloaders.get(newUrl); if (loader == null) { String file = newUrl.getFile(); String protocol = newUrl.getProtocol(); // Check that it is not a directory if (! (file.endsWith("/") || file.endsWith(File.separator))) loader = new JarURLLoader(this, newUrl); else if ("file".equals(protocol)) loader = new FileURLLoader(this, newUrl, absoluteURL); else loader = new RemoteURLLoader(this, newUrl); // Cache it. urlloaders.put(newUrl, loader); } urlinfos.add(loader); Vector extraUrls = loader.getClassPath(); if (extraUrls != null) { Iterator it = extraUrls.iterator(); while (it.hasNext()) { URL url = (URL)it.next(); URLLoader extraLoader = (URLLoader) urlloaders.get(url); if (! urlinfos.contains (extraLoader)) addURLImpl(url); } } } }
1,079
public BlockReservation testAndSetBlock(long blockNr) throws IOException{ if(blockNr<superblock.getFirstDataBlock() || blockNr>=superblock.getBlocksCount()) return new BlockReservation(false, -1, -1); int group = translateToGroup(blockNr); int index = translateToIndex(blockNr); /* Return false if the block is not a data block but a filesystem * metadata block, as the beginning of each block group is filesystem * metadata: * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); if(blockNr<firstNonMetadataBlock) return new BlockReservation(false, -1, -1); byte[] bitmap = getBlock(groupDescriptors[group].getBlockBitmap()); //at any time, only one copy of the Block exists in the cache, so it is //safe to synchronize to the bitmapBlock object (it's part of Block) synchronized( bitmap ) { BlockReservation result = BlockBitmap.testAndSetBlock( bitmap, index ); //update the block bitmap if(result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); modifyFreeBlocksCount(group, -1-result.getPreallocCount()); result.setBlock( result.getBlock()+superblock.getFirstDataBlock() ); } return result; } }
public BlockReservation testAndSetBlock(long blockNr) throws IOException{ if(blockNr<superblock.getFirstDataBlock() || blockNr>=superblock.getBlocksCount()) return new BlockReservation(false, -1, -1); int group = translateToGroup(blockNr); int index = translateToIndex(blockNr); /* Return false if the block is not a data block but a filesystem * metadata block, as the beginning of each block group is filesystem * metadata: * superblock copy (if present) * block bitmap * inode bitmap * inode table * Free blocks begin after the inode table. */ long iNodeTableBlock = groupDescriptors[group].getInodeTable(); long firstNonMetadataBlock = iNodeTableBlock + INodeTable.getSizeInBlocks(this); if(blockNr<firstNonMetadataBlock) return new BlockReservation(false, -1, -1); byte[] bitmap = getBlock(groupDescriptors[group].getBlockBitmap()); //at any time, only one copy of the Block exists in the cache, so it is //safe to synchronize to the bitmapBlock object (it's part of Block) synchronized( bitmap ) { BlockReservation result = BlockBitmap.testAndSetBlock( bitmap, index ); //update the block bitmap if(result.isSuccessful()) { writeBlock(groupDescriptors[group].getBlockBitmap(), bitmap, false); modifyFreeBlocksCount(group, -1-result.getPreallocCount()); result.setBlock(blockNr); } return result; } }
1,080
public FileSystemException(String message, Throwable cause) { super(message, cause); }
public FileSystemException(String message, Throwable cause) { super(message, cause); }
1,081
public BlockReservation(boolean successful, long block, int preallocCount, long freeBlocksCount) { this.successful = successful; this.block = block; this.preallocCount = preallocCount; this.freeBlocksCount = freeBlocksCount; }
public BlockReservation(boolean successful, long block, int preallocCount) { this.successful = successful; this.block = block; this.preallocCount = preallocCount; this.freeBlocksCount = freeBlocksCount; }
1,082
public BlockReservation(boolean successful, long block, int preallocCount, long freeBlocksCount) { this.successful = successful; this.block = block; this.preallocCount = preallocCount; this.freeBlocksCount = freeBlocksCount; }
public BlockReservation(boolean successful, long block, int preallocCount, long freeBlocksCount) { this.successful = successful; this.block = block; this.preallocCount = preallocCount; }
1,083
public TreeModelEvent(Object source, Object[] path, int[] childIndices, Object[] children) { super(source); this.path = new TreePath(path); this.childIndices = childIndices; this.children = children; } // TreeModelEvent()
public TreeModelEvent(Object source, Object[] path, int[] childIndices, Object[] children) { super(source); this.path = new TreePath(path); this.childIndices = childIndices; this.children = children; } // TreeModelEvent()
1,084
public TreeModelEvent(Object source, Object[] path, int[] childIndices, Object[] children) { super(source); this.path = new TreePath(path); this.childIndices = childIndices; this.children = children; } // TreeModelEvent()
public TreeModelEvent(Object source, Object[] path, int[] childIndices, Object[] children) { super(source); this.path = new TreePath(path); this.childIndices = childIndices; this.children = children; } // TreeModelEvent()
1,085
public File createFileObject(File directory, String filename) { return null; // TODO } // createFileObject()
public File createFileObject(File directory, String filename) { return null; // TODO } // createFileObject()
1,087
public abstract File createNewFolder(File file) throws IOException;
public abstract File createNewFolder(File containingDir) throws IOException;
1,088
public static FileSystemView getFileSystemView() { return null; // TODO } // getFileSystemView()
public static FileSystemView getFileSystemView() { return null; // TODO } // getFileSystemView()
1,089
public File[] getFiles(File directory, boolean fileHiding) { return null; // TODO } // getFiles()
public File[] getFiles(File directory, boolean fileHiding) { return null; // TODO } // getFiles()
1,090
public File getHomeDirectory() { return null; // TODO } // getHomeDirectory()
public File getHomeDirectory() { return null; // TODO } // getHomeDirectory()
1,091
public File getParentDirectory(File directory) { return null; // TODO } // getParentDirectory()
public File getParentDirectory(File directory) { return null; // TODO } // getParentDirectory()
1,092
public abstract File[] getRoots();
public File[] getRoots() { return null; }
1,093
public abstract boolean isHiddenFile(File file);
public boolean isHiddenFile(File f) { return f.isHidden(); }
1,094
public abstract boolean isRoot(File file);
public boolean isRoot(File f) { return false; }
1,095
public void itemStateChanged(ItemEvent e) { showMe_itemStateChanged(e); }
public void itemStateChanged(ItemEvent e) { hideTabBar_itemStateChanged(e); }
1,096
void jbInit() throws Exception { // make it non resizable setResizable(true); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); // create sessions panel createSessionsPanel(); // create emulator options panel createEmulatorOptionsPanel(); // create the button options createButtonOptions(); JTabbedPane optionTabs = new JTabbedPane(); optionTabs.addChangeListener(this); optionTabs.addTab(LangTool.getString("ss.labelConnections"),sessionPanel); optionTabs.addTab(LangTool.getString("ss.labelOptions1"),emulOptPanel); // add the panels to our dialog getContentPane().add(optionTabs,BorderLayout.CENTER); getContentPane().add(options, BorderLayout.SOUTH); // 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); // set default selection value as the first row or default session if (sessions.getRowCount() > 0) { int selInterval = 0; for (int x = 0; x < sessions.getRowCount(); x++) { if (((Boolean)ctm.getValueAt(x,2)).booleanValue()) selInterval = x; } sessions.getSelectionModel().setSelectionInterval(selInterval,selInterval); } sessions.requestFocus(); // now show the world what we and they can do this.setVisible(true); }
void jbInit() throws Exception { // make it non resizable setResizable(true); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); // create sessions panel createSessionsPanel(); // create emulator options panel createEmulatorOptionsPanel(); // create the button options createButtonOptions(); JTabbedPane optionTabs = new JTabbedPane(); optionTabs.addChangeListener(this); optionTabs.addTab(LangTool.getString("ss.labelConnections"),sessionPanel); optionTabs.addTab(LangTool.getString("ss.labelOptions1"),emulOptPanel); // add the panels to our dialog getContentPane().add(optionTabs,BorderLayout.CENTER); getContentPane().add(options, BorderLayout.SOUTH); // 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); // set default selection value as the first row or default session if (sessions.getRowCount() > 0) { int selInterval = 0; for (int x = 0; x < sessions.getRowCount(); x++) { if (((Boolean)ctm.getValueAt(x,2)).booleanValue()) selInterval = x; } sessions.getSelectionModel().setSelectionInterval(selInterval,selInterval); } addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { sessions.requestFocus(); } }); } }); // now show the world what we and they can do this.setVisible(true); }
1,097
public final boolean hasFeature(int feature) { return ((this.features & feature) == feature); }
public final boolean hasFeature(int feature) { return ((this.features & feature) == feature); }
1,099
public MemoryResource claimMemoryResource(ResourceOwner owner, Address start, int size, int mode) throws ResourceNotFreeException;
public MemoryResource claimMemoryResource(ResourceOwner owner, Address start, Extent size, int mode) throws ResourceNotFreeException;
1,100
protected DoubleWordItem(int kind, int offsetToFP, Register lsb, Register msb) { super(kind, offsetToFP); this.lsb = lsb; this.msb = msb; }
protected DoubleWordItem(int kind, int offsetToFP, Register lsb, Register msb) { super(kind, offsetToFP); this.lsb = lsb; this.msb = msb; }
1,101
protected final Item clone(EmitterContext ec) { final DoubleWordItem res; final AbstractX86Stream os = ec.getStream(); switch (getKind()) { case Kind.REGISTER: res = L1AHelper.requestDoubleWordRegisters(ec, getType()); final Register lsb = res.getLsbRegister(); final Register msb = res.getMsbRegister(); os.writeMOV(INTSIZE, lsb, this.lsb); os.writeMOV(INTSIZE, msb, this.msb); break; case Kind.LOCAL: res = createLocal(getType(), super.getOffsetToFP()); break; case Kind.CONSTANT: res = cloneConstant(); break; case Kind.FPUSTACK: //TODO notImplemented(); res = null; break; case Kind.STACK: //TODO notImplemented(); res = null; break; default: throw new IllegalArgumentException("Invalid item kind"); } return res; }
protected final Item clone(EmitterContext ec) { final DoubleWordItem res; final AbstractX86Stream os = ec.getStream(); switch (getKind()) { case Kind.REGISTER: res = L1AHelper.requestDoubleWordRegisters(ec, getType()); final Register lsb = res.getLsbRegister(); final Register msb = res.getMsbRegister(); os.writeMOV(INTSIZE, lsb, this.lsb); os.writeMOV(INTSIZE, msb, this.msb); break; case Kind.LOCAL: res = createLocal(getType(), super.getOffsetToFP()); break; case Kind.CONSTANT: res = cloneConstant(); break; case Kind.FPUSTACK: //TODO notImplemented(); res = null; break; case Kind.STACK: //TODO notImplemented(); res = null; break; default: throw new IllegalArgumentException("Invalid item kind"); } return res; }
1,102
protected final Item clone(EmitterContext ec) { final DoubleWordItem res; final AbstractX86Stream os = ec.getStream(); switch (getKind()) { case Kind.REGISTER: res = L1AHelper.requestDoubleWordRegisters(ec, getType()); final Register lsb = res.getLsbRegister(); final Register msb = res.getMsbRegister(); os.writeMOV(INTSIZE, lsb, this.lsb); os.writeMOV(INTSIZE, msb, this.msb); break; case Kind.LOCAL: res = createLocal(getType(), super.getOffsetToFP()); break; case Kind.CONSTANT: res = cloneConstant(); break; case Kind.FPUSTACK: //TODO notImplemented(); res = null; break; case Kind.STACK: //TODO notImplemented(); res = null; break; default: throw new IllegalArgumentException("Invalid item kind"); } return res; }
protected final Item clone(EmitterContext ec) { final DoubleWordItem res; final AbstractX86Stream os = ec.getStream(); switch (getKind()) { case Kind.REGISTER: res = L1AHelper.requestDoubleWordRegisters(ec, getType()); final Register lsb = res.getLsbRegister(); final Register msb = res.getMsbRegister(); os.writeMOV(INTSIZE, lsb, this.lsb); os.writeMOV(INTSIZE, msb, this.msb); break; case Kind.LOCAL: res = createLocal(getType(), super.getOffsetToFP()); break; case Kind.CONSTANT: res = cloneConstant(); break; case Kind.FPUSTACK: //TODO notImplemented(); res = null; break; case Kind.STACK: //TODO notImplemented(); res = null; break; default: throw new IllegalArgumentException("Invalid item kind"); } return res; }
1,103
protected final Item clone(EmitterContext ec) { final DoubleWordItem res; final AbstractX86Stream os = ec.getStream(); switch (getKind()) { case Kind.REGISTER: res = L1AHelper.requestDoubleWordRegisters(ec, getType()); final Register lsb = res.getLsbRegister(); final Register msb = res.getMsbRegister(); os.writeMOV(INTSIZE, lsb, this.lsb); os.writeMOV(INTSIZE, msb, this.msb); break; case Kind.LOCAL: res = createLocal(getType(), super.getOffsetToFP()); break; case Kind.CONSTANT: res = cloneConstant(); break; case Kind.FPUSTACK: //TODO notImplemented(); res = null; break; case Kind.STACK: //TODO notImplemented(); res = null; break; default: throw new IllegalArgumentException("Invalid item kind"); } return res; }
protected final Item clone(EmitterContext ec) { final DoubleWordItem res; final AbstractX86Stream os = ec.getStream(); switch (getKind()) { case Kind.REGISTER: res = L1AHelper.requestDoubleWordRegisters(ec, getType()); final Register lsb = res.getLsbRegister(); final Register msb = res.getMsbRegister(); os.writeMOV(INTSIZE, lsb, this.lsb); os.writeMOV(INTSIZE, msb, this.msb); break; case Kind.LOCAL: res = createLocal(getType(), super.getOffsetToFP()); break; case Kind.CONSTANT: res = cloneConstant(); break; case Kind.FPUSTACK: //TODO notImplemented(); res = null; break; case Kind.STACK: //TODO notImplemented(); res = null; break; default: throw new IllegalArgumentException("Invalid item kind"); } return res; }
1,104
final void push(EmitterContext ec) { final AbstractX86Stream os = ec.getStream(); final VirtualStack stack = ec.getVStack(); //os.log("LongItem.push "+Integer.toString(getKind())); switch (getKind()) { case Kind.REGISTER: os.writePUSH(msb); os.writePUSH(lsb); break; case Kind.LOCAL: os.writePUSH(FP, getMsbOffsetToFP()); os.writePUSH(FP, getLsbOffsetToFP()); break; case Kind.CONSTANT: pushConstant(ec, os); break; case Kind.FPUSTACK: // Make sure this item is on top of the FPU stack final FPUStack fpuStack = stack.fpuStack; if (!fpuStack.isTos(this)) { FPUHelper.fxch(os, fpuStack, fpuStack.getRegister(this)); } stack.fpuStack.pop(this); // Convert & move to new space on normal stack os.writeLEA(SP, SP, -8); popFromFPU(os, SP, 0); break; case Kind.STACK: //nothing to do if (VirtualStack.checkOperandStack) { // the item is not really pushed and popped // but this checks that it is really the top // element stack.operandStack.pop(this); } break; } release(ec); kind = Kind.STACK; if (VirtualStack.checkOperandStack) { stack.operandStack.push(this); } }
final void push(EmitterContext ec) { final AbstractX86Stream os = ec.getStream(); final VirtualStack stack = ec.getVStack(); //os.log("LongItem.push "+Integer.toString(getKind())); switch (getKind()) { case Kind.REGISTER: os.writePUSH(msb); os.writePUSH(lsb); break; case Kind.LOCAL: os.writePUSH(FP, getMsbOffsetToFP()); os.writePUSH(FP, getLsbOffsetToFP()); break; case Kind.CONSTANT: pushConstant(ec, os); break; case Kind.FPUSTACK: // Make sure this item is on top of the FPU stack final FPUStack fpuStack = stack.fpuStack; if (!fpuStack.isTos(this)) { FPUHelper.fxch(os, fpuStack, fpuStack.getRegister(this)); } stack.fpuStack.pop(this); // Convert & move to new space on normal stack os.writeLEA(SP, SP, -8); popFromFPU(os, SP, 0); break; case Kind.STACK: //nothing to do if (VirtualStack.checkOperandStack) { // the item is not really pushed and popped // but this checks that it is really the top // element stack.operandStack.pop(this); } break; } release(ec); kind = Kind.STACK; if (VirtualStack.checkOperandStack) { stack.operandStack.push(this); } }
1,105
final void release(EmitterContext ec) { //assertCondition(!ec.getVStack().contains(this), "Cannot release while on vstack"); final X86RegisterPool pool = ec.getPool(); switch (getKind()) { case Kind.REGISTER: pool.release(lsb); pool.release(msb); break; case Kind.LOCAL: // nothing to do break; case Kind.CONSTANT: // nothing to do break; case Kind.FPUSTACK: // nothing to do break; case Kind.STACK: // nothing to do break; } this.lsb = null; this.msb = null; this.kind = 0; }
final void release(EmitterContext ec) { //assertCondition(!ec.getVStack().contains(this), "Cannot release while on vstack"); final X86RegisterPool pool = ec.getPool(); switch (getKind()) { case Kind.REGISTER: pool.release(lsb); pool.release(msb); break; case Kind.LOCAL: // nothing to do break; case Kind.CONSTANT: // nothing to do break; case Kind.FPUSTACK: // nothing to do break; case Kind.STACK: // nothing to do break; } this.lsb = null; this.msb = null; this.kind = 0; }
1,106