From f57dc2ac03abe471865b3dc899bf7cce5162fcb3 Mon Sep 17 00:00:00 2001 From: Scott Russell Date: Tue, 22 Sep 2015 04:17:27 +0000 Subject: [PATCH] ICU-11572 review updates X-SVN-Rev: 37982 --- .../core/src/com/ibm/icu/text/DateFormat.java | 19 ++++++++++++++++++- .../com/ibm/icu/text/SimpleDateFormat.java | 5 +++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/DateFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/DateFormat.java index f8c7667e98..9b4be4dbbd 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/DateFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/DateFormat.java @@ -502,7 +502,12 @@ public abstract class DateFormat extends UFormat { * @provisional This API might change or be removed in a future release. */ PARSE_PARTIAL_LITERAL_MATCH, - // old name left in for previous serialization checks + /** + * alias of PARSE_PARTIAL_LITERAL_MATCH + * @internal + * @deprecated + */ + @Deprecated PARSE_PARTIAL_MATCH }; @@ -1589,6 +1594,9 @@ public abstract class DateFormat extends UFormat { */ public DateFormat setBooleanAttribute(BooleanAttribute key, boolean value) { + if(key.equals(DateFormat.BooleanAttribute.PARSE_PARTIAL_MATCH)) { + key = DateFormat.BooleanAttribute.PARSE_PARTIAL_LITERAL_MATCH; + } if(value) { booleanAttributes.add(key); @@ -1611,6 +1619,9 @@ public abstract class DateFormat extends UFormat { */ public boolean getBooleanAttribute(BooleanAttribute key) { + if(key == DateFormat.BooleanAttribute.PARSE_PARTIAL_MATCH) { + key = DateFormat.BooleanAttribute.PARSE_PARTIAL_LITERAL_MATCH; + } return booleanAttributes.contains(key); } @@ -1740,6 +1751,12 @@ public abstract class DateFormat extends UFormat { // Didn't have capitalizationSetting, set it to default capitalizationSetting = DisplayContext.CAPITALIZATION_NONE; } + + // if deserialized from a release that didn't have booleanAttributes, add them all + if(booleanAttributes == null) { + booleanAttributes = EnumSet.allOf(BooleanAttribute.class); + } + serialVersionOnStream = currentSerialVersion; } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java index e42b59dd21..e8fc746539 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/SimpleDateFormat.java @@ -3681,6 +3681,11 @@ public class SimpleDateFormat extends DateFormat { } } } + + // if serialized pre-56 update & turned off partial match switch to new enum value + if(getBooleanAttribute(DateFormat.BooleanAttribute.PARSE_PARTIAL_MATCH) == false) { + setBooleanAttribute(DateFormat.BooleanAttribute.PARSE_PARTIAL_LITERAL_MATCH, false); + } } /**