rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
public int getContentLength() { return (getHeaderFieldInt("content-length", -1));
public int getContentLength() { return getHeaderFieldInt("content-length", -1);
public int getContentLength() { return (getHeaderFieldInt("content-length", -1)); }
public String getContentType() { String type = getHeaderField("content-type"); if (type == null) type = guessContentTypeFromName(getURL().getFile()); return (type);
public String getContentType() { return getHeaderField("content-type");
public String getContentType() { String type = getHeaderField("content-type"); if (type == null) type = guessContentTypeFromName(getURL().getFile()); return (type); }
public long getDate() { return (getHeaderFieldDate("date", 0)); }
public long getDate() { return getHeaderFieldDate("date", 0L); }
public long getDate() { return (getHeaderFieldDate("date", 0)); }
public static boolean getDefaultAllowUserInteraction() { return (def_allow_user_inter);
public static boolean getDefaultAllowUserInteraction() { return defaultAllowUserInteraction;
public static boolean getDefaultAllowUserInteraction() { return (def_allow_user_inter); }
public static String getDefaultRequestProperty(String key) { return ((String) def_req_props.get(key.toLowerCase())); }
public static String getDefaultRequestProperty(String key) { return null; }
public static String getDefaultRequestProperty(String key) { return ((String) def_req_props.get(key.toLowerCase())); }
public boolean getDefaultUseCaches() { return (def_use_caches);
public boolean getDefaultUseCaches() { return defaultUseCaches;
public boolean getDefaultUseCaches() { return (def_use_caches); }
public boolean getDoInput() { return (doInput);
public boolean getDoInput() { return doInput;
public boolean getDoInput() { return (doInput); }
public boolean getDoOutput() { return (doOutput);
public boolean getDoOutput() { return doOutput;
public boolean getDoOutput() { return (doOutput); }
public long getExpiration() { return (getHeaderFieldDate("expires", 0));
public long getExpiration() { return getHeaderFieldDate("expires", 0L);
public long getExpiration() { return (getHeaderFieldDate("expires", 0)); }
public static FileNameMap getFileNameMap() { return (fileNameMap); }
public static synchronized FileNameMap getFileNameMap() { if (fileNameMap == null) fileNameMap = new MimeTypeMapper(); return fileNameMap; }
public static FileNameMap getFileNameMap() { return (fileNameMap); }
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(int index) { return null;
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 long getHeaderFieldDate(String key, long def) { String value = getHeaderField(key); if (value == null) return (def);
public long getHeaderFieldDate(String name, long defaultValue) { if (! dateformats_initialized) initializeDateFormats();
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); }
if (position == null) position = new ParsePosition(0);
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); }
Date d = new Date(value);
long result = defaultValue; String str = getHeaderField(name);
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); }
if (d == null) return (def);
if (str != null) { for (int i = 0; i < dateFormats.length; i++) { SimpleDateFormat df = dateFormats[i]; position.setIndex(0); position.setErrorIndex(0); Date date = df.parse(str, position); if (date != null) return date.getTime(); } }
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); }
return (d.getTime() / 1000); }
return result; }
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 int getHeaderFieldInt(String key, int def) { String value = getHeaderField(key); if (value == null) return (def);
public int getHeaderFieldInt(String name, int defaultValue) { String value = getHeaderField(name);
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); }
int retval = def; try { retval = Integer.parseInt(value); } catch (NumberFormatException e) { return (def); }
if (value == null) return defaultValue;
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); }
return (retval);
try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; }
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 String getHeaderFieldKey(int index) { return (null);
public String getHeaderFieldKey(int index) { return null;
public String getHeaderFieldKey(int index) { return (null); }
public long getIfModifiedSince() { return (ifModifiedSince);
public long getIfModifiedSince() { return ifModifiedSince;
public long getIfModifiedSince() { return (ifModifiedSince); }
public InputStream getInputStream() throws IOException { return (null);
public InputStream getInputStream() throws IOException { throw new UnknownServiceException("Protocol " + url.getProtocol() + " does not support input.");
public InputStream getInputStream() throws IOException { return (null); }
public long getLastModified() { return (getHeaderFieldDate("last-modified", 0)); }
public long getLastModified() { return getHeaderFieldDate("last-modified", 0L); }
public long getLastModified() { return (getHeaderFieldDate("last-modified", 0)); }
public OutputStream getOutputStream() throws IOException { return (null);
public OutputStream getOutputStream() throws IOException { throw new UnknownServiceException("Protocol " + url.getProtocol() + " does not support output.");
public OutputStream getOutputStream() throws IOException { return (null); }
public Permission getPermission() throws IOException { return (new java.security.AllPermission());
public Permission getPermission() throws IOException { return new AllPermission();
public Permission getPermission() throws IOException { return (new java.security.AllPermission()); }
public Map getRequestProperties() { return Collections.unmodifiableMap(req_props);
public Map getRequestProperties() { if (connected) throw new IllegalStateException("Already connected"); return Collections.EMPTY_MAP;
public Map getRequestProperties() { return Collections.unmodifiableMap(req_props); }
public String getRequestProperty(String key) { return ((String) req_props.get(key.toLowerCase())); }
public String getRequestProperty(String key) { if (connected) throw new IllegalStateException("Already connected"); return null; }
public String getRequestProperty(String key) { return ((String) req_props.get(key.toLowerCase())); }
public URL getURL() { return (url);
public URL getURL() { return url;
public URL getURL() { return (url); }
public boolean getUseCaches() { return (useCaches);
public boolean getUseCaches() { return useCaches;
public boolean getUseCaches() { return (useCaches); }
public static String guessContentTypeFromName(String filename) { return (fileNameMap.getContentTypeFor(filename.toLowerCase())); }
public static String guessContentTypeFromName(String filename) { return getFileNameMap().getContentTypeFor(filename.toLowerCase()); }
public static String guessContentTypeFromName(String filename) { return (fileNameMap.getContentTypeFor(filename.toLowerCase())); }
public static String guessContentTypeFromStream(InputStream is) throws IOException { return ("application/octet-stream");
public static String guessContentTypeFromStream(InputStream is) throws IOException { return "application/octet-stream";
public static String guessContentTypeFromStream(InputStream is) throws IOException { return ("application/octet-stream"); }
public static synchronized void setContentHandlerFactory(ContentHandlerFactory fac) { if (factory != null) throw new Error("The ContentHandlerFactory is already set");
public static synchronized void setContentHandlerFactory(ContentHandlerFactory factory) { if (URLConnection.factory != null) throw new Error("ContentHandlerFactory already set");
public static synchronized void setContentHandlerFactory(ContentHandlerFactory fac) { if (factory != null) throw new Error("The ContentHandlerFactory is already set"); factory = fac; }
factory = fac;
SecurityManager s = System.getSecurityManager(); if (s != null) s.checkSetFactory(); URLConnection.factory = factory;
public static synchronized void setContentHandlerFactory(ContentHandlerFactory fac) { if (factory != null) throw new Error("The ContentHandlerFactory is already set"); factory = fac; }
public static synchronized void setDefaultAllowUserInteraction(boolean allow) { def_allow_user_inter = allow;
public static void setDefaultAllowUserInteraction(boolean allow) { defaultAllowUserInteraction = allow;
public static synchronized void setDefaultAllowUserInteraction(boolean allow) { def_allow_user_inter = allow; }
public static synchronized void setDefaultRequestProperty(String key, String value) { def_req_props.put(key.toLowerCase(), value);
public static void setDefaultRequestProperty(String key, String value) {
public static synchronized void setDefaultRequestProperty(String key, String value) { def_req_props.put(key.toLowerCase(), value); }
public synchronized void setDefaultUseCaches(boolean use) { def_use_caches = use;
public void setDefaultUseCaches(boolean use) { defaultUseCaches = use;
public synchronized void setDefaultUseCaches(boolean use) { def_use_caches = use; }
public void setDoInput(boolean input) {
public void setDoInput(boolean input) { if (connected) throw new IllegalStateException("Already connected");
public void setDoInput(boolean input) { doInput = input; }
public void setDoOutput(boolean output) {
public void setDoOutput(boolean output) { if (connected) throw new IllegalStateException("Already connected");
public void setDoOutput(boolean output) { doOutput = output; }
public static void setFileNameMap(FileNameMap fileNameMap) { URLConnection.fileNameMap = fileNameMap; }
public static synchronized void setFileNameMap(FileNameMap map) { SecurityManager s = System.getSecurityManager(); if (s != null) s.checkSetFactory(); fileNameMap = map; }
public static void setFileNameMap(FileNameMap fileNameMap) { URLConnection.fileNameMap = fileNameMap; }
public void setIfModifiedSince(long modified_since) { ifModifiedSince = modified_since; }
public void setIfModifiedSince(long ifmodifiedsince) { if (connected) throw new IllegalStateException("Already connected"); ifModifiedSince = ifmodifiedsince; }
public void setIfModifiedSince(long modified_since) { ifModifiedSince = modified_since; }
public void setRequestProperty(String key, String value) { req_props.put(key.toLowerCase(), value); }
public void setRequestProperty(String key, String value) { if (connected) throw new IllegalStateException("Already connected"); if (key == null) throw new NullPointerException("key is null"); }
public void setRequestProperty(String key, String value) { req_props.put(key.toLowerCase(), value); }
public void setUseCaches(boolean use_caches) { useCaches = use_caches; }
public void setUseCaches(boolean usecaches) { if (connected) throw new IllegalStateException("Already connected"); useCaches = usecaches; }
public void setUseCaches(boolean use_caches) { useCaches = use_caches; }
public String toString() { return (url.toString());
public String toString() { return this.getClass().getName() + ":" + url.toString();
public String toString() { return (url.toString()); }
createContentHandler(String mime_type);
ContentHandler createContentHandler(String mimeType);
createContentHandler(String mime_type);
public MimeTypeMapper() {
public MimeTypeMapper() { ;
public MimeTypeMapper() { }
String[] match = 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; } }
match = (fmt_count <= 3 ? formatData.getShortWeekdays() : formatData.getWeekdays());
set1 = formatData.getWeekdays(); set2 = formatData.getShortWeekdays();
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; } }
match = (fmt_count == 3 ? formatData.getShortMonths() : formatData.getMonths());
set1 = formatData.getMonths(); set2 = formatData.getShortMonths();
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; } }
match = formatData.getAmPmStrings();
set1 = formatData.getAmPmStrings();
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; } }
calendar_field = Calendar.DST_OFFSET;
calendar_field = Calendar.ZONE_OFFSET;
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; } }
for (k = 1; k < strings.length; ++k)
for (k = 0; k < strings.length; ++k)
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; } }
calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ()); offset = 0; if (k > 2 && tz instanceof SimpleTimeZone) { SimpleTimeZone stz = (SimpleTimeZone) tz; offset = stz.getDSTSavings (); }
calendar.set (Calendar.DST_OFFSET, tz.getDSTSavings()); offset = tz.getRawOffset ();
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; } }
else if (match != null)
else if (set1 != 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; } }
for (i = offset; i < match.length; ++i) { if (match[i] != null) if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(),
boolean found = false; for (i = offset; i < set1.length; ++i) { if (set1[i] != null) if (dateStr.toUpperCase().startsWith(set1[i].toUpperCase(),
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; } }
if (i == match.length)
} 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)
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; } }
pos.setIndex(index + match[i].length());
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; } }
getContentTypeFor(String filename);
String getContentTypeFor(String filename);
getContentTypeFor(String filename);
public SimpleDateFormat(String pattern, Locale locale)
public SimpleDateFormat()
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); }
this.pattern = pattern;
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); }
super(a_reason);
super(a_reason + " Minor: " + Integer.toHexString(a_minor) + " (" + (a_minor & 0xFFF) + "). Completed: "+a_completed);
protected SystemException(String a_reason, int a_minor, CompletionStatus a_completed ) { super(a_reason); minor = a_minor; completed = a_completed; }
public DDC1ParseException(String s) { super(s);
public DDC1ParseException() { super();
public DDC1ParseException(String s) { super(s); }
if (SwingUtilities.isRightMouseButton(event))
if (event.isPopupTrigger ())
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(); } }); }
if (SwingUtilities.isRightMouseButton(event))
if (event.isPopupTrigger ())
public void mousePressed (MouseEvent event) { if (SwingUtilities.isRightMouseButton(event)) showPopupMenu(event); }
if (SwingUtilities.isRightMouseButton(event))
if (event.isPopupTrigger ())
public void mouseReleased (MouseEvent event) { if (SwingUtilities.isRightMouseButton(event)) showPopupMenu(event); }
getIconImage() { return(icon); }
public Image getIconImage() { return icon; }
getIconImage(){ return(icon);}
this.preferredWidth = preferredWidth;
this.preferredWidth = preferredWidth; firePropertyChange("preferredWidth", oldPrefWidth, this.preferredWidth);
public void setPreferredWidth(int preferredWidth) { if (preferredWidth < minWidth) this.preferredWidth = minWidth; else if (preferredWidth > maxWidth) this.preferredWidth = maxWidth; else this.preferredWidth = preferredWidth; }
public boolean send() throws Exception, AddressException, MessagingException {
public boolean send() throws Exception {
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; }
if (dataModel instanceof DefaultComboBoxModel) {
if (dataModel instanceof DefaultComboBoxModel)
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."); } }
} else if(dataModel instanceof MutableComboBoxModel){
else if (dataModel instanceof 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."); } }
for(int i=mcbm.getSize()-1; i >= 0; i--) {
for (int i = mcbm.getSize() - 1; i >= 0; i--)
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."); } }
} else { throw new RuntimeException("Unable to remove the items because the data model it is not an instance of MutableComboBoxModel."); }
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."); } }
if (button.getParent() instanceof JToolBar) button.setBorder(MetalBorders.getToolbarButtonBorder());
public void installDefaults(AbstractButton button) { super.installDefaults(button); UIDefaults defaults = UIManager.getLookAndFeelDefaults(); button.setFont(defaults.getFont("Button.font")); }
b.setRolloverEnabled(defaults.getBoolean(prefix + "rollover"));
protected void installDefaults(AbstractButton b) { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); String prefix = getPropertyPrefix(); focusColor = defaults.getColor(prefix + "focus"); b.setForeground(defaults.getColor(prefix + "foreground")); b.setBackground(defaults.getColor(prefix + "background")); b.setMargin(defaults.getInsets(prefix + "margin")); b.setBorder(defaults.getBorder(prefix + "border")); b.setIconTextGap(defaults.getInt(prefix + "textIconGap")); b.setInputMap(JComponent.WHEN_FOCUSED, (InputMap) defaults.get(prefix + "focusInputMap")); b.setOpaque(true); }
public abstract void generateCodeFor(VarReturnQuad quad);
public abstract void generateCodeFor(ConditionalBranchQuad quad);
public abstract void generateCodeFor(VarReturnQuad quad);
FileURLLoader(URLClassLoader classloader, URL url)
FileURLLoader(URLClassLoader classloader, URL url, URL absoluteUrl)
FileURLLoader(URLClassLoader classloader, URL url) { super(classloader, url); dir = new File(baseURL.getFile()); }
super(classloader, url); dir = new File(baseURL.getFile());
super(classloader, url, absoluteUrl); dir = new File(absoluteUrl.getFile());
FileURLLoader(URLClassLoader classloader, URL url) { super(classloader, url); dir = new File(baseURL.getFile()); }
public JarURLLoader(URLClassLoader classloader, URL baseURL)
public JarURLLoader(URLClassLoader classloader, URL baseURL, URL absoluteUrl)
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; }
super(classloader, baseURL);
super(classloader, baseURL, absoluteUrl);
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; }
loader = new JarURLLoader(this, newUrl);
loader = new JarURLLoader(this, newUrl, absoluteURL);
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); } } } }
loader = new FileURLLoader(this, newUrl);
loader = new FileURLLoader(this, newUrl, absoluteURL);
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); } } } }
result.setBlock( result.getBlock()+superblock.getFirstDataBlock() );
result.setBlock(blockNr);
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 FileSystemException(String message, Throwable cause) { super(message, cause);
public FileSystemException() { super();
public FileSystemException(String message, Throwable cause) { super(message, cause); }
public BlockReservation(boolean successful, long block, int preallocCount, long freeBlocksCount) {
public BlockReservation(boolean successful, long block, int preallocCount) {
public BlockReservation(boolean successful, long block, int preallocCount, long freeBlocksCount) { this.successful = successful; this.block = block; this.preallocCount = preallocCount; this.freeBlocksCount = freeBlocksCount; }
this.freeBlocksCount = freeBlocksCount;
public BlockReservation(boolean successful, long block, int preallocCount, long freeBlocksCount) { this.successful = successful; this.block = block; this.preallocCount = preallocCount; this.freeBlocksCount = freeBlocksCount; }
public TreeModelEvent(Object source, Object[] path, int[] childIndices, Object[] children) {
public TreeModelEvent(Object source, Object[] path) {
public TreeModelEvent(Object source, Object[] path, int[] childIndices, Object[] children) { super(source); this.path = new TreePath(path); this.childIndices = childIndices; this.children = children; } // TreeModelEvent()
this.path = new TreePath(path); this.childIndices = childIndices; this.children = children; }
this.path = new TreePath(path); }
public TreeModelEvent(Object source, Object[] path, int[] childIndices, Object[] children) { super(source); this.path = new TreePath(path); this.childIndices = childIndices; this.children = children; } // TreeModelEvent()
vm.dumpStatistics(out);
public static void main(String[] args) { final Vm vm = getVm(); if ((vm != null) && !vm.isBootstrap()) { final PrintStream out = System.out; out.println("JNode VM " + vm.getVersion()); vm.getStatics().dumpStatistics(out); if (vm.hotMethodManager != null) { vm.hotMethodManager.dumpStatistics(out); } vm.heapManager.dumpStatistics(out); final SecurityManager sm = System.getSecurityManager(); out.println("Security manager: " + sm); } }
public File createFileObject(File directory, String filename) { return null; }
public File createFileObject(File dir, String filename) { return new File(dir, filename); }
public File createFileObject(File directory, String filename) { return null; // TODO } // createFileObject()
public abstract File createNewFolder(File file) throws IOException;
public abstract File createNewFolder(File containingDir) throws IOException;
public abstract File createNewFolder(File file) throws IOException;
public static FileSystemView getFileSystemView() { return null; }
public static FileSystemView getFileSystemView() { if (File.separator.equals("/")) return new UnixFileSystemView(); return null; }
public static FileSystemView getFileSystemView() { return null; // TODO } // getFileSystemView()
public File[] getFiles(File directory, boolean fileHiding) { return null; }
public File[] getFiles(File dir, boolean useFileHiding) { if (dir == null) return null; File[] files = dir.listFiles(); if (! useFileHiding) return files; ArrayList trim = new ArrayList(); for (int i = 0; i < files.length; i++) if (! files[i].isHidden()) trim.add(files[i]); File[] value = (File[]) trim.toArray(new File[0]); return value; }
public File[] getFiles(File directory, boolean fileHiding) { return null; // TODO } // getFiles()
public File getHomeDirectory() { return null; }
public File getHomeDirectory() { return createFileObject(System.getProperty("user.home")); }
public File getHomeDirectory() { return null; // TODO } // getHomeDirectory()
public File getParentDirectory(File directory) { return null; }
public File getParentDirectory(File f) { if (f == null) return null; return f.getParentFile(); }
public File getParentDirectory(File directory) { return null; // TODO } // getParentDirectory()
public abstract File[] getRoots();
public File[] getRoots() { return null; }
public abstract File[] getRoots();
public abstract boolean isHiddenFile(File file);
public boolean isHiddenFile(File f) { return f.isHidden(); }
public abstract boolean isHiddenFile(File file);
public abstract boolean isRoot(File file);
public boolean isRoot(File f) { return false; }
public abstract boolean isRoot(File file);
showMe_itemStateChanged(e);
hideTabBar_itemStateChanged(e);
public void itemStateChanged(ItemEvent e) { showMe_itemStateChanged(e); }
sessions.requestFocus();
addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { sessions.requestFocus(); } }); } });
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); }
addLabelComponent("", sdn, sip); sdn.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { doItemStateChanged(e); } });
public static void doEntry(Frame parent, String propKey, Properties props) { confTabs = new JTabbedPane(); ec = new JCheckBox(LangTool.getString("conf.labelEnhanced")); tc = new JCheckBox(LangTool.getString("conf.labelUseSystemName")); useProxy = new JCheckBox(LangTool.getString("conf.labelUseProxy")); sdNormal = new JRadioButton(LangTool.getString("conf.label24")); JRadioButton sdBig = new JRadioButton(LangTool.getString("conf.label27")); noEmbed = new JCheckBox(LangTool.getString("conf.labelEmbed")); deamon = new JCheckBox(LangTool.getString("conf.labelDeamon")); newJVM = new JCheckBox(LangTool.getString("conf.labelNewJVM")); cpb = new JComboBox(); String[] availCP = CharMappings.getAvailableCodePages(); cpb.addItem(LangTool.getString("conf.labelDefault")); for (int x = 0; x < availCP.length; x++) { cpb.addItem(availCP[x]); } sslType = new JComboBox(); for (int x = 0; x < SSL_TYPES.length; x++) { sslType.addItem(SSL_TYPES[x]); } if (propKey == null) { systemName = new JTextField(20); systemId = new JTextField(20); port = new JTextField("23",5); deviceName = new JTextField(20); fpn = new JTextField(20); proxyHost = new JTextField(20); proxyPort = new JTextField("1080",5); ec.setSelected(true); tc.setSelected(true); sdNormal.setSelected(true); deamon.setSelected(true); } else { String[] args = new String[20]; parseArgs((String)props.get(propKey),args); systemName = new JTextField(propKey,20); systemName.setEditable(false); systemName.setEnabled(false); systemId = new JTextField(args[0],20); if (isSpecified("-p",args)) { port = new JTextField(getParm("-p",args),5); } else { port = new JTextField("23",5); } if (isSpecified("-sslType",args)) sslType.setSelectedItem(getParm("-sslType",args)); if (isSpecified("-sph",args)) proxyHost = new JTextField(getParm("-sph",args),20); else proxyHost = new JTextField(20); if (isSpecified("-f",args)) fpn = new JTextField(getParm("-f",args),20); else fpn = new JTextField(20); if (isSpecified("-cp",args)) cpb.setSelectedItem(getParm("-cp",args)); if (isSpecified("-e",args)) ec.setSelected(true); else ec.setSelected(false); if (isSpecified("-t",args)) tc.setSelected(true); else tc.setSelected(false); if (isSpecified("-132",args)) sdBig.setSelected(true); else sdNormal.setSelected(true); if (isSpecified("-dn",args)) deviceName = new JTextField(getParm("-dn",args),20); else deviceName = new JTextField(20); if (isSpecified("-spp",args)) { proxyPort = new JTextField(getParm("-spp",args),5); } else { proxyPort = new JTextField("1080",5); } if (isSpecified("-usp",args)) useProxy.setSelected(true); else useProxy.setSelected(false); if (isSpecified("-noembed",args)) noEmbed.setSelected(true); else noEmbed.setSelected(false); if (isSpecified("-d",args)) deamon.setSelected(true); else deamon.setSelected(false); if (isSpecified("-nc",args)) newJVM.setSelected(true); else newJVM.setSelected(false); } //Create main attributes panel JPanel mp = new JPanel(); BoxLayout mpLayout = new BoxLayout(mp,BoxLayout.Y_AXIS); mp.setLayout(mpLayout); //System Name panel JPanel snp = new JPanel(); AlignLayout snpLayout = new AlignLayout(2,5,5); snp.setLayout(snpLayout); snp.setBorder(BorderFactory.createEtchedBorder()); addLabelComponent(LangTool.getString("conf.labelSystemName"), systemName, snp); addLabelComponent(" ", noEmbed, snp); addLabelComponent(" ", deamon, snp); addLabelComponent(" ", newJVM, snp); //System Id panel JPanel sip = new JPanel(); AlignLayout al = new AlignLayout(2,5,5); sip.setLayout(al); sip.setBorder(BorderFactory.createTitledBorder( LangTool.getString("conf.labelSystemIdTitle"))); addLabelComponent(LangTool.getString("conf.labelSystemId"), systemId, sip); addLabelComponent(LangTool.getString("conf.labelPort"), port, sip); addLabelComponent(LangTool.getString("conf.labelDeviceName"), deviceName, sip); addLabelComponent(LangTool.getString("conf.labelSSLType"), sslType, sip); // options panel JPanel op = new JPanel(); BoxLayout opLayout = new BoxLayout(op,BoxLayout.Y_AXIS); op.setLayout(opLayout); op.setBorder(BorderFactory.createTitledBorder( LangTool.getString("conf.labelOptionsTitle"))); // file name panel JPanel fp = new JPanel(); BoxLayout fpLayout = new BoxLayout(fp,BoxLayout.Y_AXIS); fp.setLayout(fpLayout); fp.setBorder(BorderFactory.createTitledBorder( LangTool.getString("conf.labelConfFile"))); fp.add(fpn); // screen dimensions panel JPanel sdp = new JPanel(); BoxLayout sdpLayout = new BoxLayout(sdp,BoxLayout.X_AXIS); sdp.setLayout(sdpLayout); sdp.setBorder(BorderFactory.createTitledBorder( LangTool.getString("conf.labelDimensions"))); // Group the radio buttons. ButtonGroup sdGroup = new ButtonGroup(); sdGroup.add(sdNormal); sdGroup.add(sdBig); sdp.add(sdNormal); sdp.add(sdBig); // code page panel JPanel cp = new JPanel(); BoxLayout cpLayout = new BoxLayout(cp,BoxLayout.Y_AXIS); cp.setLayout(cpLayout); cp.setBorder(BorderFactory.createTitledBorder( LangTool.getString("conf.labelCodePage"))); cp.add(cpb); // emulation mode panel JPanel ep = new JPanel(); BoxLayout epLayout = new BoxLayout(ep,BoxLayout.X_AXIS); ep.setLayout(epLayout); ep.setBorder(BorderFactory.createTitledBorder( LangTool.getString("conf.labelEmulateMode"))); ep.add(ec); // title to be use panel JPanel tp = new JPanel(); BoxLayout tpLayout = new BoxLayout(tp,BoxLayout.X_AXIS); tp.setLayout(tpLayout); tp.setBorder(BorderFactory.createTitledBorder( "")); addLabelComponent("", tc, tp); // add all options to Options panel op.add(fp); op.add(sdp); op.add(cp); op.add(ep); op.add(tp); //System Id panel JPanel sprox = new JPanel(); AlignLayout spal = new AlignLayout(2,5,5); sprox.setLayout(spal); sprox.setBorder(BorderFactory.createEtchedBorder()); addLabelComponent("", useProxy, sprox); addLabelComponent(LangTool.getString("conf.labelProxyHost"), proxyHost, sprox); addLabelComponent(LangTool.getString("conf.labelProxyPort"), proxyPort, sprox); confTabs.addTab(LangTool.getString("conf.tabGeneral"),snp); confTabs.addTab(LangTool.getString("conf.tabTCP"),sip); confTabs.addTab(LangTool.getString("conf.tabOptions"),op); confTabs.addTab(LangTool.getString("conf.tabProxy"),sprox); systemName.setAlignmentX(Component.CENTER_ALIGNMENT); systemId.setAlignmentX(Component.CENTER_ALIGNMENT); fpn.setAlignmentX(Component.CENTER_ALIGNMENT); cpb.setAlignmentX(Component.CENTER_ALIGNMENT); Object[] message = new Object[1]; message[0] = confTabs; String[] options = new String[2]; String title; if (propKey == null) { options[0] = LangTool.getString("conf.optAdd"); title = LangTool.getString("conf.addEntryATitle"); } else { options[0] = LangTool.getString("conf.optEdit"); title = LangTool.getString("conf.addEntryETitle"); } options[1] = LangTool.getString("conf.optCancel"); int result = JOptionPane.showOptionDialog( parent, // the parent that the dialog blocks message, // the dialog message array title, // the title of the dialog window JOptionPane.DEFAULT_OPTION, // option type JOptionPane.PLAIN_MESSAGE, // message type null, // optional icon, use null to use the default icon options, // options string array, will be made into buttons// options[0] // option that should be made into a default button ); if (result == 0) { if (propKey == null) { props.put(systemName.getText(),toArgString()); } else { props.setProperty(systemName.getText(),toArgString()); } } }
public final boolean hasFeature(int feature) { return ((this.features & feature) == feature);
public final boolean hasFeature(long feature) { return ((this.exFeatures & feature) == feature);
public final boolean hasFeature(int feature) { return ((this.features & feature) == feature); }