FileDocCategorySizeDatePackage
ConversionException.javaAPI DocGlassfish v2 API8956Tue May 22 16:54:18 BST 2007oracle.toplink.essentials.exceptions

ConversionException

public class ConversionException extends TopLinkException

Purpose: Conversion exceptions such as method or class not defined will raise this exception.

Fields Summary
protected Class
classToConvertTo
protected transient Object
sourceObject
public static final int
COULD_NOT_BE_CONVERTED
public static final int
COULD_NOT_BE_CONVERTED_EXTENDED
public static final int
INCORRECT_DATE_FORMAT
public static final int
INCORRECT_TIME_FORMAT
public static final int
INCORRECT_TIMESTAMP_FORMAT
public static final int
COULD_NOT_CONVERT_TO_BYTE_ARRAY
public static final int
COULD_NOT_BE_CONVERTED_TO_CLASS
public static final int
INCORRECT_DATE_TIME_FORMAT
Constructors Summary
protected ConversionException(String message, Object sourceObject, Class classToConvertTo, Exception exception)
INTERNAL: TopLink exceptions should only be thrown by TopLink.


                  
             
        super(message, exception);
        setSourceObject(sourceObject);
        setClassToConvertTo(classToConvertTo);
    
Methods Summary
public static oracle.toplink.essentials.exceptions.ConversionExceptioncouldNotBeConverted(java.lang.Object mapping, java.lang.Object descriptor, oracle.toplink.essentials.exceptions.ConversionException exception)

        Object sourceObject = exception.getSourceObject();
        Class javaClass = exception.getClassToConvertTo();
        Exception original = (Exception)exception.getInternalException();

        Object[] args = { sourceObject, sourceObject.getClass(), mapping, descriptor, javaClass };
        String message = ExceptionMessageGenerator.buildMessage(ConversionException.class, COULD_NOT_BE_CONVERTED_EXTENDED, args);
        ConversionException conversionException = new ConversionException(message, sourceObject, javaClass, original);
        conversionException.setStackTrace(exception.getStackTrace());
        conversionException.setErrorCode(COULD_NOT_BE_CONVERTED_EXTENDED);
        return conversionException;
    
public static oracle.toplink.essentials.exceptions.ConversionExceptioncouldNotBeConverted(java.lang.Object object, java.lang.Class javaClass)

        Object[] args = { object, object.getClass(), javaClass };
        String message = ExceptionMessageGenerator.buildMessage(ConversionException.class, COULD_NOT_BE_CONVERTED, args);
        ConversionException conversionException = new ConversionException(message, object, javaClass, null);
        conversionException.setErrorCode(COULD_NOT_BE_CONVERTED);
        return conversionException;
    
public static oracle.toplink.essentials.exceptions.ConversionExceptioncouldNotBeConverted(java.lang.Object object, java.lang.Class javaClass, java.lang.Exception exception)

        Object[] args = { object, object.getClass(), javaClass };
        String message = ExceptionMessageGenerator.buildMessage(ConversionException.class, COULD_NOT_BE_CONVERTED, args);
        ConversionException conversionException = new ConversionException(message, object, javaClass, exception);
        conversionException.setErrorCode(COULD_NOT_BE_CONVERTED);
        return conversionException;
    
public static oracle.toplink.essentials.exceptions.ConversionExceptioncouldNotBeConvertedToClass(java.lang.Object object, java.lang.Class javaClass, java.lang.Exception exception)

        Object[] args = { object, object.getClass(), javaClass };
        String message = ExceptionMessageGenerator.buildMessage(ConversionException.class, COULD_NOT_BE_CONVERTED_TO_CLASS, args);
        ConversionException conversionException = new ConversionException(message, object, javaClass, exception);
        conversionException.setErrorCode(COULD_NOT_BE_CONVERTED_TO_CLASS);
        return conversionException;
    
public static oracle.toplink.essentials.exceptions.ConversionExceptioncouldNotConvertToByteArray(java.lang.Object object)

        Object[] args = { object };
        String message = ExceptionMessageGenerator.buildMessage(ConversionException.class, COULD_NOT_CONVERT_TO_BYTE_ARRAY, args);
        ConversionException conversionException = new ConversionException(message, object, byte[].class, null);
        conversionException.setErrorCode(COULD_NOT_CONVERT_TO_BYTE_ARRAY);
        return conversionException;
    
public java.lang.ClassgetClassToConvertTo()
PUBLIC: Return the class to convert to.

        return classToConvertTo;
    
public java.lang.ObjectgetSourceObject()
PUBLIC: Return the object for which the problem was detected.

        return sourceObject;
    
public static oracle.toplink.essentials.exceptions.ConversionExceptionincorrectDateFormat(java.lang.String dateString)

        Object[] args = { dateString };
        String message = ExceptionMessageGenerator.buildMessage(ConversionException.class, INCORRECT_DATE_FORMAT, args);
        ConversionException conversionException = new ConversionException(message, dateString, java.sql.Date.class, null);
        conversionException.setErrorCode(INCORRECT_DATE_FORMAT);
        return conversionException;
    
public static oracle.toplink.essentials.exceptions.ConversionExceptionincorrectDateTimeFormat(java.lang.String dateTimeString)

        Object[] args = { dateTimeString };
        String message = ExceptionMessageGenerator.buildMessage(ConversionException.class, INCORRECT_DATE_TIME_FORMAT, args);
        ConversionException conversionException = new ConversionException(message, dateTimeString, Calendar.class, null);
        conversionException.setErrorCode(INCORRECT_DATE_TIME_FORMAT);
        return conversionException;
    
public static oracle.toplink.essentials.exceptions.ConversionExceptionincorrectTimeFormat(java.lang.String timeString)

        Object[] args = { timeString };
        String message = ExceptionMessageGenerator.buildMessage(ConversionException.class, INCORRECT_TIME_FORMAT, args);
        ConversionException conversionException = new ConversionException(message, timeString, java.sql.Time.class, null);
        conversionException.setErrorCode(INCORRECT_TIME_FORMAT);
        return conversionException;
    
public static oracle.toplink.essentials.exceptions.ConversionExceptionincorrectTimestampFormat(java.lang.String timestampString)

        Object[] args = { timestampString };
        String message = ExceptionMessageGenerator.buildMessage(ConversionException.class, INCORRECT_TIMESTAMP_FORMAT, args);
        ConversionException conversionException = new ConversionException(message, timestampString, java.sql.Timestamp.class, null);
        conversionException.setErrorCode(INCORRECT_TIMESTAMP_FORMAT);
        return conversionException;
    
public voidsetClassToConvertTo(java.lang.Class classToConvertTo)
INTERNAL: Set the class to convert to.

        this.classToConvertTo = classToConvertTo;
    
public voidsetSourceObject(java.lang.Object sourceObject)
INTERNAL: Set the object for which the problem was detected.

        this.sourceObject = sourceObject;