summaryrefslogtreecommitdiff
path: root/src/dbc/scala/dbc/result/Field.scala
blob: 5fc8be17ea3905817edafc97b6aee4a75872897e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2006, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |                                         **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

// $Id:Field.scala 6853 2006-03-20 16:58:47 +0100 (Mon, 20 Mar 2006) dubochet $


package scala.dbc.result;


import scala.dbc.datatype._;
import scala.dbc.value._;

/** An ISO-9075:2003 (SQL) table field. */
abstract class Field {

  /** The content (value) of the field. The type of this value is undefined,
   * transformation into a useful type will be done by an automatic view
   * function defined in the field object. */
  def content: Value;

  final def value[Type <: Value]: Type =
    content.asInstanceOf[Type];

  final def exactNumericValue[NativeType] =
    content.asInstanceOf[dbc.value.ExactNumeric[NativeType]];

  final def approximateNumericValue[NativeType] =
    content.asInstanceOf[dbc.value.ApproximateNumeric[NativeType]];

  final def booleanValue =
    content.asInstanceOf[dbc.value.Boolean];

  final def characterValue =
    content.asInstanceOf[dbc.value.Character];

  final def characterLargeObjectValue =
    content.asInstanceOf[dbc.value.CharacterLargeObject];

  final def characterVaryingValue =
    content.asInstanceOf[dbc.value.CharacterVarying];

  final def unknownValue =
    content.asInstanceOf[dbc.value.Unknown];

  /** The tuple that contains this field. */
  def originatingTuple: Tuple;

  /** The field metadata attached to this field. */
  def metadata: FieldMetadata;

}

object Field {

  implicit def fieldToValue (field:Field): Value = field.content;


}