Permalink
Browse files

[scala] Support nullable flag for column of row list

  • Loading branch information...
cchantep
cchantep committed Jan 11, 2014
1 parent 4edb03e commit 38f0b52dc120488d1bae3a4e830a849958146fe3
Showing with 9 additions and 5 deletions.
  1. +1 −1 project/Scala.scala
  2. +2 −2 scala/src/main/scala/Acolyte.scala
  3. +6 −2 scala/src/main/templates/RowList.tmpl
View
@@ -102,7 +102,7 @@ trait Scala {
val gp = (for (i 0 until n) yield letter(i)).mkString(", ")
val ca = (for (i 0 until n) yield "l.c%d".format(i)).mkString(", ")
"implicit def RowList%dAsScala[%s](l: RowList%d.Impl[%s]): ScalaRowList%d[%s] = new ScalaRowList%d[%s](%s, l.rows, l.colNames)".format(n, gp, n, gp, n, gp, n, gp, ca)
"implicit def RowList%dAsScala[%s](l: RowList%d.Impl[%s]): ScalaRowList%d[%s] = new ScalaRowList%d[%s](%s, l.rows, l.colNames, l.colNullables)".format(n, gp, n, gp, n, gp, n, gp, ca)
})
val tmpl = base / "src" / "main" / "templates" / "RowLists.tmpl"
@@ -11,7 +11,7 @@ import scala.collection.JavaConversions
import acolyte.ParameterMetaData.ParameterDef
import acolyte.StatementHandler.Parameter
import acolyte.AbstractCompositeHandler.{ QueryHandler, UpdateHandler }
import acolyte.RowList.Column
import acolyte.RowList.{ Column Col }
/**
* Acolyte DSL.
@@ -113,7 +113,7 @@ object Implicits extends ScalaRowLists with CompositeHandlerImplicits {
* }}}
*/
implicit def PairAsColumn[T](c: (Class[T], String)): Column[T] =
Column(c._1, c._2)
Col(c._1, c._2)
}
@@ -1,14 +1,15 @@
// -*- mode: scala -*-
package acolyte
import java.lang.{Boolean=>JBool}
import java.util.{ ArrayList, List JList, Map JMap }
/** Scala implementation of RowList#N#. */
private[acolyte] final class ScalaRowList#N#[#TC#](#CV#, rows: JList[Row#N#[#TC#]], colNames: JMap[String, Integer]) extends RowList#N#[#TC#, ScalaRowList#N#[#TC#]] {
private[acolyte] final class ScalaRowList#N#[#TC#](#CV#, rows: JList[Row#N#[#TC#]], colNames: JMap[String, Integer], colNullables: JMap[Integer, JBool]) extends RowList#N#[#TC#, ScalaRowList#N#[#TC#]] {
lazy val factory: RowList#N#.Factory[#TC#, ScalaRowList#N#[#TC#]] =
new RowList#N#.Factory[#TC#, ScalaRowList#N#[#TC#]]() {
def rowList(#CA#, rows: JList[Row#N#[#TC#]], colNames: JMap[String, Integer]): ScalaRowList#N#[#TC#] = new ScalaRowList#N#[#TC#](#CC#, rows, colNames)
def rowList(#CA#, rows: JList[Row#N#[#TC#]], colNames: JMap[String, Integer], colNullables: JMap[Integer,JBool]): ScalaRowList#N#[#TC#] = new ScalaRowList#N#[#TC#](#CC#, rows, colNames, colNullables)
}
/** Rows */
@@ -17,6 +18,9 @@ private[acolyte] final class ScalaRowList#N#[#TC#](#CV#, rows: JList[Row#N#[#TC#
/** Column labels */
lazy val getColumnLabels: JMap[String, Integer] = colNames
/** Column nullables */
lazy val getColumnNullables: JMap[Integer, JBool] = colNullables
/** Column classes */
lazy val getColumnClasses: JList[Class[_]] = {
val list: JList[Class[_]] = new ArrayList[Class[_]]()

0 comments on commit 38f0b52

Please sign in to comment.