mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-09 11:34:55 +00:00
Fix some formatting.
This commit is contained in:
parent
b03b21b449
commit
c6314067f0
@ -124,7 +124,8 @@ protected FastDateParser(final String pattern, final TimeZone timeZone, final Lo
|
|||||||
*
|
*
|
||||||
* @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 = pattern;
|
this.pattern = pattern;
|
||||||
this.timeZone = timeZone;
|
this.timeZone = timeZone;
|
||||||
this.locale = LocaleUtils.toLocale(locale);
|
this.locale = LocaleUtils.toLocale(locale);
|
||||||
@ -297,9 +298,7 @@ public boolean equals(final Object obj) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final FastDateParser other = (FastDateParser) obj;
|
final FastDateParser other = (FastDateParser) obj;
|
||||||
return pattern.equals(other.pattern)
|
return pattern.equals(other.pattern) && timeZone.equals(other.timeZone) && locale.equals(other.locale);
|
||||||
&& timeZone.equals(other.timeZone)
|
|
||||||
&& locale.equals(other.locale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -357,9 +356,8 @@ public Date parse(final String source) throws ParseException {
|
|||||||
if (date == null) {
|
if (date == null) {
|
||||||
// Add a note re supported date range
|
// Add a note re supported date range
|
||||||
if (locale.equals(JAPANESE_IMPERIAL)) {
|
if (locale.equals(JAPANESE_IMPERIAL)) {
|
||||||
throw new ParseException(
|
throw new ParseException("(The " + locale + " locale does not support dates before 1868 AD)\n"
|
||||||
"(The " +locale + " locale does not support dates before 1868 AD)\n" +
|
+ "Unparseable date: \"" + source, pp.getErrorIndex());
|
||||||
"Unparseable date: \""+source, pp.getErrorIndex());
|
|
||||||
}
|
}
|
||||||
throw new ParseException("Unparseable date: " + source, pp.getErrorIndex());
|
throw new ParseException("Unparseable date: " + source, pp.getErrorIndex());
|
||||||
}
|
}
|
||||||
@ -460,7 +458,8 @@ private static StringBuilder simpleQuote(final StringBuilder sb, final String va
|
|||||||
* @param regex The regular expression to build
|
* @param regex The regular expression to build
|
||||||
* @return The map of string display names to field values
|
* @return The map of string display names to field values
|
||||||
*/
|
*/
|
||||||
private static Map<String, Integer> appendDisplayNames(final Calendar cal, Locale locale, final int field, final StringBuilder regex) {
|
private static Map<String, Integer> appendDisplayNames(final Calendar cal, Locale locale, final int field,
|
||||||
|
final StringBuilder regex) {
|
||||||
final Map<String, Integer> values = new HashMap<>();
|
final Map<String, Integer> values = new HashMap<>();
|
||||||
locale = LocaleUtils.toLocale(locale);
|
locale = LocaleUtils.toLocale(locale);
|
||||||
final Map<String, Integer> displayNames = cal.getDisplayNames(field, Calendar.ALL_STYLES, locale);
|
final Map<String, Integer> displayNames = cal.getDisplayNames(field, Calendar.ALL_STYLES, locale);
|
||||||
@ -491,9 +490,9 @@ private int adjustYear(final int twoDigitYear) {
|
|||||||
* A strategy to parse a single field from the parsing pattern
|
* A strategy to parse a single field from the parsing pattern
|
||||||
*/
|
*/
|
||||||
private abstract static class Strategy {
|
private abstract static class Strategy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this field a number?
|
* Is this field a number? The default implementation returns false.
|
||||||
* The default implementation returns false.
|
|
||||||
*
|
*
|
||||||
* @return true, if field is a number
|
* @return true, if field is a number
|
||||||
*/
|
*/
|
||||||
@ -501,7 +500,8 @@ boolean isNumber() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract boolean parse(FastDateParser parser, Calendar calendar, String source, ParsePosition pos, int maxWidth);
|
abstract boolean parse(FastDateParser parser, Calendar calendar, String source, ParsePosition pos,
|
||||||
|
int maxWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -520,8 +520,7 @@ void createPattern(final String regex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this field a number?
|
* Is this field a number? The default implementation returns false.
|
||||||
* The default implementation returns false.
|
|
||||||
*
|
*
|
||||||
* @return true, if field is a number
|
* @return true, if field is a number
|
||||||
*/
|
*/
|
||||||
@ -531,7 +530,8 @@ boolean isNumber() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean parse(final FastDateParser parser, final Calendar calendar, final String source, final ParsePosition pos, final int maxWidth) {
|
boolean parse(final FastDateParser parser, final Calendar calendar, final String source,
|
||||||
|
final ParsePosition pos, final int maxWidth) {
|
||||||
final Matcher matcher = pattern.matcher(source.substring(pos.getIndex()));
|
final Matcher matcher = pattern.matcher(source.substring(pos.getIndex()));
|
||||||
if (!matcher.lookingAt()) {
|
if (!matcher.lookingAt()) {
|
||||||
pos.setErrorIndex(pos.getIndex());
|
pos.setErrorIndex(pos.getIndex());
|
||||||
@ -631,8 +631,7 @@ private Strategy getLocaleSpecificStrategy(final int field, final Calendar defin
|
|||||||
final ConcurrentMap<Locale, Strategy> cache = getCache(field);
|
final ConcurrentMap<Locale, Strategy> cache = getCache(field);
|
||||||
Strategy strategy = cache.get(locale);
|
Strategy strategy = cache.get(locale);
|
||||||
if (strategy == null) {
|
if (strategy == null) {
|
||||||
strategy = field == Calendar.ZONE_OFFSET
|
strategy = field == Calendar.ZONE_OFFSET ? new TimeZoneStrategy(locale)
|
||||||
? new TimeZoneStrategy(locale)
|
|
||||||
: new CaseInsensitiveTextStrategy(field, definingCalendar, locale);
|
: new CaseInsensitiveTextStrategy(field, definingCalendar, locale);
|
||||||
final Strategy inCache = cache.putIfAbsent(locale, strategy);
|
final Strategy inCache = cache.putIfAbsent(locale, strategy);
|
||||||
if (inCache != null) {
|
if (inCache != null) {
|
||||||
@ -651,6 +650,7 @@ private static class CopyQuotedStrategy extends Strategy {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a Strategy that ensures the formatField has literal text
|
* Constructs a Strategy that ensures the formatField has literal text
|
||||||
|
*
|
||||||
* @param formatField The literal text to match
|
* @param formatField The literal text to match
|
||||||
*/
|
*/
|
||||||
CopyQuotedStrategy(final String formatField) {
|
CopyQuotedStrategy(final String formatField) {
|
||||||
@ -666,7 +666,8 @@ boolean isNumber() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean parse(final FastDateParser parser, final Calendar calendar, final String source, final ParsePosition pos, final int maxWidth) {
|
boolean parse(final FastDateParser parser, final Calendar calendar, final String source,
|
||||||
|
final ParsePosition pos, final int maxWidth) {
|
||||||
for (int idx = 0; idx < formatField.length(); ++idx) {
|
for (int idx = 0; idx < formatField.length(); ++idx) {
|
||||||
final int sIdx = idx + pos.getIndex();
|
final int sIdx = idx + pos.getIndex();
|
||||||
if (sIdx == source.length()) {
|
if (sIdx == source.length()) {
|
||||||
@ -693,6 +694,7 @@ private static class CaseInsensitiveTextStrategy extends PatternStrategy {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a Strategy that parses a Text field
|
* Constructs a Strategy that parses a Text field
|
||||||
|
*
|
||||||
* @param field The Calendar field
|
* @param field The Calendar field
|
||||||
* @param definingCalendar The Calendar to use
|
* @param definingCalendar The Calendar to use
|
||||||
* @param locale The Locale to use
|
* @param locale The Locale to use
|
||||||
@ -733,6 +735,7 @@ private static class NumberStrategy extends Strategy {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a Strategy that parses a Number field
|
* Constructs a Strategy that parses a Number field
|
||||||
|
*
|
||||||
* @param field The Calendar field
|
* @param field The Calendar field
|
||||||
*/
|
*/
|
||||||
NumberStrategy(final int field) {
|
NumberStrategy(final int field) {
|
||||||
@ -748,7 +751,8 @@ boolean isNumber() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean parse(final FastDateParser parser, final Calendar calendar, final String source, final ParsePosition pos, final int maxWidth) {
|
boolean parse(final FastDateParser parser, final Calendar calendar, final String source,
|
||||||
|
final ParsePosition pos, final int maxWidth) {
|
||||||
int idx = pos.getIndex();
|
int idx = pos.getIndex();
|
||||||
int last = source.length();
|
int last = source.length();
|
||||||
|
|
||||||
@ -789,6 +793,7 @@ boolean parse(final FastDateParser parser, final Calendar calendar, final String
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Make any modifications to parsed integer
|
* Make any modifications to parsed integer
|
||||||
|
*
|
||||||
* @param parser The parser
|
* @param parser The parser
|
||||||
* @param iValue The parsed integer
|
* @param iValue The parsed integer
|
||||||
* @return The modified value
|
* @return The modified value
|
||||||
@ -836,6 +841,7 @@ private static class TzInfo {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a Strategy that parses a TimeZone
|
* Constructs a Strategy that parses a TimeZone
|
||||||
|
*
|
||||||
* @param locale The Locale
|
* @param locale The Locale
|
||||||
*/
|
*/
|
||||||
TimeZoneStrategy(final Locale locale) {
|
TimeZoneStrategy(final Locale locale) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user