summaryrefslogtreecommitdiff
path: root/src/library/scala/dbc/result/Field.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/scala/dbc/result/Field.scala')
-rw-r--r--src/library/scala/dbc/result/Field.scala60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/library/scala/dbc/result/Field.scala b/src/library/scala/dbc/result/Field.scala
new file mode 100644
index 0000000000..af129d18b7
--- /dev/null
+++ b/src/library/scala/dbc/result/Field.scala
@@ -0,0 +1,60 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2005, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+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 view (field:Field): Value = field.content;
+
+
+
+}