Class UtilProperties

  • All Implemented Interfaces:
    java.io.Serializable

    public final class UtilProperties
    extends java.lang.Object
    implements java.io.Serializable
    Generic Property Accessor with Cache - Utilities for working with properties files.

    UtilProperties divides properties files into two classes: non-locale-specific - which are used for application parameters, configuration settings, etc; and locale-specific - which are used for UI labels, system messages, etc. Each class of properties files is kept in its own cache.

    The locale-specific class of properties files can be in any one of three formats: the standard text-based key=value format (*.properties file), the Java XML properties format, and the OFBiz-specific XML file format (see the xmlToProperties method).

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String module  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Properties createProperties​(java.lang.String fileName)
      Returns a new Properties instance created from fileName.
      static java.lang.String createResourceName​(java.lang.String resource, java.util.Locale locale, boolean removeExtension)
      Create a localized resource name based on a resource name and a locale.
      static java.util.List<java.util.Locale> getCandidateLocales​(java.util.Locale locale)
      Returns a list of candidate locales based on a supplied locale.
      static java.util.Set<java.util.Locale> getDefaultCandidateLocales()
      Returns the default candidate Locale list.
      static java.util.Locale getFallbackLocale()
      Returns the configured fallback locale.
      static java.lang.String getMessage​(java.lang.String resource, java.lang.String name, java.lang.Object[] arguments, java.util.Locale locale)
      Returns the value of the specified property name from the specified resource/properties file corresponding to the given locale and replacing argument place holders with the given arguments using the MessageFormat class
      static <E> java.lang.String getMessage​(java.lang.String resource, java.lang.String name, java.util.List<E> arguments, java.util.Locale locale)
      Returns the value of the specified property name from the specified resource/properties file corresponding to the given locale and replacing argument place holders with the given arguments using the MessageFormat class
      static java.lang.String getMessage​(java.lang.String resource, java.lang.String name, java.util.Locale locale)
      Returns the value of the specified property name from the specified resource/properties file corresponding to the given locale.
      static java.lang.String getMessage​(java.lang.String resource, java.lang.String name, java.util.Map<java.lang.String,​? extends java.lang.Object> context, java.util.Locale locale)
      Returns the value of the specified property name from the specified resource/properties file corresponding to the given locale and replacing argument place holders with the given arguments using the FlexibleStringExpander class
      static java.lang.String getMessageList​(java.lang.String resource, java.lang.String name, java.util.Locale locale, java.lang.Object... arguments)  
      static java.lang.String getMessageMap​(java.lang.String resource, java.lang.String name, java.util.Locale locale, java.lang.Object... context)  
      static java.util.Properties getProperties​(java.lang.String resource)
      Returns the specified resource/properties file
      static java.util.Properties getProperties​(java.lang.String resource, java.util.Locale locale)
      Returns the specified resource/properties file.
      static java.util.Properties getProperties​(java.net.URL url)
      Returns the specified resource/properties file
      static java.math.BigDecimal getPropertyAsBigDecimal​(java.lang.String resource, java.lang.String name, java.math.BigDecimal defaultNumber)
      Returns a BigDecimal-Object of the specified property name from the specified resource/properties file.
      static java.math.BigInteger getPropertyAsBigInteger​(java.lang.String resource, java.lang.String name, java.math.BigInteger defaultNumber)
      Returns a BigInteger-Object of the specified property name from the specified resource/properties file.
      static java.lang.Boolean getPropertyAsBoolean​(java.lang.String resource, java.lang.String name, boolean defaultValue)
      Returns a Boolean-Object of the specified property name from the specified resource/properties file.
      static java.lang.Double getPropertyAsDouble​(java.lang.String resource, java.lang.String name, double defaultNumber)
      Returns a Double-Object of the specified property name from the specified resource/properties file.
      static java.lang.Float getPropertyAsFloat​(java.lang.String resource, java.lang.String name, float defaultNumber)
      Returns a Float-Object of the specified property name from the specified resource/properties file.
      static java.lang.Integer getPropertyAsInteger​(java.lang.String resource, java.lang.String name, int defaultNumber)
      Returns an Integer-Object of the specified property name from the specified resource/properties file.
      static java.lang.Long getPropertyAsLong​(java.lang.String resource, java.lang.String name, long defaultNumber)
      Returns a Long-Object of the specified property name from the specified resource/properties file.
      static double getPropertyNumber​(java.lang.String resource, java.lang.String name)  
      static double getPropertyNumber​(java.lang.String resource, java.lang.String name, double defaultValue)  
      static double getPropertyNumber​(java.net.URL url, java.lang.String name)  
      static double getPropertyNumber​(java.net.URL url, java.lang.String name, double defaultValue)  
      static java.lang.String getPropertyValue​(java.lang.String resource, java.lang.String name)
      Returns the value of the specified property name from the specified resource/properties file
      static java.lang.String getPropertyValue​(java.lang.String resource, java.lang.String name, java.lang.String defaultValue)
      Returns the value of the specified property name from the specified resource/properties file.
      static java.lang.String getPropertyValue​(java.net.URL url, java.lang.String name)
      Returns the value of the specified property name from the specified resource/properties file
      static java.lang.String getPropertyValue​(java.net.URL url, java.lang.String name, java.lang.String defaultValue)
      Returns the value of the specified property name from the specified resource/properties file.
      static java.util.ResourceBundle getResourceBundle​(java.lang.String resource, java.util.Locale locale)
      Returns the specified resource/properties file as a ResourceBundle
      static ResourceBundleMapWrapper getResourceBundleMap​(java.lang.String resource, java.util.Locale locale)
      Returns the specified resource/properties file as a Map with the original ResourceBundle in the Map under the key _RESOURCE_BUNDLE_
      static ResourceBundleMapWrapper getResourceBundleMap​(java.lang.String resource, java.util.Locale locale, java.util.Map<java.lang.String,​java.lang.Object> context)
      Returns the specified resource/properties file as a Map with the original ResourceBundle in the Map under the key _RESOURCE_BUNDLE_
      static java.lang.String getSplitPropertyValue​(java.net.URL url, java.lang.String name)
      Returns the value of a split property name from the specified resource/properties file Rather than specifying the property name the value of a name.X property is specified which will correspond to a value.X property whose value will be returned.
      static boolean isPropertiesResourceNotFound​(java.lang.String resource, java.util.Locale locale, boolean removeExtension)  
      static java.util.List<java.util.Locale> localeToCandidateList​(java.util.Locale locale)
      Converts a Locale instance to a candidate Locale list.
      static boolean propertyValueEquals​(java.lang.String resource, java.lang.String name, java.lang.String compareString)
      Compares the specified property to the compareString, returns true if they are the same, false otherwise
      static boolean propertyValueEquals​(java.net.URL url, java.lang.String name, java.lang.String compareString)
      Compares the specified property to the compareString, returns true if they are the same, false otherwise
      static boolean propertyValueEqualsIgnoreCase​(java.lang.String resource, java.lang.String name, java.lang.String compareString)
      Compares Ignoring Case the specified property to the compareString, returns true if they are the same, false otherwise
      static boolean propertyValueEqualsIgnoreCase​(java.net.URL url, java.lang.String name, java.lang.String compareString)
      Compares Ignoring Case the specified property to the compareString, returns true if they are the same, false otherwise
      static java.net.URL resolvePropertiesUrl​(java.lang.String resource, java.util.Locale locale)
      Resolve a properties file URL.
      static void setPropertyValue​(java.lang.String resource, java.lang.String name, java.lang.String value)
      Sets the specified value of the specified property name to the specified resource/properties file
      static void setPropertyValueInMemory​(java.lang.String resource, java.lang.String name, java.lang.String value)
      Sets the specified value of the specified property name to the specified resource/properties in memory, does not persist it
      static java.util.Properties xmlToProperties​(java.io.InputStream in, java.util.Locale locale, java.util.Properties properties)
      Convert XML property file to Properties instance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • module

        public static final java.lang.String module
    • Method Detail

      • propertyValueEquals

        public static boolean propertyValueEquals​(java.lang.String resource,
                                                  java.lang.String name,
                                                  java.lang.String compareString)
        Compares the specified property to the compareString, returns true if they are the same, false otherwise
        Parameters:
        resource - The name of the resource - if the properties file is 'webevent.properties', the resource name is 'webevent'
        name - The name of the property in the properties file
        compareString - The String to compare the property value to
        Returns:
        True if the strings are the same, false otherwise
      • propertyValueEqualsIgnoreCase

        public static boolean propertyValueEqualsIgnoreCase​(java.lang.String resource,
                                                            java.lang.String name,
                                                            java.lang.String compareString)
        Compares Ignoring Case the specified property to the compareString, returns true if they are the same, false otherwise
        Parameters:
        resource - The name of the resource - if the properties file is 'webevent.properties', the resource name is 'webevent'
        name - The name of the property in the properties file
        compareString - The String to compare the property value to
        Returns:
        True if the strings are the same, false otherwise
      • getPropertyValue

        public static java.lang.String getPropertyValue​(java.lang.String resource,
                                                        java.lang.String name,
                                                        java.lang.String defaultValue)
        Returns the value of the specified property name from the specified resource/properties file. If the specified property name or properties file is not found, the defaultValue is returned.
        Parameters:
        resource - The name of the resource - if the properties file is 'webevent.properties', the resource name is 'webevent'
        name - The name of the property in the properties file
        defaultValue - The value to return if the property is not found
        Returns:
        The value of the property in the properties file, or if not found then the defaultValue
      • getPropertyNumber

        public static double getPropertyNumber​(java.lang.String resource,
                                               java.lang.String name,
                                               double defaultValue)
      • getPropertyNumber

        public static double getPropertyNumber​(java.lang.String resource,
                                               java.lang.String name)
      • getPropertyAsBoolean

        public static java.lang.Boolean getPropertyAsBoolean​(java.lang.String resource,
                                                             java.lang.String name,
                                                             boolean defaultValue)
        Returns a Boolean-Object of the specified property name from the specified resource/properties file. If the specified property name or properties file is not found, the defaultValue is returned.
        Parameters:
        resource - The name of the resource - if the properties file is 'webevent.properties', the resource name is 'webevent'
        name - The name of the property in the properties file
        defaultValue - Optional: The Value to return if the property is not found or not the correct format.
        Returns:
        A Boolean-Object of the property; or if not found the defaultValue
      • getPropertyAsInteger

        public static java.lang.Integer getPropertyAsInteger​(java.lang.String resource,
                                                             java.lang.String name,
                                                             int defaultNumber)
        Returns an Integer-Object of the specified property name from the specified resource/properties file. If the specified property name or properties file is not found, the defaultNumber is returned.
        Parameters:
        resource - The name of the resource - if the properties file is 'webevent.properties', the resource name is 'webevent'
        name - The name of the property in the properties file
        defaultNumber - Optional: The Value to return if the property is not found.
        Returns:
        An Integer-Object of the property; or if not found the defaultNumber
      • getPropertyAsLong

        public static java.lang.Long getPropertyAsLong​(java.lang.String resource,
                                                       java.lang.String name,
                                                       long defaultNumber)
        Returns a Long-Object of the specified property name from the specified resource/properties file. If the specified property name or properties file is not found, the defaultNumber is returned.
        Parameters:
        resource - The name of the resource - if the properties file is 'webevent.properties', the resource name is 'webevent'
        name - The name of the property in the properties file
        defaultNumber - Optional: The Value to return if the property is not found.
        Returns:
        A Long-Object of the property; or if not found the defaultNumber
      • getPropertyAsFloat

        public static java.lang.Float getPropertyAsFloat​(java.lang.String resource,
                                                         java.lang.String name,
                                                         float defaultNumber)
        Returns a Float-Object of the specified property name from the specified resource/properties file. If the specified property name or properties file is not found, the defaultNumber is returned.
        Parameters:
        resource - The name of the resource - if the properties file is 'webevent.properties', the resource name is 'webevent'
        name - The name of the property in the properties file
        defaultNumber - Optional: The Value to return if the property is not found.
        Returns:
        A Long-Object of the property; or if not found the defaultNumber
      • getPropertyAsDouble

        public static java.lang.Double getPropertyAsDouble​(java.lang.String resource,
                                                           java.lang.String name,
                                                           double defaultNumber)
        Returns a Double-Object of the specified property name from the specified resource/properties file. If the specified property name or properties file is not found, the defaultNumber is returned.
        Parameters:
        resource - The name of the resource - if the properties file is 'webevent.properties', the resource name is 'webevent'
        name - The name of the property in the properties file
        defaultNumber - Optional: The Value to return if the property is not found.
        Returns:
        A Double-Object of the property; or if not found the defaultNumber
      • getPropertyAsBigInteger

        public static java.math.BigInteger getPropertyAsBigInteger​(java.lang.String resource,
                                                                   java.lang.String name,
                                                                   java.math.BigInteger defaultNumber)
        Returns a BigInteger-Object of the specified property name from the specified resource/properties file. If the specified property name or properties file is not found, the defaultNumber is returned.
        Parameters:
        resource - The name of the resource - if the properties file is 'webevent.properties', the resource name is 'webevent'
        name - The name of the property in the properties file
        defaultNumber - Optional: The Value to return if the property is not found.
        Returns:
        A BigInteger-Object of the property; or if not found the defaultNumber
      • getPropertyAsBigDecimal

        public static java.math.BigDecimal getPropertyAsBigDecimal​(java.lang.String resource,
                                                                   java.lang.String name,
                                                                   java.math.BigDecimal defaultNumber)
        Returns a BigDecimal-Object of the specified property name from the specified resource/properties file. If the specified property name or properties file is not found, the defaultNumber is returned.
        Parameters:
        resource - The name of the resource - if the properties file is 'webevent.properties', the resource name is 'webevent'
        name - The name of the property in the properties file
        defaultNumber - Optional: The Value to return if the property is not found.
        Returns:
        A BigDecimal-Object of the property; or if not found the defaultNumber
      • getPropertyValue

        public static java.lang.String getPropertyValue​(java.lang.String resource,
                                                        java.lang.String name)
        Returns the value of the specified property name from the specified resource/properties file
        Parameters:
        resource - The name of the resource - can be a file, class, or URL
        name - The name of the property in the properties file
        Returns:
        The value of the property in the properties file
      • createProperties

        public static java.util.Properties createProperties​(java.lang.String fileName)
        Returns a new Properties instance created from fileName.

        This method is intended for low-level framework classes that need to read properties files before OFBiz has been fully initialized.

        Parameters:
        fileName - The full name of the properties file ("foo.properties")
        Returns:
        A new Properties instance created from fileName, or null if the file was not found
        Throws:
        java.lang.IllegalArgumentException - if fileName is empty
        java.lang.IllegalStateException - if there was a problem reading the file
      • getProperties

        public static java.util.Properties getProperties​(java.lang.String resource)
        Returns the specified resource/properties file
        Parameters:
        resource - The name of the resource - can be a file, class, or URL
        Returns:
        The properties file
      • getProperties

        public static java.util.Properties getProperties​(java.net.URL url)
        Returns the specified resource/properties file
        Parameters:
        url - The URL to the resource
        Returns:
        The properties file
      • propertyValueEquals

        public static boolean propertyValueEquals​(java.net.URL url,
                                                  java.lang.String name,
                                                  java.lang.String compareString)
        Compares the specified property to the compareString, returns true if they are the same, false otherwise
        Parameters:
        url - URL object specifying the location of the resource
        name - The name of the property in the properties file
        compareString - The String to compare the property value to
        Returns:
        True if the strings are the same, false otherwise
      • propertyValueEqualsIgnoreCase

        public static boolean propertyValueEqualsIgnoreCase​(java.net.URL url,
                                                            java.lang.String name,
                                                            java.lang.String compareString)
        Compares Ignoring Case the specified property to the compareString, returns true if they are the same, false otherwise
        Parameters:
        url - URL object specifying the location of the resource
        name - The name of the property in the properties file
        compareString - The String to compare the property value to
        Returns:
        True if the strings are the same, false otherwise
      • getPropertyValue

        public static java.lang.String getPropertyValue​(java.net.URL url,
                                                        java.lang.String name,
                                                        java.lang.String defaultValue)
        Returns the value of the specified property name from the specified resource/properties file. If the specified property name or properties file is not found, the defaultValue is returned.
        Parameters:
        url - URL object specifying the location of the resource
        name - The name of the property in the properties file
        defaultValue - The value to return if the property is not found
        Returns:
        The value of the property in the properties file, or if not found then the defaultValue
      • getPropertyNumber

        public static double getPropertyNumber​(java.net.URL url,
                                               java.lang.String name,
                                               double defaultValue)
      • getPropertyNumber

        public static double getPropertyNumber​(java.net.URL url,
                                               java.lang.String name)
      • getPropertyValue

        public static java.lang.String getPropertyValue​(java.net.URL url,
                                                        java.lang.String name)
        Returns the value of the specified property name from the specified resource/properties file
        Parameters:
        url - URL object specifying the location of the resource
        name - The name of the property in the properties file
        Returns:
        The value of the property in the properties file
      • getSplitPropertyValue

        public static java.lang.String getSplitPropertyValue​(java.net.URL url,
                                                             java.lang.String name)
        Returns the value of a split property name from the specified resource/properties file Rather than specifying the property name the value of a name.X property is specified which will correspond to a value.X property whose value will be returned. X is a number from 1 to whatever and all values are checked until a name.X for a certain X is not found.
        Parameters:
        url - URL object specifying the location of the resource
        name - The name of the split property in the properties file
        Returns:
        The value of the split property from the properties file
      • setPropertyValue

        public static void setPropertyValue​(java.lang.String resource,
                                            java.lang.String name,
                                            java.lang.String value)
        Sets the specified value of the specified property name to the specified resource/properties file
        Parameters:
        resource - The name of the resource - must be a file
        name - The name of the property in the properties file
        value - The value of the property in the properties file
      • setPropertyValueInMemory

        public static void setPropertyValueInMemory​(java.lang.String resource,
                                                    java.lang.String name,
                                                    java.lang.String value)
        Sets the specified value of the specified property name to the specified resource/properties in memory, does not persist it
        Parameters:
        resource - The name of the resource
        name - The name of the property in the resource
        value - The value of the property to set in memory
      • getMessage

        public static java.lang.String getMessage​(java.lang.String resource,
                                                  java.lang.String name,
                                                  java.util.Locale locale)
        Returns the value of the specified property name from the specified resource/properties file corresponding to the given locale.
        Parameters:
        resource - The name of the resource - can be a file, class, or URL
        name - The name of the property in the properties file
        locale - The locale that the given resource will correspond to
        Returns:
        The value of the property in the properties file
      • getMessage

        public static java.lang.String getMessage​(java.lang.String resource,
                                                  java.lang.String name,
                                                  java.lang.Object[] arguments,
                                                  java.util.Locale locale)
        Returns the value of the specified property name from the specified resource/properties file corresponding to the given locale and replacing argument place holders with the given arguments using the MessageFormat class
        Parameters:
        resource - The name of the resource - can be a file, class, or URL
        name - The name of the property in the properties file
        arguments - An array of Objects to insert into the message argument place holders
        locale - The locale that the given resource will correspond to
        Returns:
        The value of the property in the properties file
      • getMessage

        public static <E> java.lang.String getMessage​(java.lang.String resource,
                                                      java.lang.String name,
                                                      java.util.List<E> arguments,
                                                      java.util.Locale locale)
        Returns the value of the specified property name from the specified resource/properties file corresponding to the given locale and replacing argument place holders with the given arguments using the MessageFormat class
        Parameters:
        resource - The name of the resource - can be a file, class, or URL
        name - The name of the property in the properties file
        arguments - A List of Objects to insert into the message argument place holders
        locale - The locale that the given resource will correspond to
        Returns:
        The value of the property in the properties file
      • getMessageList

        public static java.lang.String getMessageList​(java.lang.String resource,
                                                      java.lang.String name,
                                                      java.util.Locale locale,
                                                      java.lang.Object... arguments)
      • getMessage

        public static java.lang.String getMessage​(java.lang.String resource,
                                                  java.lang.String name,
                                                  java.util.Map<java.lang.String,​? extends java.lang.Object> context,
                                                  java.util.Locale locale)
        Returns the value of the specified property name from the specified resource/properties file corresponding to the given locale and replacing argument place holders with the given arguments using the FlexibleStringExpander class
        Parameters:
        resource - The name of the resource - can be a file, class, or URL
        name - The name of the property in the properties file
        context - A Map of Objects to insert into the message place holders using the ${} syntax of the FlexibleStringExpander
        locale - The locale that the given resource will correspond to
        Returns:
        The value of the property in the properties file
      • getMessageMap

        public static java.lang.String getMessageMap​(java.lang.String resource,
                                                     java.lang.String name,
                                                     java.util.Locale locale,
                                                     java.lang.Object... context)
      • getResourceBundle

        public static java.util.ResourceBundle getResourceBundle​(java.lang.String resource,
                                                                 java.util.Locale locale)
        Returns the specified resource/properties file as a ResourceBundle
        Parameters:
        resource - The name of the resource - can be a file, class, or URL
        locale - The locale that the given resource will correspond to
        Returns:
        The ResourceBundle
      • getResourceBundleMap

        public static ResourceBundleMapWrapper getResourceBundleMap​(java.lang.String resource,
                                                                    java.util.Locale locale)
        Returns the specified resource/properties file as a Map with the original ResourceBundle in the Map under the key _RESOURCE_BUNDLE_
        Parameters:
        resource - The name of the resource - can be a file, class, or URL
        locale - The locale that the given resource will correspond to
        Returns:
        Map containing all entries in The ResourceBundle
      • getResourceBundleMap

        public static ResourceBundleMapWrapper getResourceBundleMap​(java.lang.String resource,
                                                                    java.util.Locale locale,
                                                                    java.util.Map<java.lang.String,​java.lang.Object> context)
        Returns the specified resource/properties file as a Map with the original ResourceBundle in the Map under the key _RESOURCE_BUNDLE_
        Parameters:
        resource - The name of the resource - can be a file, class, or URL
        locale - The locale that the given resource will correspond to
        context - The screen rendering context
        Returns:
        Map containing all entries in The ResourceBundle
      • getProperties

        public static java.util.Properties getProperties​(java.lang.String resource,
                                                         java.util.Locale locale)
        Returns the specified resource/properties file.

        Note that this method will return a Properties instance for the specified locale only - if you need I18n properties, then use getResourceBundle(String resource, Locale locale). This method is intended to be used primarily by the UtilProperties class.

        Parameters:
        resource - The name of the resource - can be a file, class, or URL
        locale - The desired locale
        Returns:
        The Properties instance, or null if no matching properties are found
      • getFallbackLocale

        public static java.util.Locale getFallbackLocale()
        Returns the configured fallback locale. UtilProperties uses this locale to resolve locale-specific XML properties.

        The fallback locale can be configured using the locale.properties.fallback property in general.properties.

        Returns:
        The configured fallback locale
      • localeToCandidateList

        public static java.util.List<java.util.Locale> localeToCandidateList​(java.util.Locale locale)
        Converts a Locale instance to a candidate Locale list. The list is ordered most-specific to least-specific. Example: localeToCandidateList(Locale.US) would return a list containing en_US and en.
        Returns:
        A list of candidate locales.
      • getDefaultCandidateLocales

        public static java.util.Set<java.util.Locale> getDefaultCandidateLocales()
        Returns the default candidate Locale list. The list is populated with the JVM's default locale, the OFBiz fallback locale, and the LOCALE_ROOT (empty) locale - in that order.
        Returns:
        A list of default candidate locales.
      • getCandidateLocales

        public static java.util.List<java.util.Locale> getCandidateLocales​(java.util.Locale locale)
        Returns a list of candidate locales based on a supplied locale. The returned list consists of the supplied locale and the default candidate locales - in that order.
        Parameters:
        locale - The desired locale
        Returns:
        A list of candidate locales
      • createResourceName

        public static java.lang.String createResourceName​(java.lang.String resource,
                                                          java.util.Locale locale,
                                                          boolean removeExtension)
        Create a localized resource name based on a resource name and a locale.
        Parameters:
        resource - The desired resource
        locale - The desired locale
        removeExtension - Remove file extension from resource String
        Returns:
        Localized resource name
      • isPropertiesResourceNotFound

        public static boolean isPropertiesResourceNotFound​(java.lang.String resource,
                                                           java.util.Locale locale,
                                                           boolean removeExtension)
      • resolvePropertiesUrl

        public static java.net.URL resolvePropertiesUrl​(java.lang.String resource,
                                                        java.util.Locale locale)
        Resolve a properties file URL.

        This method uses the following strategy:

        • Locate the XML file specified in resource (MyProps.xml)
        • Locate the file that starts with the name specified in resource and ends with the locale's string and .xml (MyProps_en.xml)
        • Locate the file that starts with the name specified in resource and ends with the locale's string and .properties (MyProps_en.properties)
        • Locate the file that starts with the name specified in resource and ends with the locale's string (MyProps_en)
        The component:// protocol is supported in the resource parameter.
        Parameters:
        resource - The resource to resolve
        locale - The desired locale
        Returns:
        A URL instance or null if not found.
      • xmlToProperties

        public static java.util.Properties xmlToProperties​(java.io.InputStream in,
                                                           java.util.Locale locale,
                                                           java.util.Properties properties)
                                                    throws java.io.IOException,
                                                           java.util.InvalidPropertiesFormatException
        Convert XML property file to Properties instance. This method will convert both the Java XML properties file format and the OFBiz custom XML properties file format.

        The format of the custom XML properties file is:

         
         <resource>
             <property key="key">
             <value xml:lang="locale 1">Some value</value>
             <value xml:lang="locale 2">Some value</value>
             ...
             </property>
             ...
         </resource>
         
         
        where "locale 1", "locale 2" are valid xml:lang values..
        Parameters:
        in - XML file InputStream
        locale - The desired locale
        properties - Optional Properties object to populate
        Returns:
        Properties instance or null if not found
        Throws:
        java.io.IOException
        java.util.InvalidPropertiesFormatException