~ubuntu-branches/debian/sid/scala/sid

« back to all changes in this revision

Viewing changes to src/dbc/scala/dbc/value/Factory.scala

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg, Mehdi Dogguy, Lucas Satabin, Frank S. Thomas, Emmanuel Bourg
  • Date: 2015-06-05 23:52:59 UTC
  • mfrom: (1.2.11)
  • Revision ID: package-import@ubuntu.com-20150605235259-wk00vgk83dh8o19g
Tags: 2.10.5-1
* Team upload.

[ Mehdi Dogguy ]
* New upstream release (Closes: #744278).

[ Lucas Satabin ]
* Update patches
* Update the clean target
* Update paths of elements to install
* Update watch file

[ Frank S. Thomas ]
* Remove myself from Uploaders.

[ Emmanuel Bourg ]
* The package has been adopted by the Java Team (Closes: #754935)
* Patched the build to avoid downloading libraries from the Internet
* Replaced the minified JavaScript files with unobfuscated ones
* No longer build scala-partest.jar until diffutils is packaged or replaced
* debian/watch: Fixed the versions matched (x.y.z instead of x.y.z..z)
* debian/rules:
  - Added the missing get-orig-source target (Closes: #724704)
  - Improved the clean target
* debian/control:
  - Build depend on scala (>= 2.10) and bnd
  - Use canonical URLs for the Vcs-* fields
  - Standards-Version updated to 3.9.6 (no changes)
* Switch to debhelper level 9

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*                     __                                               *\
2
 
**     ________ ___   / /  ___     Scala API                            **
3
 
**    / __/ __// _ | / /  / _ |    (c) 2003-2011, LAMP/EPFL             **
4
 
**  __\ \/ /__/ __ |/ /__/ __ |                                         **
5
 
** /____/\___/_/ |_/____/_/ | |                                         **
6
 
**                          |/                                          **
7
 
\*                                                                      */
8
 
 
9
 
 
10
 
 
11
 
package scala.dbc
12
 
package value;
13
 
 
14
 
 
15
 
import java.math.BigInteger;
16
 
import java.math.BigDecimal;
17
 
 
18
 
@deprecated(DbcIsDeprecated, "2.9.0") object Factory {
19
 
 
20
 
  def create (result: java.sql.ResultSet, index: Int, expectedDataType: DataType): Value = {
21
 
    expectedDataType.nativeTypeId match {
22
 
      case DataType.OBJECT =>
23
 
        new value.Unknown {
24
 
          val dataType = expectedDataType.asInstanceOf[datatype.Unknown];
25
 
          val nativeValue: AnyRef = result.getObject(index);
26
 
        }
27
 
      case DataType.STRING => {
28
 
        expectedDataType match {
29
 
          case t:datatype.Character =>
30
 
              new value.Character {
31
 
              val dataType = t;
32
 
              val nativeValue: String = result.getString(index);
33
 
            }
34
 
          case t:datatype.CharacterVarying =>
35
 
            new value.CharacterVarying {
36
 
              val dataType = t;
37
 
              val nativeValue: String = result.getString(index);
38
 
            }
39
 
          case t:datatype.CharacterLargeObject =>
40
 
            new value.CharacterLargeObject {
41
 
              val dataType = t;
42
 
              val nativeValue: String = result.getString(index);
43
 
            }
44
 
        }
45
 
      }
46
 
      case DataType.BOOLEAN =>
47
 
        new value.Boolean {
48
 
          val dataType = expectedDataType.asInstanceOf[datatype.Boolean];
49
 
          val nativeValue: scala.Boolean = result.getBoolean(index);
50
 
        }
51
 
      case DataType.FLOAT  =>
52
 
        new value.ApproximateNumeric[Float] {
53
 
          val dataType = expectedDataType.asInstanceOf[datatype.ApproximateNumeric[Float]];
54
 
          val nativeValue: Float = result.getFloat(index);
55
 
        }
56
 
      case DataType.DOUBLE =>
57
 
        new value.ApproximateNumeric[Double] {
58
 
          val dataType = expectedDataType.asInstanceOf[datatype.ApproximateNumeric[Double]];
59
 
           val nativeValue: Double = result.getDouble(index);
60
 
        }
61
 
      case DataType.BYTE =>
62
 
        new value.ExactNumeric[Byte] {
63
 
          val dataType = expectedDataType.asInstanceOf[datatype.ExactNumeric[Byte]];
64
 
          val nativeValue: Byte = result.getByte(index);
65
 
        }
66
 
      case DataType.SHORT =>
67
 
        new value.ExactNumeric[Short] {
68
 
          val dataType = expectedDataType.asInstanceOf[datatype.ExactNumeric[Short]];
69
 
          val nativeValue: Short = result.getShort(index);
70
 
        }
71
 
      case DataType.INT =>
72
 
        new value.ExactNumeric[Int] {
73
 
          val dataType = expectedDataType.asInstanceOf[datatype.ExactNumeric[Int]];
74
 
          val nativeValue: Int = result.getInt(index);
75
 
        }
76
 
      case DataType.LONG =>
77
 
        new value.ExactNumeric[Long] {
78
 
          val dataType = expectedDataType.asInstanceOf[datatype.ExactNumeric[Long]];
79
 
          val nativeValue:Long = result.getLong(index);
80
 
        }
81
 
      case DataType.BIG_INTEGER =>
82
 
        new value.ExactNumeric[BigInteger] {
83
 
          val dataType = expectedDataType.asInstanceOf[datatype.ExactNumeric[BigInteger]];
84
 
          val nativeValue: BigInteger = result.getBigDecimal(index).unscaledValue();
85
 
        }
86
 
      case DataType.BIG_DECIMAL =>
87
 
        new value.ExactNumeric[BigDecimal] {
88
 
          val dataType = expectedDataType.asInstanceOf[datatype.ExactNumeric[BigDecimal]];
89
 
          val nativeValue: BigDecimal = result.getBigDecimal(index);
90
 
        }
91
 
 
92
 
    }
93
 
  }
94
 
 
95
 
}