Top Description Fields Constructors Methods
org.springframework.web.server.i18n

public Class FixedLocaleContextResolver

extends Object
implements LocaleContextResolver
Class Inheritance
All Implemented Interfaces
org.springframework.web.server.i18n.LocaleContextResolver
Imports
java.util.Locale, .TimeZone, org.springframework.context.i18n.LocaleContext, .TimeZoneAwareLocaleContext, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.server.ServerWebExchange

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, as the fixed locale and time zone cannot be changed.

Author
Sebastien Deleuze
Since
5.0

Field Summary

Modifier and TypeField and Description
private final Locale
private final TimeZone

Constructor Summary

AccessConstructor and Description
public
FixedLocaleContextResolver()

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

public
FixedLocaleContextResolver(Locale
the locale to expose
locale
)

Create a FixedLocaleResolver that exposes the given locale.

public
FixedLocaleContextResolver(Locale
the locale to expose
locale
,
TimeZone
the time zone to expose
timeZone
)

Create a FixedLocaleResolver that exposes the given locale and time zone.

Method Summary

Modifier and TypeMethod and Description
public LocaleContext
resolveLocaleContext(ServerWebExchange
current server exchange
exchange
)

Implements org.springframework.web.server.i18n.LocaleContextResolver.resolveLocaleContext.

Resolve the current locale context via the given exchange.

public void
setLocaleContext(ServerWebExchange
current server exchange
exchange
,
LocaleContext
the new locale context, or null to clear the locale
localeContext
)

Implements org.springframework.web.server.i18n.LocaleContextResolver.setLocaleContext.

Set the current locale context to the given one, potentially including a locale with associated time zone information.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

localeback to summary
private final Locale locale
timeZoneback to summary
private final TimeZone timeZone
Annotations
@Nullable

Constructor Detail

FixedLocaleContextResolverback to summary
public FixedLocaleContextResolver()

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

FixedLocaleContextResolverback to summary
public FixedLocaleContextResolver(Locale locale)

Create a FixedLocaleResolver that exposes the given locale.

Parameters
locale:Locale

the locale to expose

FixedLocaleContextResolverback to summary
public FixedLocaleContextResolver(Locale locale, TimeZone timeZone)

Create a FixedLocaleResolver that exposes the given locale and time zone.

Parameters
locale:Locale

the locale to expose

timeZone:TimeZone

the time zone to expose

Method Detail

resolveLocaleContextback to summary
public LocaleContext resolveLocaleContext(ServerWebExchange exchange)

Implements org.springframework.web.server.i18n.LocaleContextResolver.resolveLocaleContext.

Doc from org.springframework.web.server.i18n.LocaleContextResolver.resolveLocaleContext.

Resolve the current locale context via the given exchange.

The returned context may be a org.springframework.context.i18n.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.

Parameters
exchange:ServerWebExchange

current server exchange

Returns:LocaleContext

the current locale context (never null)

Annotations
@Override
setLocaleContextback to summary
public void setLocaleContext(ServerWebExchange exchange, LocaleContext localeContext)

Implements org.springframework.web.server.i18n.LocaleContextResolver.setLocaleContext.

Doc from org.springframework.web.server.i18n.LocaleContextResolver.setLocaleContext.

Set the current locale context to the given one, potentially including a locale with associated time zone information.

Parameters
exchange:ServerWebExchange

current server exchange

localeContext:LocaleContext

the new locale context, or null to clear the locale

Annotations
@Override