public class CsvConstraintViolationException extends CsvFieldAssignmentException
This can be for constraints like making certain a number is in a certain range, or it can even be thrown by code using opencsv when constraints outside of opencsv would be violated. An example of the latter is importing into a database when one of the field in the CSV is supposed to contain the primary key for a foreign table, but the foreign key cannot be satisfied.
This exception is not currently used by opencsv itself, since opencsv has no concept of what data consistency means in the context of the application using it. It is meant more for custom converters.
Constructor and Description |
---|
CsvConstraintViolationException()
Default constructor, in case no further information is necessary or
available.
|
CsvConstraintViolationException(Object sourceObject)
Constructor for setting the source object that triggered the constraint
violation.
|
CsvConstraintViolationException(Object sourceObject,
String message)
Constructor for setting the source object and an error message.
|
CsvConstraintViolationException(String message)
Constructor with a simple text.
|
Modifier and Type | Method and Description |
---|---|
Object |
getSourceObject()
Gets the object that would have caused a constraint violation.
|
getLine, getLineNumber, setLine, setLineNumber
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public CsvConstraintViolationException()
public CsvConstraintViolationException(Object sourceObject)
sourceObject
- The offending source objectpublic CsvConstraintViolationException(String message)
message
- Human-readable error textpublic Object getSourceObject()
sourceObject
is marked transient
, because
Object
is not Serializable
. If
for any reason this exception is serialized and deserialized, this method
will subsequently return null
.Copyright © 2005–2023. All rights reserved.