Top Description Fields Constructors Methods
org.springframework.context.support

public Class DefaultMessageSourceResolvable

extends Object
implements MessageSourceResolvable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.springframework.context.MessageSourceResolvable
Known Direct Subclasses
org.springframework.validation.ObjectError
Annotations
@SuppressWarnings:serial
Imports
java.io.Serializable, org.springframework.context.MessageSourceResolvable, org.springframework.lang.Nullable, org.springframework.util.ObjectUtils, .StringUtils

Spring's default implementation of the MessageSourceResolvable interface. Offers an easy way to store all the necessary values needed to resolve a message via a org.springframework.context.MessageSource.
Author
Juergen Hoeller
Since
13.02.2004
See Also
org.springframework.context.MessageSource#getMessage(MessageSourceResolvable, java.util.Locale)

Field Summary

Modifier and TypeField and Description
private final Object[]
private final String[]
private final String

Constructor Summary

AccessConstructor and Description
public
DefaultMessageSourceResolvable(String
the code to be used to resolve this message
code
)

Create a new DefaultMessageSourceResolvable.

public
DefaultMessageSourceResolvable(String[]
the codes to be used to resolve this message
codes
)

Create a new DefaultMessageSourceResolvable.

public
DefaultMessageSourceResolvable(String[]
the codes to be used to resolve this message
codes
,
String
the default message to be used to resolve this message
defaultMessage
)

Create a new DefaultMessageSourceResolvable.

public
DefaultMessageSourceResolvable(String[]
the codes to be used to resolve this message
codes
,
Object[]
the array of arguments to be used to resolve this message
arguments
)

Create a new DefaultMessageSourceResolvable.

public
DefaultMessageSourceResolvable(String[]
the codes to be used to resolve this message
codes
,
Object[]
the array of arguments to be used to resolve this message
arguments
,
String
the default message to be used to resolve this message
defaultMessage
)

Create a new DefaultMessageSourceResolvable.

public
DefaultMessageSourceResolvable(MessageSourceResolvable
the resolvable to copy from
resolvable
)

Copy constructor: Create a new instance from another resolvable.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Object[]
getArguments()

Overrides default org.springframework.context.MessageSourceResolvable.getArguments.

Return the array of arguments to be used to resolve this message.
public String
getCode()

Return the default code of this resolvable, that is, the last one in the codes array.

public String[]
getCodes()

Implements org.springframework.context.MessageSourceResolvable.getCodes.

Return the codes to be used to resolve this message, in the order that they should get tried.
public String
getDefaultMessage()

Overrides default org.springframework.context.MessageSourceResolvable.getDefaultMessage.

Return the default message to be used to resolve this message.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
protected final String
resolvableToString()

Build a default String representation for this MessageSourceResolvable: including codes, arguments, and default message.

public boolean

Returns:

true if the default message may contain argument placeholders; false if it definitely does not contain placeholders or custom escaping and can therefore be simply exposed as-is
shouldRenderDefaultMessage
()

Indicate whether the specified default message needs to be rendered for substituting placeholders and/or java.text.MessageFormat escaping.

public String
toString()

Overrides java.lang.Object.toString.

The default implementation exposes the attributes of this MessageSourceResolvable.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

argumentsback to summary
private final Object[] arguments
Annotations
@Nullable
codesback to summary
private final String[] codes
Annotations
@Nullable
defaultMessageback to summary
private final String defaultMessage
Annotations
@Nullable

Constructor Detail

DefaultMessageSourceResolvableback to summary
public DefaultMessageSourceResolvable(String code)

Create a new DefaultMessageSourceResolvable.

Parameters
code:String

the code to be used to resolve this message

DefaultMessageSourceResolvableback to summary
public DefaultMessageSourceResolvable(String[] codes)

Create a new DefaultMessageSourceResolvable.

Parameters
codes:String[]

the codes to be used to resolve this message

DefaultMessageSourceResolvableback to summary
public DefaultMessageSourceResolvable(String[] codes, String defaultMessage)

Create a new DefaultMessageSourceResolvable.

Parameters
codes:String[]

the codes to be used to resolve this message

defaultMessage:String

the default message to be used to resolve this message

DefaultMessageSourceResolvableback to summary
public DefaultMessageSourceResolvable(String[] codes, Object[] arguments)

Create a new DefaultMessageSourceResolvable.

Parameters
codes:String[]

the codes to be used to resolve this message

arguments:Object[]

the array of arguments to be used to resolve this message

DefaultMessageSourceResolvableback to summary
public DefaultMessageSourceResolvable(String[] codes, Object[] arguments, String defaultMessage)

Create a new DefaultMessageSourceResolvable.

Parameters
codes:String[]

the codes to be used to resolve this message

arguments:Object[]

the array of arguments to be used to resolve this message

defaultMessage:String

the default message to be used to resolve this message

DefaultMessageSourceResolvableback to summary
public DefaultMessageSourceResolvable(MessageSourceResolvable resolvable)

Copy constructor: Create a new instance from another resolvable.

Parameters
resolvable:MessageSourceResolvable

the resolvable to copy from

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getArgumentsback to summary
public Object[] getArguments()

Overrides default org.springframework.context.MessageSourceResolvable.getArguments.

Doc from org.springframework.context.MessageSourceResolvable.getArguments.

Return the array of arguments to be used to resolve this message.

The default implementation simply returns null.

Returns:Object[]

an array of objects to be used as parameters to replace placeholders within the message text

Annotations
@Override
@Nullable
getCodeback to summary
public String getCode()

Return the default code of this resolvable, that is, the last one in the codes array.

Annotations
@Nullable
getCodesback to summary
public String[] getCodes()

Implements org.springframework.context.MessageSourceResolvable.getCodes.

Doc from org.springframework.context.MessageSourceResolvable.getCodes.

Return the codes to be used to resolve this message, in the order that they should get tried. The last code will therefore be the default one.

Returns:String[]

a String array of codes which are associated with this message

Annotations
@Override
@Nullable
getDefaultMessageback to summary
public String getDefaultMessage()

Overrides default org.springframework.context.MessageSourceResolvable.getDefaultMessage.

Doc from org.springframework.context.MessageSourceResolvable.getDefaultMessage.

Return the default message to be used to resolve this message.

The default implementation simply returns null. Note that the default message may be identical to the primary message code (getCodes()), which effectively enforces org.springframework.context.support.AbstractMessageSource#setUseCodeAsDefaultMessage for this particular message.

Returns:String

the default message, or null if no default

Annotations
@Override
@Nullable
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
resolvableToStringback to summary
protected final String resolvableToString()

Build a default String representation for this MessageSourceResolvable: including codes, arguments, and default message.

shouldRenderDefaultMessageback to summary
public boolean shouldRenderDefaultMessage()

Indicate whether the specified default message needs to be rendered for substituting placeholders and/or java.text.MessageFormat escaping.

Returns:boolean

true if the default message may contain argument placeholders; false if it definitely does not contain placeholders or custom escaping and can therefore be simply exposed as-is

Since
5.1.7
See Also
getDefaultMessage(), getArguments(), AbstractMessageSource#renderDefaultMessage
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

The default implementation exposes the attributes of this MessageSourceResolvable.

To be overridden in more specific subclasses, potentially including the resolvable content through resolvableToString().

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override
See Also
resolvableToString()