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

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.

Author
Juergen Hoeller

Since
1.1.5

See Also
AbstractApplicationContext

Constructors

<init>

DelegatingMessageSource()

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.

Functions

getMessage

open fun getMessage(code: String, args: Array<Any>, defaultMessage: String, locale: Locale): String
open fun getMessage(code: String, args: Array<Any>, locale: Locale): String
open fun getMessage(resolvable: MessageSourceResolvable, locale: Locale): String

getParentMessageSource

open fun getParentMessageSource(): MessageSource

setParentMessageSource

open fun setParentMessageSource(parent: MessageSource): Unit

Inherited 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.