+ scaladocs on SqlToXMLRes methods
authorEric Prud'hommeaux <eric@w3.org>
Sat, 12 Jun 2010 09:37:34 -0400
changeset 205 745da618b07c
parent 204 89e270df8e93
child 206 d88313013f7d
child 207 c23b9fd839cd
+ scaladocs on SqlToXMLRes methods
src/main/scala/SparqlToSql.scala
--- a/src/main/scala/SparqlToSql.scala	Sat Jun 12 09:27:16 2010 -0400
+++ b/src/main/scala/SparqlToSql.scala	Sat Jun 12 09:37:34 2010 -0400
@@ -1053,6 +1053,10 @@
  *     binding("emp", "253", rdfmap, stem) +
  *     binding("name", "Bob", rdfmap, stem) +
  *   endresult +
+ *   startresult +
+ *     binding("emp", "258", rdfmap, stem) +
+ *     // employee 258 has no name attribute so omit this binding
+ *   endresult +
  *   foot
  * </pre>
  *
@@ -1060,14 +1064,31 @@
  * @see {@link http://www.w3.org/TR/2008/REC-rdf-sparql-XMLres-20080115/ XML Results Format}
  */
 object SqlToXMLRes {
+
+  /**
+   * Create a SPARQL Results format header and begin the body (results).
+   * @param vars list of variable names to insert into the header
+   */
   def head (vars:List[String]) : String = {
     "<?xml version=\"1.0\"?>\n<sparql xmlns=\"http://www.w3.org/2005/sparql-results#\">\n  <head>\n" +
     vars.map(varname => "    <variable name=\"" + varname + "\"/>\n").mkString + 
     "  </head>\n\n  <results>\n"
   }
+
+  /**
+   * Open a result element
+   */
   def startresult () : String = {
     "    <result> \n"
   }
+
+  /**
+   * Create a binding value appropriate for <code>name</code>'s datatype.
+   * @param name name of bound variable.
+   * @param value lexical value of bound variable, may need normalization from e.g. SQL.
+   * @param varmap mapping of sparql variables to datatypes, emitted by SparqlToSql._2
+   * @param stem  stem URI for all generated RDF URIs.
+   */
   def binding (name:String, value:String, varmap:Map[sparql.Assignable, SparqlToSql.SQL2RDFValueMapper], stem:StemURI) : String = {
     def getattr (b:SparqlToSql.FullOrPartialBinding) : sql.Attribute = {
       b match {
@@ -1088,9 +1109,17 @@
     }
     "      <binding name=\"" + name + "\">\n	" + t + "\n      </binding>\n"
   }
+
+  /**
+   * Close a result element.
+   */
   def endresult () : String = {
     "    </result>\n"
   }
+
+  /**
+   * End SPARQL Results document.
+   */
   def foot () : String = {
     "  </results>\n</sparql>\n"
   }