Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2002-2008 the original author or authors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.springframework.beans;
 
 
Exception thrown on a type mismatch when trying to set a bean property.

Author(s):
Rod Johnson
Juergen Hoeller
 
 public class TypeMismatchException extends PropertyAccessException {

Error code that a type mismatch error will be registered with.
 
 	public static final String ERROR_CODE = "typeMismatch";
 
 
 	private transient Object value;
 
 	private Class requiredType;


Create a new TypeMismatchException.

Parameters:
propertyChangeEvent the PropertyChangeEvent that resulted in the problem
requiredType the required target type
 
 	public TypeMismatchException(PropertyChangeEvent propertyChangeEventClass requiredType) {
 		this(propertyChangeEventrequiredTypenull);
 	}

Create a new TypeMismatchException.

Parameters:
propertyChangeEvent the PropertyChangeEvent that resulted in the problem
requiredType the required target type (or null if not known)
cause the root cause (may be null)
 
 	public TypeMismatchException(PropertyChangeEvent propertyChangeEventClass requiredTypeThrowable cause) {
 		super(propertyChangeEvent,
 				"Failed to convert property value of type [" +
 				ClassUtils.getDescriptiveType(propertyChangeEvent.getNewValue()) + "]" +
 				(requiredType != null ?
 				 " to required type [" + ClassUtils.getQualifiedName(requiredType) + "]" : "") +
 				(propertyChangeEvent.getPropertyName() != null ?
 				 " for property '" + propertyChangeEvent.getPropertyName() + "'" : ""),
 				cause);
 		this. = propertyChangeEvent.getNewValue();
 		this. = requiredType;
 	}

Create a new TypeMismatchException without PropertyChangeEvent.

Parameters:
value the offending value that couldn't be converted (may be null)
requiredType the required target type (or null if not known)
 
 	public TypeMismatchException(Object valueClass requiredType) {
 		this(valuerequiredTypenull);
 	}

Create a new TypeMismatchException without PropertyChangeEvent.

Parameters:
value the offending value that couldn't be converted (may be null)
requiredType the required target type (or null if not known)
cause the root cause (may be null)
 
 	public TypeMismatchException(Object valueClass requiredTypeThrowable cause) {
 		super("Failed to convert value of type [" + ClassUtils.getDescriptiveType(value) + "]" +
 				(requiredType != null ? " to required type [" + ClassUtils.getQualifiedName(requiredType) + "]" : ""),
 				cause);
 		this. = value;
 		this. = requiredType;
 	}


Return the offending value (may be null)
 
 	public Object getValue() {
 		return this.;
 	}

Return the required target type, if any.
	public Class getRequiredType() {
		return this.;
	}
	public String getErrorCode() {
		return ;
	}
New to GrepCode? Check out our FAQ X