Class LocalizedMessageInterpolator

  • All Implemented Interfaces:
    javax.validation.MessageInterpolator

    public class LocalizedMessageInterpolator
    extends org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator
    A MessageInterpolator that is aware of a given Locale instead of using the default one. Additionally, it uses an Application's default MessageSource to retrieve validation messages.
    Author:
    Matthias Müller
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface javax.validation.MessageInterpolator

        javax.validation.MessageInterpolator.Context
    • Field Summary

      • Fields inherited from class org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator

        CONTRIBUTOR_VALIDATION_MESSAGES, USER_VALIDATION_MESSAGES
    • Constructor Summary

      Constructors 
      Constructor Description
      LocalizedMessageInterpolator​(Locale locale, org.springframework.context.MessageSource messageSource)
      Creates a new LocalizedMessageInterpolator using the given Locale .
    • Constructor Detail

      • LocalizedMessageInterpolator

        public LocalizedMessageInterpolator​(Locale locale,
                                            org.springframework.context.MessageSource messageSource)
        Creates a new LocalizedMessageInterpolator using the given Locale .
        Parameters:
        locale - The Locale to use.
        messageSource - An additional MessageSource to use. If this is an instance of AbstractResourceBasedMessageSource, AbstractResourceBasedMessageSource.getBasenameSet() is being used to create a new ResourceBundleMessageSource with these base names. This is necessary because a the messageSource might use MessageSourceSupport.setAlwaysUseMessageFormat(boolean), which can't properly be handled by MessageInterpolator.
    • Method Detail

      • interpolate

        public String interpolate​(String messageTemplate,
                                  javax.validation.MessageInterpolator.Context context)
        Specified by:
        interpolate in interface javax.validation.MessageInterpolator
        Overrides:
        interpolate in class org.hibernate.validator.messageinterpolation.AbstractMessageInterpolator