com.opensymphony.xwork2

## Interface LocaleProvider

- All Known Subinterfaces:
    ValidatorContext
  All Known Implementing Classes:
    ActionSupport, ActionSupport, CspReportAction, DefaultActionSupport, DefaultCspReportAction, DefaultLocaleProvider, DelegatingValidatorContext, VisitorFieldValidator.AppendingValidatorContext

      public interface LocaleProvider

  Indicates that the implementing class can provide its own `Locale`.

  This is useful for when an action may wish override the default locale. All that is needed is to implement this interface and return your own custom locale. The `TextProvider` interface uses this interface heavily for retrieving internationalized messages from resource bundles.

  Author:
    Jason Carreira

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `Locale` | `getLocale()` Gets the provided locale.
    `boolean` | `isValidLocale(Locale locale)` Validates if provided `Locale` is value
    `boolean` | `isValidLocaleString(String localeStr)` Validates if provided string is a valid `Locale`
    `default Locale` | `toLocale(String localeStr)` Tries to convert provided locale string into `Locale` or returns null

- - ### Method Detail

    - #### getLocale

          Locale getLocale()

      Gets the provided locale.
      Returns:
        the locale.

    - #### isValidLocaleString

          boolean isValidLocaleString(String localeStr)

      Validates if provided string is a valid `Locale`
      Parameters:
        `localeStr` - a String representing locale, e.g. en_EN
      Returns:
        true if valid

    - #### isValidLocale

          boolean isValidLocale(Locale locale)

      Validates if provided `Locale` is value
      Parameters:
        `locale` - instance of `Locale` to validate
      Returns:
        true if valid

    - #### toLocale

          default Locale toLocale(String localeStr)

      Tries to convert provided locale string into `Locale` or returns null
      Parameters:
        `localeStr` - a String representing locale, e.g.: en_EN
      Returns:
        instance of `Locale` or null
      Since:
        Struts 6.5.0

Copyright © 2000–2026 Apache Software Foundation. All rights reserved.