class TypeConvertingSqlAccessor implements SqlAccessor {

  @Override
  public long getLong( int rowOffset ) throws InvalidAccessException {
    final long result;
    switch ( getType().getMinorType() ) {
      // 1. Regular type:
      case BIGINT:
        result = innerAccessor.getLong( rowOffset );
        break;

      // 2. Converted-from types:
      case TINYINT:
        result = innerAccessor.getByte( rowOffset );
        break;
      case SMALLINT:
        result = innerAccessor.getShort( rowOffset );
        break;
      case INT:
        result = innerAccessor.getInt( rowOffset );
        break;
      case FLOAT4:
        result = getLongValueOrThrow( innerAccessor.getFloat( rowOffset ),
                                      "Java float / SQL REAL/FLOAT" );
        break;
      case FLOAT8:
        result = getLongValueOrThrow( innerAccessor.getDouble( rowOffset ),
                                      "Java double / SQL DOUBLE PRECISION" );
        break;
      case VARDECIMAL:
        result = getLongValueOrThrow(
            innerAccessor.getBigDecimal(rowOffset).longValue(),
            "Java BigDecimal / SQL DECIMAL PRECISION");
        break;

      // 3. Not-yet-converted and unconvertible types:
      default:
        result = innerAccessor.getLong( rowOffset );
        break;
    }
    return result;
  }

  public  TypeConvertingSqlAccessor( SqlAccessor innerAccessor );

}