Package com.opencsv.exceptions
Class CsvDataTypeMismatchException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- com.opencsv.exceptions.CsvException
-
- com.opencsv.exceptions.CsvDataTypeMismatchException
-
- All Implemented Interfaces:
java.io.Serializable
public class CsvDataTypeMismatchException extends CsvException
This exception should be thrown when the provided string value for conversion cannot be converted to the required type of the destination field.- Since:
- 3.8
- Author:
- Andrew Rucker Jones
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CsvDataTypeMismatchException()
Default constructor, in case no further information is necessary or available.CsvDataTypeMismatchException(java.lang.Object sourceObject, java.lang.Class<?> destinationClass)
Constructor for setting the data and the class of the intended destination field.CsvDataTypeMismatchException(java.lang.Object sourceObject, java.lang.Class<?> destinationClass, java.lang.String message)
Constructor for setting the data and the class of the intended destination field along with an error message.CsvDataTypeMismatchException(java.lang.String message)
Constructor with a simple text.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Class<?>
getDestinationClass()
Gets the type of the field to which the data were to be assigned.java.lang.Object
getSourceObject()
Gets the object that was to be assigned to a field of the wrong type.-
Methods inherited from class com.opencsv.exceptions.CsvException
getLine, getLineNumber, setLine, setLineNumber
-
-
-
-
Constructor Detail
-
CsvDataTypeMismatchException
public CsvDataTypeMismatchException()
Default constructor, in case no further information is necessary or available.
-
CsvDataTypeMismatchException
public CsvDataTypeMismatchException(java.lang.Object sourceObject, java.lang.Class<?> destinationClass)
Constructor for setting the data and the class of the intended destination field.- Parameters:
sourceObject
- Object that was to be assigned to the destination field. This may not be available in all contexts.destinationClass
- Class of the destination field. This may not be available in all contexts.
-
CsvDataTypeMismatchException
public CsvDataTypeMismatchException(java.lang.String message)
Constructor with a simple text.- Parameters:
message
- Human-readable error text
-
CsvDataTypeMismatchException
public CsvDataTypeMismatchException(java.lang.Object sourceObject, java.lang.Class<?> destinationClass, java.lang.String message)
Constructor for setting the data and the class of the intended destination field along with an error message.- Parameters:
sourceObject
- Object that was to be assigned to the destination field. This may not be available in all contexts.destinationClass
- Class of the destination field. This may not be available in all contexts.message
- Human-readable error text
-
-
Method Detail
-
getSourceObject
public java.lang.Object getSourceObject()
Gets the object that was to be assigned to a field of the wrong type.sourceObject
is markedtransient
, becauseObject
is notSerializable
. If for any reason this exception is serialized and deserialized, this method will subsequently returnnull
.- Returns:
- The data that could not be assigned
-
getDestinationClass
public java.lang.Class<?> getDestinationClass()
Gets the type of the field to which the data were to be assigned.- Returns:
- The class of the destination field
-
-