Beispiel #1
0
 public void InvalidConversion()
 {
     try
     {
         throw HsqlConvert.InvalidConversion(java.sql.Types.DATALINK);
     }
     catch (HsqlDataSourceException hdse)
     {
         Assert.AreEqual(org.hsqldb.Trace.INVALID_CONVERSION, -hdse.ErrorCode);
     }
 }
        /// <summary>
        /// Gets the <c>System.Data.SqlTypes</c> representation
        /// of the value of the field with the given column ordinal
        /// in the current row of the result set.
        /// </summary>
        /// <remarks>
        /// Because this method does not check if this reader
        /// is open or if row data is available, it should be invoked
        /// *only* when it is already known that this reader is open and
        /// row data is available.
        /// </remarks>
        /// <param name="ordinal">The column ordinal.</param>
        /// <returns>The <c>System.Data.SqlTypes</c> representation</returns>
        internal object GetSqlValueInternal(int ordinal)
        {
            object value = m_currentRecord.data[ordinal];

            bool isNull = (value == null);

            int type = m_metaData.colTypes[ordinal];

            switch (type)
            {
            case org.hsqldb.Types.ARRAY:
            {
                throw HsqlConvert.InvalidConversion(type);
            }

            case org.hsqldb.Types.BIGINT:
            {
                return((isNull)
                            ? SqlInt64.Null
                            : new SqlInt64(((java.lang.Long)value).longValue()));
            }

            case org.hsqldb.Types.BINARY:
            {
                return((isNull)
                            ? SqlBinary.Null
                            : new SqlBinary(((org.hsqldb.types.Binary)value).getBytes()));
            }

            case org.hsqldb.Types.BLOB:
            {
                throw HsqlConvert.InvalidConversion(type);
            }

            case org.hsqldb.Types.BOOLEAN:
            {
                return((isNull)
                            ? SqlBoolean.Null
                            : ((java.lang.Boolean)value).booleanValue()
                                ? SqlBoolean.True
                                : SqlBoolean.False);
            }

            case org.hsqldb.Types.CHAR:
            {
                return((isNull)
                            ? SqlString.Null
                            : new SqlString((string)value));
            }

            case org.hsqldb.Types.CLOB:
            {
                throw HsqlConvert.InvalidConversion(type);
            }

            case org.hsqldb.Types.DATALINK:
            {
                throw HsqlConvert.InvalidConversion(type);
            }

            case org.hsqldb.Types.DATE:
            {
                return((isNull)
                            ? SqlDateTime.Null
                            : new SqlDateTime(
                           HsqlConvert.FromJava.ToDate(((java.sql.Date)value).getTime())));
            }

            case org.hsqldb.Types.DECIMAL:
            {
                return((isNull)
                            ? SqlDecimal.Null
                            : new SqlDecimal(HsqlConvert.FromJava.ToDecimal((java.math.BigDecimal)value)));
            }

            case org.hsqldb.Types.DISTINCT:
            {
                throw HsqlConvert.InvalidConversion(type);
            }

            case org.hsqldb.Types.DOUBLE:
            {
                return((isNull)
                            ? SqlDouble.Null
                            : new SqlDouble(((java.lang.Double)value).doubleValue()));
            }

            case org.hsqldb.Types.FLOAT:
            {
                return((isNull)
                            ? SqlDouble.Null
                            : new SqlDouble(((java.lang.Double)value).doubleValue()));
            }

            case org.hsqldb.Types.INTEGER:
            {
                return((isNull)
                            ? SqlInt32.Null
                            : new SqlInt32(((java.lang.Integer)value).intValue()));
            }

            case org.hsqldb.Types.JAVA_OBJECT:
            {
                throw HsqlConvert.InvalidConversion(type);
            }

            case org.hsqldb.Types.LONGVARBINARY:
            {
                return((isNull)
                            ? SqlBinary.Null
                            : new SqlBinary(((org.hsqldb.types.Binary)value).getBytes()));
            }

            case org.hsqldb.Types.LONGVARCHAR:
            {
                return((isNull)
                            ? SqlString.Null
                            : new SqlString((string)value));
            }

            case org.hsqldb.Types.NULL:
            {
                throw HsqlConvert.InvalidConversion(type);
            }

            case org.hsqldb.Types.NUMERIC:
            {
                return((isNull)
                            ? SqlDecimal.Null
                            : new SqlDecimal(HsqlConvert.FromJava.ToDecimal((java.math.BigDecimal)value)));
            }

            case org.hsqldb.Types.OTHER:
            {
                throw HsqlConvert.InvalidConversion(type);
            }

            case org.hsqldb.Types.REAL:
            {
                return((isNull)
                            ? SqlSingle.Null
                            : new SqlSingle(((java.lang.Double)value).floatValue()));
            }

            case org.hsqldb.Types.REF:
            {
                throw HsqlConvert.InvalidConversion(type);
            }

            case org.hsqldb.Types.SMALLINT:
            {
                return((isNull)
                            ? SqlInt16.Null
                            : new SqlInt16(((java.lang.Integer)value).shortValue()));
            }

            case org.hsqldb.Types.STRUCT:
            {
                throw HsqlConvert.InvalidConversion(type);
            }

            case org.hsqldb.Types.TIME:
            {
                return((isNull)
                            ? SqlDateTime.Null
                            : new SqlDateTime(
                           HsqlConvert.FromJava.ToTime(((java.sql.Time)value).getTime())));
            }

            case org.hsqldb.Types.TIMESTAMP:
            {
                return((isNull)
                            ? SqlDateTime.Null
                            : new SqlDateTime(
                           HsqlConvert.FromJava.ToTimestamp(((java.sql.Timestamp)value).getTime())));
            }

            case org.hsqldb.Types.TINYINT:
            {
                return((isNull)
                            ? SqlInt16.Null
                            : new SqlInt16(((java.lang.Integer)value).shortValue()));
            }

            case org.hsqldb.Types.VARBINARY:
            {
                return((isNull)
                            ? SqlBinary.Null
                            : new SqlBinary(((org.hsqldb.types.Binary)value).getBytes()));
            }

            case org.hsqldb.Types.VARCHAR:
            {
                return((isNull)
                            ? SqlString.Null
                            : new SqlString((string)value));
            }

            case org.hsqldb.Types.VARCHAR_IGNORECASE:
            {
                return((isNull)
                            ? SqlString.Null
                            : new SqlString((string)value));
            }

            case org.hsqldb.Types.XML:
            {
                throw HsqlConvert.InvalidConversion(type);
            }

            default:
            {
                throw HsqlConvert.InvalidConversion(type);
            }
            }
        }