Whitespace and Javadoc
This commit is contained in:
parent
216e3fda5d
commit
e0d7fb81e2
|
@ -85,6 +85,7 @@ public class FastDateParser implements DateParser, Serializable {
|
||||||
* A strategy that handles a text field in the parsing pattern
|
* A strategy that handles a text field in the parsing pattern
|
||||||
*/
|
*/
|
||||||
private static final class CaseInsensitiveTextStrategy extends PatternStrategy {
|
private static final class CaseInsensitiveTextStrategy extends PatternStrategy {
|
||||||
|
|
||||||
private final int field;
|
private final int field;
|
||||||
final Locale locale;
|
final Locale locale;
|
||||||
private final Map<String, Integer> lKeyValues;
|
private final Map<String, Integer> lKeyValues;
|
||||||
|
@ -430,7 +431,6 @@ public class FastDateParser implements DateParser, Serializable {
|
||||||
if (currentIdx >= pattern.length()) {
|
if (currentIdx >= pattern.length()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final char c = pattern.charAt(currentIdx);
|
final char c = pattern.charAt(currentIdx);
|
||||||
if (isFormatLetter(c)) {
|
if (isFormatLetter(c)) {
|
||||||
return letterPattern(c);
|
return letterPattern(c);
|
||||||
|
@ -445,7 +445,6 @@ public class FastDateParser implements DateParser, Serializable {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final int width = currentIdx - begin;
|
final int width = currentIdx - begin;
|
||||||
return new StrategyAndWidth(getStrategy(c, width, definingCalendar), width);
|
return new StrategyAndWidth(getStrategy(c, width, definingCalendar), width);
|
||||||
}
|
}
|
||||||
|
@ -466,11 +465,9 @@ public class FastDateParser implements DateParser, Serializable {
|
||||||
++currentIdx;
|
++currentIdx;
|
||||||
sb.append(c);
|
sb.append(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activeQuote) {
|
if (activeQuote) {
|
||||||
throw new IllegalArgumentException("Unterminated quote");
|
throw new IllegalArgumentException("Unterminated quote");
|
||||||
}
|
}
|
||||||
|
|
||||||
final String formatField = sb.toString();
|
final String formatField = sb.toString();
|
||||||
return new StrategyAndWidth(new CopyQuotedStrategy(formatField), formatField.length());
|
return new StrategyAndWidth(new CopyQuotedStrategy(formatField), formatField.length());
|
||||||
}
|
}
|
||||||
|
@ -687,8 +684,6 @@ public class FastDateParser implements DateParser, Serializable {
|
||||||
|
|
||||||
private static final Strategy SECOND_STRATEGY = new NumberStrategy(Calendar.SECOND);
|
private static final Strategy SECOND_STRATEGY = new NumberStrategy(Calendar.SECOND);
|
||||||
|
|
||||||
// Support for strategies
|
|
||||||
|
|
||||||
private static final Strategy MILLISECOND_STRATEGY = new NumberStrategy(Calendar.MILLISECOND);
|
private static final Strategy MILLISECOND_STRATEGY = new NumberStrategy(Calendar.MILLISECOND);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -806,16 +801,13 @@ public class FastDateParser implements DateParser, Serializable {
|
||||||
* @param timeZone non-null time zone to use
|
* @param timeZone non-null time zone to use
|
||||||
* @param locale locale, null maps to the default Locale.
|
* @param locale locale, null maps to the default Locale.
|
||||||
* @param centuryStart The start of the century for 2 digit year parsing
|
* @param centuryStart The start of the century for 2 digit year parsing
|
||||||
*
|
|
||||||
* @since 3.5
|
* @since 3.5
|
||||||
*/
|
*/
|
||||||
protected FastDateParser(final String pattern, final TimeZone timeZone, final Locale locale, final Date centuryStart) {
|
protected FastDateParser(final String pattern, final TimeZone timeZone, final Locale locale, final Date centuryStart) {
|
||||||
this.pattern = Objects.requireNonNull(pattern, "pattern");
|
this.pattern = Objects.requireNonNull(pattern, "pattern");
|
||||||
this.timeZone = Objects.requireNonNull(timeZone, "timeZone");
|
this.timeZone = Objects.requireNonNull(timeZone, "timeZone");
|
||||||
this.locale = LocaleUtils.toLocale(locale);
|
this.locale = LocaleUtils.toLocale(locale);
|
||||||
|
|
||||||
final Calendar definingCalendar = Calendar.getInstance(timeZone, this.locale);
|
final Calendar definingCalendar = Calendar.getInstance(timeZone, this.locale);
|
||||||
|
|
||||||
final int centuryStartYear;
|
final int centuryStartYear;
|
||||||
if (centuryStart != null) {
|
if (centuryStart != null) {
|
||||||
definingCalendar.setTime(centuryStart);
|
definingCalendar.setTime(centuryStart);
|
||||||
|
@ -829,7 +821,6 @@ public class FastDateParser implements DateParser, Serializable {
|
||||||
}
|
}
|
||||||
century = centuryStartYear / 100 * 100;
|
century = centuryStartYear / 100 * 100;
|
||||||
startYear = centuryStartYear - century;
|
startYear = centuryStartYear - century;
|
||||||
|
|
||||||
init(definingCalendar);
|
init(definingCalendar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -844,7 +835,6 @@ public class FastDateParser implements DateParser, Serializable {
|
||||||
return twoDigitYear >= startYear ? trial : trial + 100;
|
return twoDigitYear >= startYear ? trial : trial + 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Basics
|
|
||||||
/**
|
/**
|
||||||
* Compares another object for equality with this object.
|
* Compares another object for equality with this object.
|
||||||
*
|
*
|
||||||
|
@ -882,7 +872,7 @@ public class FastDateParser implements DateParser, Serializable {
|
||||||
return cache.computeIfAbsent(locale,
|
return cache.computeIfAbsent(locale,
|
||||||
k -> field == Calendar.ZONE_OFFSET ? new TimeZoneStrategy(locale) : new CaseInsensitiveTextStrategy(field, definingCalendar, locale));
|
k -> field == Calendar.ZONE_OFFSET ? new TimeZoneStrategy(locale) : new CaseInsensitiveTextStrategy(field, definingCalendar, locale));
|
||||||
}
|
}
|
||||||
// Accessors
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -1022,7 +1012,6 @@ public class FastDateParser implements DateParser, Serializable {
|
||||||
// timing tests indicate getting new instance is 19% faster than cloning
|
// timing tests indicate getting new instance is 19% faster than cloning
|
||||||
final Calendar cal = Calendar.getInstance(timeZone, locale);
|
final Calendar cal = Calendar.getInstance(timeZone, locale);
|
||||||
cal.clear();
|
cal.clear();
|
||||||
|
|
||||||
return parse(source, pos, cal) ? cal.getTime() : null;
|
return parse(source, pos, cal) ? cal.getTime() : null;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -1078,7 +1067,6 @@ public class FastDateParser implements DateParser, Serializable {
|
||||||
*/
|
*/
|
||||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
|
|
||||||
final Calendar definingCalendar = Calendar.getInstance(timeZone, locale);
|
final Calendar definingCalendar = Calendar.getInstance(timeZone, locale);
|
||||||
init(definingCalendar);
|
init(definingCalendar);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue