Top Description Fields Constructors Methods
org.springframework.validation.beanvalidation

public Class LocaleContextMessageInterpolator

extends Object
implements MessageInterpolator
Class Inheritance
All Implemented Interfaces
jakarta.validation.MessageInterpolator
Imports
java.util.Locale, jakarta.validation.MessageInterpolator, org.springframework.context.i18n.LocaleContextHolder, org.springframework.util.Assert

Delegates to a target MessageInterpolator implementation but enforces Spring's managed Locale. Typically used to wrap the validation provider's default interpolator.
Author
Juergen Hoeller
Since
3.0
See Also
org.springframework.context.i18n.LocaleContextHolder#getLocale()

Field Summary

Modifier and TypeField and Description
private final MessageInterpolator

Constructor Summary

AccessConstructor and Description
public
LocaleContextMessageInterpolator(MessageInterpolator
the target MessageInterpolator to wrap
targetInterpolator
)

Create a new LocaleContextMessageInterpolator, wrapping the given target interpolator.

Method Summary

Modifier and TypeMethod and Description
public String
interpolate(String
the message to interpolate
message
,
MessageInterpolator.Context
contextual information related to the interpolation
context
)

Implements jakarta.validation.MessageInterpolator.interpolate.

Interpolates the message template based on the constraint validation context.

public String
interpolate(String
the message to interpolate
message
,
MessageInterpolator.Context
contextual information related to the interpolation
context
,
Locale
the locale targeted for the message
locale
)

Implements jakarta.validation.MessageInterpolator.interpolate.

Interpolates the message template based on the constraint validation context.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

targetInterpolatorback to summary
private final MessageInterpolator targetInterpolator

Constructor Detail

LocaleContextMessageInterpolatorback to summary
public LocaleContextMessageInterpolator(MessageInterpolator targetInterpolator)

Create a new LocaleContextMessageInterpolator, wrapping the given target interpolator.

Parameters
targetInterpolator:MessageInterpolator

the target MessageInterpolator to wrap

Method Detail

interpolateback to summary
public String interpolate(String message, MessageInterpolator.Context context)

Implements jakarta.validation.MessageInterpolator.interpolate.

Doc from jakarta.validation.MessageInterpolator.interpolate.

Interpolates the message template based on the constraint validation context.

The locale is defaulted according to the MessageInterpolator implementation. See the implementation documentation for more detail.

Parameters
message:String

the message to interpolate

context:MessageInterpolator.Context

contextual information related to the interpolation

Returns:String

interpolated error message

Annotations
@Override
interpolateback to summary
public String interpolate(String message, MessageInterpolator.Context context, Locale locale)

Implements jakarta.validation.MessageInterpolator.interpolate.

Doc from jakarta.validation.MessageInterpolator.interpolate.

Interpolates the message template based on the constraint validation context. The Locale used is provided as a parameter.

Parameters
message:String

the message to interpolate

context:MessageInterpolator.Context

contextual information related to the interpolation

locale:Locale

the locale targeted for the message

Returns:String

interpolated error message

Annotations
@Override