Package org.springframework.web.server.i18n

# Class FixedLocaleContextResolver

java.lang.Object
org.springframework.web.server.i18n.FixedLocaleContextResolver

All Implemented Interfaces:
  `LocaleContextResolver`

public class FixedLocaleContextResolver extends Object implements LocaleContextResolver
`LocaleContextResolver` implementation that always returns a fixed locale and optionally time zone. Default is the current JVM's default locale.

Note: Does not support `setLocaleContext(org.springframework.web.server.ServerWebExchange, org.springframework.context.i18n.LocaleContext)`, as the fixed locale and time zone cannot be changed.

Since:
  5.0
Author:
  Sebastien Deleuze

## Constructor Summary

Constructors
Constructor
Description
`FixedLocaleContextResolver()`
Create a default FixedLocaleResolver, exposing a configured default locale (or the JVM's default locale as fallback).
`FixedLocaleContextResolver(Locale locale)`
Create a FixedLocaleResolver that exposes the given locale.
`FixedLocaleContextResolver(Locale locale, TimeZone timeZone)`
Create a FixedLocaleResolver that exposes the given locale and time zone.

## Method Summary

Modifier and Type
Method
Description
`org.springframework.context.i18n.LocaleContext`
`resolveLocaleContext(ServerWebExchange exchange)`
Resolve the current locale context via the given exchange.
`void`
`setLocaleContext(ServerWebExchange exchange, org.springframework.context.i18n.LocaleContext localeContext)`
Set the current locale context to the given one, potentially including a locale with associated time zone information.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### FixedLocaleContextResolver

public FixedLocaleContextResolver()
Create a default FixedLocaleResolver, exposing a configured default locale (or the JVM's default locale as fallback).

### FixedLocaleContextResolver

public FixedLocaleContextResolver(Locale locale)
Create a FixedLocaleResolver that exposes the given locale.

Parameters:
  `locale` - the locale to expose

### FixedLocaleContextResolver

public FixedLocaleContextResolver(Locale locale, @Nullable TimeZone timeZone)
Create a FixedLocaleResolver that exposes the given locale and time zone.

Parameters:
  `locale` - the locale to expose
  `timeZone` - the time zone to expose

## Method Details

### resolveLocaleContext

public org.springframework.context.i18n.LocaleContext resolveLocaleContext(ServerWebExchange exchange)
Description copied from interface: `LocaleContextResolver`
Resolve the current locale context via the given exchange.

The returned context may be a `TimeZoneAwareLocaleContext`, containing a locale with associated time zone information. Simply apply an `instanceof` check and downcast accordingly.

Custom resolver implementations may also return extra settings in the returned context, which again can be accessed through downcasting.

Specified by:
  `resolveLocaleContext` in interface `LocaleContextResolver`
Parameters:
  `exchange` - current server exchange
Returns:
  the current locale context (never `null`)

### setLocaleContext

public void setLocaleContext(ServerWebExchange exchange, @Nullable org.springframework.context.i18n.LocaleContext localeContext)
Description copied from interface: `LocaleContextResolver`
Set the current locale context to the given one, potentially including a locale with associated time zone information.

Specified by:
  `setLocaleContext` in interface `LocaleContextResolver`
Parameters:
  `exchange` - current server exchange
  `localeContext` - the new locale context, or `null` to clear the locale
See Also:
  - `SimpleLocaleContext`
  - `SimpleTimeZoneAwareLocaleContext`