spring-framework / org.springframework.context.support / MessageSourceSupport

MessageSourceSupport

abstract class MessageSourceSupport

Base class for message source implementations, providing support infrastructure such as java.text.MessageFormat handling but not implementing concrete methods defined in the org.springframework.context.MessageSource.

AbstractMessageSource derives from this class, providing concrete getMessage implementations that delegate to a central template method for message code resolution.

Author
Juergen Hoeller

Since
2.5.5

Constructors

<init>

MessageSourceSupport()

Base class for message source implementations, providing support infrastructure such as java.text.MessageFormat handling but not implementing concrete methods defined in the org.springframework.context.MessageSource.

AbstractMessageSource derives from this class, providing concrete getMessage implementations that delegate to a central template method for message code resolution.

Functions

setAlwaysUseMessageFormat

open fun setAlwaysUseMessageFormat(alwaysUseMessageFormat: Boolean): Unit

Set whether to always apply the MessageFormat rules, parsing even messages without arguments.

Default is "false": Messages without arguments are by default returned as-is, without parsing them through MessageFormat. Set this to "true" to enforce MessageFormat for all messages, expecting all message texts to be written with MessageFormat escaping.

For example, MessageFormat expects a single quote to be escaped as "''". If your message texts are all written with such escaping, even when not defining argument placeholders, you need to set this flag to "true". Else, only message texts with actual arguments are supposed to be written with MessageFormat escaping.

Inheritors

DelegatingMessageSource

open class DelegatingMessageSource : MessageSourceSupport, HierarchicalMessageSource

Empty MessageSource that delegates all calls to the parent MessageSource. If no parent is available, it simply won't resolve any message.

Used as placeholder by AbstractApplicationContext, if the context doesn't define its own MessageSource. Not intended for direct use in applications.