~ simple refactoring
authorAlexandre Bertails <bertails@gmail.com>
Sat, 27 Aug 2011 20:13:23 -0400
changeset 11 e323200c6ecc
parent 10 6874dd1a9497
child 12 4fcf6502668c
~ simple refactoring
src/main/scala/Main.scala
src/main/scala/Post.scala
--- a/src/main/scala/Main.scala	Sat Aug 27 20:10:20 2011 -0400
+++ b/src/main/scala/Main.scala	Sat Aug 27 20:13:23 2011 -0400
@@ -101,32 +101,6 @@
 
 }
 
-sealed trait Post
-case class PostUpdate(update:UpdateRequest) extends Post
-case class PostRDF(model:Model) extends Post
-
-object Post {
-  
-  def parse(is:InputStream, baseURI:String):Post = {
-    val source = Source.fromInputStream(is, "UTF-8")
-    val s = source.getLines.mkString("\n")
-    parse(s, baseURI)
-  }
-  
-  def parse(s:String, baseURI:String):Post = {
-    val reader = new StringReader(s)
-    try {
-      val update:UpdateRequest = UpdateFactory.create(s, baseURI)
-      PostUpdate(update)      
-    } catch {
-      case qpe:QueryParseException => {
-        val model = modelFromString(s, baseURI)
-        PostRDF(model)
-      }
-    }
-  }
-  
-}
 
 object ReadWriteWebMain {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/scala/Post.scala	Sat Aug 27 20:13:23 2011 -0400
@@ -0,0 +1,40 @@
+package org.w3.readwriteweb
+
+import java.io._
+import scala.io.Source
+
+import org.slf4j.{Logger, LoggerFactory}
+
+import com.hp.hpl.jena.rdf.model._
+import com.hp.hpl.jena.query._
+import com.hp.hpl.jena.update._
+import com.hp.hpl.jena.shared.JenaException
+
+import org.w3.readwriteweb.util._
+
+sealed trait Post
+case class PostUpdate(update:UpdateRequest) extends Post
+case class PostRDF(model:Model) extends Post
+
+object Post {
+  
+  def parse(is:InputStream, baseURI:String):Post = {
+    val source = Source.fromInputStream(is, "UTF-8")
+    val s = source.getLines.mkString("\n")
+    parse(s, baseURI)
+  }
+  
+  def parse(s:String, baseURI:String):Post = {
+    val reader = new StringReader(s)
+    try {
+      val update:UpdateRequest = UpdateFactory.create(s, baseURI)
+      PostUpdate(update)      
+    } catch {
+      case qpe:QueryParseException => {
+        val model = modelFromString(s, baseURI)
+        PostRDF(model)
+      }
+    }
+  }
+  
+}