-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
}
return false;
}
+
+ public int[] stateSummary() {
+ return new int[] { field_1_font_index, field_2_format_index, field_3_cell_options, field_4_alignment_options,
+ field_5_indention_options, field_6_border_options, field_7_palette_options, field_8_adtl_palette_options, field_9_fill_palette_options };
+ }
}
}
+ // variables for performance optimization:
+ // avoid re-checking DataUtil.isADateFormat(int, String) if a given format
+ // string represents a date format if the same string is passed multiple times.
+ // see https://issues.apache.org/bugzilla/show_bug.cgi?id=55611
+ private static int lastFormatIndex = -1;
+ private static String lastFormatString = null;
+ private static boolean cached = false;
+
/**
* Given a format ID and its format String, will check to see if the
* format represents a date format or not.
* @param formatString The format string, eg from FormatRecord.getFormatString
* @see #isInternalDateFormat(int)
*/
+
public static boolean isADateFormat(int formatIndex, String formatString) {
+
+ if (formatString != null && formatIndex == lastFormatIndex && formatString.equals(lastFormatString)) {
+ return cached;
+ }
// First up, is this an internal date format?
if(isInternalDateFormat(formatIndex)) {
+ lastFormatIndex = formatIndex;
+ lastFormatString = formatString;
+ cached = true;
return true;
}
// If we didn't get a real string, it can't be
if(formatString == null || formatString.length() == 0) {
+ lastFormatIndex = formatIndex;
+ lastFormatString = formatString;
+ cached = false;
return false;
}
// short-circuit if it indicates elapsed time: [h], [m] or [s]
if(date_ptrn4.matcher(fs).matches()){
+ lastFormatIndex = formatIndex;
+ lastFormatString = formatString;
+ cached = true;
return true;
}
// If we get here, check it's only made up, in any case, of:
// y m d h s - \ / , . : [ ]
// optionally followed by AM/PM
- return date_ptrn3b.matcher(fs).matches();
+
+ boolean result = date_ptrn3b.matcher(fs).matches();
+ lastFormatIndex = formatIndex;
+ lastFormatString = formatString;
+ cached = result;
+ return result;
}
/**