changeset 1:4319b991f2a3 tip

~ add some dumping methods ~ update to sbt 0.7.4
author Alexandre Bertails <bertails@w3.org>
date Fri, 04 Jun 2010 10:40:00 -0400
parents f3fe2188ab5f
children
files project/build.properties src/main/scala/net/croz/scardf/Model.scala
diffstat 2 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/project/build.properties	Mon Mar 15 20:30:12 2010 -0400
+++ b/project/build.properties	Fri Jun 04 10:40:00 2010 -0400
@@ -2,8 +2,8 @@
 #Thu Feb 25 21:29:24 EST 2010
 project.organization=W3C
 project.name=scardf-2.8
-sbt.version=0.7.1
-project.version=1.0
+sbt.version=0.7.4
+project.version=0.2.1
 def.scala.version=2.7.7
 build.scala.versions=2.8.0.Beta1
 project.initialize=false
--- a/src/main/scala/net/croz/scardf/Model.scala	Mon Mar 15 20:30:12 2010 -0400
+++ b/src/main/scala/net/croz/scardf/Model.scala	Fri Jun 04 10:40:00 2010 -0400
@@ -1,6 +1,6 @@
 package net.croz.scardf
 
-import java.io.StringWriter
+import java.io.{File, StringWriter,PrintStream}
 import com.hp.hpl.jena.rdf.model.AnonId
 import com.hp.hpl.jena.rdf.model.ModelFactory
 import com.hp.hpl.jena.rdf.model.Resource
@@ -10,6 +10,7 @@
 import com.hp.hpl.jena.rdf.model.Property
 import com.hp.hpl.jena.rdf.model.{Model => JModel}
 import com.hp.hpl.jena.ontology.OntModel
+import com.hp.hpl.jena.util.FileManager
 
 class Model( val jModel: JModel ) extends util.Logging {
 
@@ -95,11 +96,14 @@
     case m => m
   } )
 
-  def dump = jModel.write( System.out, "TURTLE" )
-  
+  def dump(out:PrintStream, syntax:String):Unit = jModel.write(out, syntax)
+  def dump(syntax:String = "TURTLE"):Unit = dump(System.out, syntax)
+  def dump(file:File, syntax:String):Unit = dump(new PrintStream(file), syntax)
+  def dump(file:File):Unit = dump(file, "TURTLE")
+
   def dumpAll = jModel match {
     case om: OntModel => om.writeAll( System.out, "TURTLE", null )
-    case _ => dump
+    case _ => dump("TURTLE")
   }
   
   def dumpStatements = for ( s <- statements ) println( s )
@@ -148,4 +152,11 @@
   
   implicit def toRModel( jm: JModel ) = Model( jm )
   implicit def toJModel( rm: Model ) = rm.jModel
+
+  def apply(filepath:String, base:String=null):Model = {
+    val jModel = ModelFactory.createDefaultModel()
+    jModel.read(FileManager.get().open(filepath), base)
+    new Model(jModel)
+  }
+
 }
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.