public class

LocalizedResourceHelper

extends Object
java.lang.Object
   ↳ org.springframework.core.io.support.LocalizedResourceHelper

Class Overview

Helper class for loading a localized resource, specified through name, extension and current locale.

Summary

Constants
String DEFAULT_SEPARATOR The default separator to use inbetween file name parts: an underscore
Public Constructors
LocalizedResourceHelper()
Create a new LocalizedResourceHelper with a DefaultResourceLoader.
LocalizedResourceHelper(ResourceLoader resourceLoader)
Create a new LocalizedResourceHelper with the given ResourceLoader.
Public Methods
Resource findLocalizedResource(String name, String extension, Locale locale)
Find the most specific localized resource for the given name, extension and locale:

The file will be searched with locations in the following order, similar to java.util.ResourceBundle's search order:

  • [name]_[language]_[country]_[variant][extension]
  • [name]_[language]_[country][extension]
  • [name]_[language][extension]
  • [name][extension]

If none of the specific files can be found, a resource descriptor for the default location will be returned.

void setSeparator(String separator)
Set the separator to use inbetween file name parts.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String DEFAULT_SEPARATOR

Also: SpringCore

The default separator to use inbetween file name parts: an underscore

Constant Value: "_"

Public Constructors

public LocalizedResourceHelper ()

Also: SpringCore

Create a new LocalizedResourceHelper with a DefaultResourceLoader.

public LocalizedResourceHelper (ResourceLoader resourceLoader)

Also: SpringCore

Create a new LocalizedResourceHelper with the given ResourceLoader.

Parameters
resourceLoader the ResourceLoader to use

Public Methods

public Resource findLocalizedResource (String name, String extension, Locale locale)

Also: SpringCore

Find the most specific localized resource for the given name, extension and locale:

The file will be searched with locations in the following order, similar to java.util.ResourceBundle's search order:

  • [name]_[language]_[country]_[variant][extension]
  • [name]_[language]_[country][extension]
  • [name]_[language][extension]
  • [name][extension]

If none of the specific files can be found, a resource descriptor for the default location will be returned.

Parameters
name the name of the file, without localization part nor extension
extension the file extension (e.g. ".xls")
locale the current locale (may be null)
Returns
  • the most specific localized resource found
See Also

public void setSeparator (String separator)

Also: SpringCore

Set the separator to use inbetween file name parts. Default is an underscore ("_").