Package org.springframework.beans
Class TypeMismatchException
- All Implemented Interfaces:
Serializable
,ErrorCoded
- Direct Known Subclasses:
ConversionNotSupportedException
,MethodArgumentTypeMismatchException
public class TypeMismatchException extends PropertyAccessException
Exception thrown on a type mismatch when trying to set a bean property.- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
- Serialized Form
Field Summary
Fields Modifier and Type Field Description static String
ERROR_CODE
Error code that a type mismatch error will be registered with.
Constructor Summary
Constructors Constructor Description TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType)
Create a newTypeMismatchException
.TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType, Throwable cause)
Create a newTypeMismatchException
.TypeMismatchException(Object value, Class<?> requiredType)
Create a newTypeMismatchException
without aPropertyChangeEvent
.TypeMismatchException(Object value, Class<?> requiredType, Throwable cause)
Create a newTypeMismatchException
without aPropertyChangeEvent
.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getErrorCode()
Return a corresponding error code for this type of exception.Class<?>
getRequiredType()
Return the required target type, if any.Object
getValue()
Return the offending value (may benull
).Methods inherited from class org.springframework.beans.PropertyAccessException
getPropertyChangeEvent, getPropertyName
Methods inherited from class org.springframework.beans.BeansException
equals, hashCode
Methods inherited from class org.springframework.core.NestedRuntimeException
contains, getMessage, getMostSpecificCause, getRootCause
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Field Detail
ERROR_CODE
public static final String ERROR_CODE
Error code that a type mismatch error will be registered with.- See Also:
- Constant Field Values
Constructor Detail
TypeMismatchException
public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType)
Create a newTypeMismatchException
.- Parameters:
propertyChangeEvent
- the PropertyChangeEvent that resulted in the problemrequiredType
- the required target type
TypeMismatchException
public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType, Throwable cause)
Create a newTypeMismatchException
.- Parameters:
propertyChangeEvent
- the PropertyChangeEvent that resulted in the problemrequiredType
- the required target type (ornull
if not known)cause
- the root cause (may benull
)
TypeMismatchException
public TypeMismatchException(Object value, Class<?> requiredType)
Create a newTypeMismatchException
without aPropertyChangeEvent
.- Parameters:
value
- the offending value that couldn't be converted (may benull
)requiredType
- the required target type (ornull
if not known)
TypeMismatchException
public TypeMismatchException(Object value, Class<?> requiredType, Throwable cause)
Create a newTypeMismatchException
without aPropertyChangeEvent
.- Parameters:
value
- the offending value that couldn't be converted (may benull
)requiredType
- the required target type (ornull
if not known)cause
- the root cause (may benull
)
Method Detail
getValue
public Object getValue()
Return the offending value (may benull
).- Overrides:
getValue
in classPropertyAccessException
getRequiredType
public Class<?> getRequiredType()
Return the required target type, if any.
getErrorCode
public String getErrorCode()
Description copied from class:PropertyAccessException
Return a corresponding error code for this type of exception.- Specified by:
getErrorCode
in interfaceErrorCoded
- Specified by:
getErrorCode
in classPropertyAccessException
- Returns:
- a String error code associated with this failure, or
null
if not error-coded