Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 4 files changed
  • 0 comments
  • 1 contributor
13 README.md
Source Rendered
... ... @@ -1,3 +1,12 @@
1   -# PayGoo - Pay As You Go data Objects
  1 +# PayGoo - Pay As You GO data Objects
2 2
3   -An object-orient implementation of '[Linked Data Basic Profile](http://www.w3.org/Submission/2012/SUBM-ldbp-20120326/ "Linked Data Basic Profile 1.0")'-compliant containers/resources.
  3 +An object-orient implementation of '[Linked Data Basic Profile](http://www.w3.org/Submission/2012/SUBM-ldbp-20120326/ "Linked Data Basic Profile 1.0")'-compliant containers/resources.
  4 +
  5 +## Dependencies
  6 +
  7 +* [scardf](http://code.google.com/p/scardf/ "Scala RDF API - Google Project Hosting")
  8 +* [spray](spray.cc "A suite of lightweight Scala libraries for building and consuming RESTful web services on top of Akka")
  9 +
  10 +## License
  11 +
  12 +Public Domain.
60 info.paygoo.core.scala
... ... @@ -0,0 +1,60 @@
  1 +import scala.actors.Actor
  2 +import scala.actors.Actor._
  3 +import scala.util.parsing.json._
  4 +
  5 +package info.paygoo.core {
  6 +
  7 + /**
  8 + * Objects that represent a PayGoo's serialisation (or wire format).
  9 + * A PayGoo MUST support all four media types.
  10 + *
  11 + * @param mediatype as of http://www.iana.org/assignments/media-types/
  12 + */
  13 + case class WireFormat ( val mediatype: String )
  14 + object HTML extends WireFormat ( mediatype = "text/html" )
  15 + object JSON extends WireFormat ( mediatype = "application/json" )
  16 + object Text extends WireFormat ( mediatype = "text/plain" )
  17 + object Turtle extends WireFormat ( mediatype = "text/turtle" )
  18 +
  19 + /**
  20 + * The core PayGoo class, just has a label.
  21 + *
  22 + * @param label a human-readable label for the PayGoo
  23 + */
  24 + abstract class PayGoo ( var label: String ) {
  25 + def ser( format: WireFormat = JSON ) : String
  26 + }
  27 +
  28 + /**
  29 + * A PayGoo resource class.
  30 + *
  31 + * @param rlabel a human-readable label for the PayGoo resource
  32 + * @return dunno
  33 + */
  34 + case class PayGooResource ( rlabel: String ) extends PayGoo ( rlabel ) {
  35 + private var r = Map ( "label" -> rlabel )
  36 +
  37 + override def ser ( format: WireFormat = JSON ) : String = format match {
  38 + case HTML => "<div>" + rlabel + "</div>"
  39 + case JSON => JSONObject(r).toString
  40 + case Text => r("label")
  41 + case Turtle => ":a rdfs:label '" + r("label") + "' ."
  42 + }
  43 +
  44 + override def toString = "[PayGooResource: label=" + r("label") + "]"
  45 + }
  46 +
  47 +
  48 + /**
  49 + * Testing the resource ...
  50 + */
  51 + object PayGooResource extends App {
  52 + val r = new PayGooResource("pg0")
  53 + println(r.ser(format=HTML))
  54 + println(r.ser(format=JSON))
  55 + println(r.ser(format=Text))
  56 + println(r.ser(format=Turtle))
  57 + println(r)
  58 + }
  59 +}
  60 +
BIN  lib/joda-time-1.6.jar
Binary file not shown
BIN  lib/scardf-0.6-SNAPSHOT.jar
Binary file not shown

No commit comments for this range

Something went wrong with that request. Please try again.