svn commit: r645561 - in /ofbiz/trunk/framework: base/src/base/org/ofbiz/base/util/UtilProperties.java entity/src/org/ofbiz/entity/GenericEntity.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r645561 - in /ofbiz/trunk/framework: base/src/base/org/ofbiz/base/util/UtilProperties.java entity/src/org/ofbiz/entity/GenericEntity.java

jonesde
Author: jonesde
Date: Mon Apr  7 08:21:26 2008
New Revision: 645561

URL: http://svn.apache.org/viewvc?rev=645561&view=rev
Log:
Small refactor to preserve protected Map in UtilProperties

Modified:
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java?rev=645561&r1=645560&r2=645561&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java Mon Apr  7 08:21:26 2008
@@ -73,6 +73,12 @@
      */
     protected static UtilCache<String, FlexibleProperties> urlCache = new UtilCache<String, FlexibleProperties>("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();
+    
     /** 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'
      * @param name The name of the property in the properties file
@@ -536,9 +542,6 @@
 
     // ========= Classes and Methods for expanded Properties file support ========== //
 
-    public static final Locale LOCALE_ROOT = new Locale("", "", "");
-
-    protected static Locale fallbackLocale = null;
     /** Returns the configured fallback locale. UtilProperties uses this locale
      * to resolve locale-specific XML properties.<p>The fallback locale can be
      * configured using the <code>locale.properties.fallback</code> property in
@@ -581,7 +584,6 @@
         return localeList;
     }
 
-    protected static Set<Locale> defaultCandidateLocales = null;
     /** Returns the default candidate Locale list. The list is populated
      * with the JVM's default locale, the OFBiz fallback locale, and
      * the <code>LOCALE_ROOT</code> (empty) locale - in that order.
@@ -645,8 +647,11 @@
         }
         return resourceName;
     }
+    
+    public static boolean isPropertyNotFound(String resource, Locale locale, boolean removeExtension) {
+        return propertiesNotFound.contains(UtilProperties.createResourceName(resource, locale, removeExtension));
+    }
 
-    public static Set<String> propertiesNotFound = FastSet.newInstance();
     /** Resolve a properties file URL.
      * <p>This method uses the following strategy:<br />
      * <ul>

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java?rev=645561&r1=645560&r2=645561&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java Mon Apr  7 08:21:26 2008
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *******************************************************************************/
+ */
 package org.ofbiz.entity;
 
 import java.io.PrintWriter;
@@ -723,7 +723,7 @@
                 return fieldValue;
             }
         }
-        if (UtilProperties.propertiesNotFound.contains(UtilProperties.createResourceName(resource, locale, false))) {
+        if (UtilProperties.isPropertyNotFound(resource, locale, false)) {
             // Properties do not exist for this resource+locale combination
             return fieldValue;
         }


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r645561 - in /ofbiz/trunk/framework: base/src/base/org/ofbiz/base/util/UtilProperties.java entity/src/org/ofbiz/entity/GenericEntity.java

Adrian Crum
David,

Thanks for doing this. I happened to be working on a similar approach
myself, only I was moving the propertiesNotFound checking code to the
UtilProperties.getResourceBundle method.

-Adrian

[hidden email] wrote:

> Author: jonesde
> Date: Mon Apr  7 08:21:26 2008
> New Revision: 645561
>
> URL: http://svn.apache.org/viewvc?rev=645561&view=rev
> Log:
> Small refactor to preserve protected Map in UtilProperties
>
> Modified:
>     ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java
>     ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java
>
> Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java?rev=645561&r1=645560&r2=645561&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java (original)
> +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java Mon Apr  7 08:21:26 2008
> @@ -73,6 +73,12 @@
>       */
>      protected static UtilCache<String, FlexibleProperties> urlCache = new UtilCache<String, FlexibleProperties>("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();
> +    
>      /** 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'
>       * @param name The name of the property in the properties file
> @@ -536,9 +542,6 @@
>  
>      // ========= Classes and Methods for expanded Properties file support ========== //
>  
> -    public static final Locale LOCALE_ROOT = new Locale("", "", "");
> -
> -    protected static Locale fallbackLocale = null;
>      /** Returns the configured fallback locale. UtilProperties uses this locale
>       * to resolve locale-specific XML properties.<p>The fallback locale can be
>       * configured using the <code>locale.properties.fallback</code> property in
> @@ -581,7 +584,6 @@
>          return localeList;
>      }
>  
> -    protected static Set<Locale> defaultCandidateLocales = null;
>      /** Returns the default candidate Locale list. The list is populated
>       * with the JVM's default locale, the OFBiz fallback locale, and
>       * the <code>LOCALE_ROOT</code> (empty) locale - in that order.
> @@ -645,8 +647,11 @@
>          }
>          return resourceName;
>      }
> +    
> +    public static boolean isPropertyNotFound(String resource, Locale locale, boolean removeExtension) {
> +        return propertiesNotFound.contains(UtilProperties.createResourceName(resource, locale, removeExtension));
> +    }
>  
> -    public static Set<String> propertiesNotFound = FastSet.newInstance();
>      /** Resolve a properties file URL.
>       * <p>This method uses the following strategy:<br />
>       * <ul>
>
> Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java?rev=645561&r1=645560&r2=645561&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java (original)
> +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java Mon Apr  7 08:21:26 2008
> @@ -1,4 +1,4 @@
> -/*******************************************************************************
> +/*
>   * Licensed to the Apache Software Foundation (ASF) under one
>   * or more contributor license agreements.  See the NOTICE file
>   * distributed with this work for additional information
> @@ -15,7 +15,7 @@
>   * KIND, either express or implied.  See the License for the
>   * specific language governing permissions and limitations
>   * under the License.
> - *******************************************************************************/
> + */
>  package org.ofbiz.entity;
>  
>  import java.io.PrintWriter;
> @@ -723,7 +723,7 @@
>                  return fieldValue;
>              }
>          }
> -        if (UtilProperties.propertiesNotFound.contains(UtilProperties.createResourceName(resource, locale, false))) {
> +        if (UtilProperties.isPropertyNotFound(resource, locale, false)) {
>              // Properties do not exist for this resource+locale combination
>              return fieldValue;
>          }
>
>
>