Those public methods were created in anticipation of the Java 6 classes that will replace them. I can put them back and deprecate them instead.
-Adrian --- On Tue, 1/12/10, Adam Heath <doo...@brainfood.com> wrote: > From: Adam Heath <doo...@brainfood.com> > Subject: Re: svn commit: r898338 - > /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java > To: dev@ofbiz.apache.org > Date: Tuesday, January 12, 2010, 5:17 PM > adri...@apache.org > wrote: > > Author: adrianc > > Date: Tue Jan 12 14:24:36 2010 > > New Revision: 898338 > > > > URL: http://svn.apache.org/viewvc?rev=898338&view=rev > > Log: > > First pass at converting UtilProperties.java to Java > 6, plus some small code cleanups. > > Where exactly is the 1.6 syntax you are using? It's > not in making > more class fields static. It's not in removing the > public methods(you > may have broken external code, please add the public static > methods > back). It's not in removing the DCL pattern. > > > > > Modified: > > > ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java > > > > Modified: > ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java > > URL: > > http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java?rev=898338&r1=898337&r2=898338&view=diff > > > ============================================================================== > > --- > ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java > (original) > > +++ > ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java > Tue Jan 12 14:24:36 2010 > > @@ -57,26 +57,20 @@ > > * (see the <a > href="#xmlToProperties(java.io.InputStream,%20java.util.Locale,%20java.util.Properties)">xmlToProperties</a> > > * method).</p> > > */ > > -...@suppresswarnings("serial") > > -public class UtilProperties implements > java.io.Serializable { > > +public class UtilProperties { > > > > public static final String module > = UtilProperties.class.getName(); > > - > > /** An instance of the generic > cache for storing the non-locale-specific properties. > > * Each Properties > instance is keyed by the resource String. > > */ > > - protected static UtilCache<String, > Properties> resourceCache = > UtilCache.createUtilCache("properties.UtilPropertiesResourceCache"); > > - > > + protected static final > UtilCache<String, Properties> resourceCache = > UtilCache.createUtilCache("properties.UtilPropertiesResourceCache"); > > /** An instance of the generic > cache for storing the non-locale-specific properties. > > * Each Properties > instance is keyed by the file's URL. > > */ > > - protected static UtilCache<String, > Properties> urlCache = > UtilCache.createUtilCache("properties.UtilPropertiesUrlCache"); > > - > > - public static final Locale LOCALE_ROOT > = new Locale("", "", ""); > > - > > - protected static Locale fallbackLocale > = null; > > - protected static Set<Locale> > defaultCandidateLocales = null; > > - protected static Set<String> > propertiesNotFound = FastSet.newInstance(); > > + protected static final > UtilCache<String, Properties> urlCache = > UtilCache.createUtilCache("properties.UtilPropertiesUrlCache"); > > + protected static final > Set<String> propertiesNotFound = > FastSet.newInstance(); > > + protected static final Locale > fallbackLocale = createFallbackLocale(); > > + protected static final > Set<Locale> defaultCandidateLocales = > createDefaultCandidateLocales(); > > > > /** Compares the specified > property to the compareString, returns true if they are the > same, false otherwise > > * @param resource The > name of the resource - if the properties file is > 'webevent.properties', the resource name is 'webevent' > > @@ -606,21 +600,16 @@ > > * > <code>general.properties</code>. > > * @return The > configured fallback locale > > */ > > - public static Locale > getFallbackLocale() { > > - if (fallbackLocale == > null) { > > - > synchronized (UtilProperties.class) { > > - > if (fallbackLocale == null) { > > - > String locale = > getPropertyValue("general", "locale.properties.fallback"); > > - > if (UtilValidate.isNotEmpty(locale)) { > > - > fallbackLocale = > UtilMisc.parseLocale(locale); > > - > } > > - > if (fallbackLocale == null) { > > - > fallbackLocale = > UtilMisc.parseLocale("en"); > > - > } > > - > } > > - } > > + protected static Locale > createFallbackLocale() { > > + String locale = > getPropertyValue("general", "locale.properties.fallback"); > > + Locale result = null; > > + if > (UtilValidate.isNotEmpty(locale)) { > > + result = > UtilMisc.parseLocale(locale); > > + } > > + if (result == null) { > > + result = > UtilMisc.parseLocale("en"); > > } > > - return fallbackLocale; > > + return result; > > } > > > > /** Converts a Locale instance to > a candidate Locale list. The list > > @@ -647,19 +636,12 @@ > > * the > <code>LOCALE_ROOT</code> (empty) locale - in > that order. > > * @return A list of > default candidate locales. > > */ > > - public static Set<Locale> > getDefaultCandidateLocales() { > > - if > (defaultCandidateLocales == null) { > > - > synchronized (UtilProperties.class) { > > - > if (defaultCandidateLocales == null) { > > - > defaultCandidateLocales = > FastSet.newInstance(); > > - > > defaultCandidateLocales.addAll(localeToCandidateList(Locale.getDefault())); > > - > // Change to Locale.ROOT in Java 6 > > - > > defaultCandidateLocales.add(LOCALE_ROOT); > > - > > defaultCandidateLocales.addAll(localeToCandidateList(getFallbackLocale())); > > - > } > > - } > > - } > > - return > defaultCandidateLocales; > > + protected static Set<Locale> > createDefaultCandidateLocales() { > > + Set<Locale> result > = FastSet.newInstance(); > > + > result.addAll(localeToCandidateList(Locale.getDefault())); > > + > result.addAll(localeToCandidateList(fallbackLocale)); > > + result.add(Locale.ROOT); > > + return result; > > You changed the position that ROOT gets added. > > Additionally, you should have done this as multiple > commits, changing > LOCALE_ROOT local variable to Locale.ROOT, then changing > the method > implementations. > > > > } > > > > /** Returns a list of candidate > locales based on a supplied locale. > > @@ -671,12 +653,12 @@ > > */ > > public static List<Locale> > getCandidateLocales(Locale locale) { > > // Java 6 > conformance > > - if > (LOCALE_ROOT.equals(locale)) { > > + if > (Locale.ROOT.equals(locale)) { > > return > UtilMisc.toList(locale); > > } > > Set<Locale> > localeSet = FastSet.newInstance(); > > > localeSet.addAll(localeToCandidateList(locale)); > > - > localeSet.addAll(getDefaultCandidateLocales()); > > + > localeSet.addAll(defaultCandidateLocales); > > List<Locale> > localeList = FastList.newInstance(); > > > localeList.addAll(localeSet); > > return localeList; > > > > > >