com.interface21.validation
Class FieldError

java.lang.Object
  |
  +--com.interface21.context.support.MessageSourceResolvableImpl
        |
        +--com.interface21.validation.ObjectError
              |
              +--com.interface21.validation.FieldError
All Implemented Interfaces:
MessageSourceResolvable, java.io.Serializable

public class FieldError
extends ObjectError

Encapsulates a field error, i.e. a reason for rejecting a specific field value.

A field error gets created with a single code but uses 3 codes for message resolution, in the following order:

E.g.: code "typeMismatch", field "age", object name "user":

Thus, this resolution algorithm can be leveraged for example to show specific messages for binding errors like "required" and "typeMismatch":

Author:
Rod Johnson, Juergen Hoeller
See Also:
Serialized Form

Field Summary
static java.lang.String CODE_SEPARATOR
           
 
Constructor Summary
protected FieldError(java.lang.String objectName, java.lang.String field, java.lang.Object rejectedValue, java.lang.String[] codes, java.lang.Object[] args, java.lang.String defaultMessage)
          Create a new FieldError instance, using multiple codes.
  FieldError(java.lang.String objectName, java.lang.String field, java.lang.Object rejectedValue, java.lang.String code, java.lang.Object[] args, java.lang.String defaultMessage)
          Create a new FieldError instance, using a default code.
 
Method Summary
 java.lang.String getField()
           
 java.lang.Object getRejectedValue()
           
 java.lang.String toString()
           
 
Methods inherited from class com.interface21.validation.ObjectError
getObjectName
 
Methods inherited from class com.interface21.context.support.MessageSourceResolvableImpl
getArgs, getCode, getCodes, getDefaultMessage, resolvableToString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CODE_SEPARATOR

public static final java.lang.String CODE_SEPARATOR
Constructor Detail

FieldError

protected FieldError(java.lang.String objectName,
                     java.lang.String field,
                     java.lang.Object rejectedValue,
                     java.lang.String[] codes,
                     java.lang.Object[] args,
                     java.lang.String defaultMessage)
Create a new FieldError instance, using multiple codes.

This is only meant to be used by subclasses.

See Also:
MessageSourceResolvable.getCodes()

FieldError

public FieldError(java.lang.String objectName,
                  java.lang.String field,
                  java.lang.Object rejectedValue,
                  java.lang.String code,
                  java.lang.Object[] args,
                  java.lang.String defaultMessage)
Create a new FieldError instance, using a default code.
Method Detail

getField

public java.lang.String getField()

getRejectedValue

public java.lang.Object getRejectedValue()

toString

public java.lang.String toString()
Overrides:
toString in class ObjectError


Rod Johnson and Spring contributors 2001-2003.