changeset 19:d7d4ffe9d5a7

~ follow RDF defn in http://www.w3.org/2001/sw/rdb2rdf/directGraph/?english;scala
author Eric Prud'hommeaux <eric@w3.org>
date Sun, 26 Sep 2010 07:48:33 -0400
parents c7cca0b31bb9
children ae6390ee0fa4
files src/main/scala/Main.scala
diffstat 1 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/scala/Main.scala	Sun Sep 26 07:12:51 2010 -0400
+++ b/src/main/scala/Main.scala	Sun Sep 26 07:48:33 2010 -0400
@@ -60,15 +60,22 @@
   implicit def iri2objectiri(i:IRI):Object = ObjectIRI(i)
   case class ObjectBNode(b:BNode) extends Object
   implicit def bnode2objectbnode(b:BNode):Object = ObjectBNode(b)
-  case class ObjectTypedLiteral (l:TypedLiteral) extends Object
-  implicit def literal2objectliteral(l:TypedLiteral):Object = ObjectTypedLiteral(l)
+  case class ObjectLiteral (l:Literal) extends Object
 
   case class IRI(iri:String)
+
   case class BNode(label:String)
+
+  sealed abstract class Literal
+  case class LiteralTyped(i:TypedLiteral) extends Literal
+  implicit def typed2object(i:TypedLiteral):Object = ObjectLiteral(LiteralTyped(i))
+  case class LiteralPlain(b:PlainLiteral) extends Literal
+  implicit def plain2object(b:PlainLiteral):Object = ObjectLiteral(LiteralPlain(b))
+
+  case class PlainLiteral(value:String, langtag:Option[String])
+
   case class TypedLiteral(value:String, datatype:IRI)
 
-
-
 }
 
 object Transformer {
@@ -108,14 +115,14 @@
   def scalartriples (u:StemIRI, rn:RelName, s:IRI, a:AttrName, h:Header, t:Tuple) : Triple = {
     val p = predicatemap (u, rn, a)
     val l = t(a).asInstanceOf[LexicalValue]
-    val o = ObjectTypedLiteral(literalmap(l, sqlDatatype(h, a)))
+    val o = literalmap(l, sqlDatatype(h, a))
     Triple(s, p, o)
   }
   def referencetriples (u:StemIRI, rn:RelName, s:IRI, a:AttrName, h:Header, t:Tuple) : Triple = {
     val p = predicatemap (u, rn, a)
     val l = t(a).asInstanceOf[LexicalValue]
     val target = h.fks(a)
-    val o = ObjectIRI(nodemap(u, target.rel, target.attr, l))
+    val o = nodemap(u, target.rel, target.attr, l)
     Triple(s, p, o)
   }
 
@@ -135,12 +142,12 @@
       case l:LexicalValue if hasForeignKeys(a) => {
 	val target = h.fks(a)
 	val p = predicatemap (u, rn, a)
-	val o = ObjectIRI(nodemap(u, target.rel, target.attr, l))
+	val o = nodemap(u, target.rel, target.attr, l)
 	Some(Triple(s, p, o))
       }
       case l:LexicalValue => {
 	val p = predicatemap (u, rn, a)
-	val o = ObjectTypedLiteral(literalmap(l, sqlDatatype(h, a)))
+	val o = literalmap(l, sqlDatatype(h, a))
 	Some(Triple(s, p, o))
       }
     }
Set up and maintained by W3C Systems Team, please report bugs to sysreq@w3.org.

W3C would like to thank Microsoft who donated the server that allows us to run this service.