From 84a5a27dc1c6459861a3e4a29ba629d5c41eb8f4 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Tue, 7 Jun 2016 07:39:40 +0000 Subject: [PATCH] make emulateCSV final, add a single common all-inclusive (private) constructor that all other constructors tree up to and invert the constructors git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1747163 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/ss/usermodel/DataFormatter.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java index ad7178cd7e..308445f9ca 100644 --- a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java +++ b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java @@ -201,7 +201,7 @@ public class DataFormatter implements Observer { */ private final Map formats = new HashMap(); - private boolean emulateCSV = false; + private final boolean emulateCSV; /** stores the locale valid it the last formatting call */ private Locale locale; @@ -232,7 +232,6 @@ public class DataFormatter implements Observer { */ public DataFormatter() { this(false); - this.localeIsAdapting = true; } /** @@ -241,8 +240,14 @@ public class DataFormatter implements Observer { * @param emulateCSV whether to emulate CSV output. */ public DataFormatter(boolean emulateCSV) { - this(LocaleUtil.getUserLocale(), emulateCSV); - this.localeIsAdapting = true; + this(LocaleUtil.getUserLocale(), true, emulateCSV); + } + + /** + * Creates a formatter using the given locale. + */ + public DataFormatter(Locale locale) { + this(locale, false); } /** @@ -251,17 +256,19 @@ public class DataFormatter implements Observer { * @param emulateCSV whether to emulate CSV output. */ public DataFormatter(Locale locale, boolean emulateCSV) { - this(locale); - this.emulateCSV = emulateCSV; + this(locale, false, emulateCSV); } /** * Creates a formatter using the given locale. + * @param localeIsAdapting (true only if locale is not user-specified) + * @param emulateCSV whether to emulate CSV output. */ - public DataFormatter(Locale locale) { + private DataFormatter(Locale locale, boolean localeIsAdapting, boolean emulateCSV) { localeChangedObservable.addObserver(this); localeChangedObservable.checkForLocaleChange(locale); - this.localeIsAdapting = false; + this.localeIsAdapting = localeIsAdapting; + this.emulateCSV = emulateCSV; } /** -- 2.39.5