~ the Representation trait gets its own file
authorAlexandre Bertails <bertails@gmail.com>
Sat, 15 Oct 2011 18:31:37 -0400
changeset 71 753ae107492c
parent 70 1a34982ea440
child 72 c9986c05e45e
~ the Representation trait gets its own file
src/main/scala/Authoritative.scala
src/main/scala/Representation.scala
--- a/src/main/scala/Authoritative.scala	Sat Oct 15 18:28:35 2011 -0400
+++ b/src/main/scala/Authoritative.scala	Sat Oct 15 18:31:37 2011 -0400
@@ -3,56 +3,6 @@
 import unfiltered.request._
 import java.net.URL
 
-sealed trait Representation
-
-object Representation {
-  
-  def fromSuffix(suffix: String): Representation = {
-    suffix match {
-      case "n3" => RDFRepr(N3)
-      case "turtle" | "ttl" => RDFRepr(TURTLE)
-      case "rdf" => RDFRepr(RDFXML)
-      case "htm" | "html" | "xhtml" => HTMLRepr
-      case _ => UnknownRepr
-    }
-  }
-  
-  val htmlCharsets = Set("text/html", "application/xhtml+xml")
-  
-  def acceptsHTML(ct: Iterable[String]) =
-    ! (htmlCharsets & ct.toSet).isEmpty
-  
-  def fromAcceptedContentTypes(ct: Iterable[String]): Representation = {
-    Lang(ct) map RDFRepr.apply getOrElse {
-      if (acceptsHTML(ct))
-        HTMLRepr
-      else
-        UnknownRepr
-    }
-  }
-  
-  /** implements http://www.w3.org/2001/tag/doc/metaDataInURI-31 and http://www.w3.org/2001/tag/doc/mime-respect
-    * 
-    * if there is no known suffix (eg. the URI was already the authoritative one),
-    * inspects the given accepted content types
-    * 
-    * This knows only about the RDF and HTML charsets
-    */
-  def apply(
-      suffixOpt: Option[String],
-      ct: Iterable[String]): Representation = {
-    suffixOpt map fromSuffix match {
-      case None | Some(UnknownRepr) => fromAcceptedContentTypes(ct)
-      case Some(repr) => repr
-    }
-  }
-}
-
-case class RDFRepr(lang: Lang) extends Representation
-case object HTMLRepr extends Representation
-case object UnknownRepr extends Representation
-case object NoRepr extends Representation
-
 object Authoritative {
   
   val r = """^(.*)\.(\w{0,4})$""".r
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/scala/Representation.scala	Sat Oct 15 18:31:37 2011 -0400
@@ -0,0 +1,54 @@
+package org.w3.readwriteweb
+
+import unfiltered.request._
+import java.net.URL
+
+sealed trait Representation
+
+object Representation {
+  
+  def fromSuffix(suffix: String): Representation = {
+    suffix match {
+      case "n3" => RDFRepr(N3)
+      case "turtle" | "ttl" => RDFRepr(TURTLE)
+      case "rdf" => RDFRepr(RDFXML)
+      case "htm" | "html" | "xhtml" => HTMLRepr
+      case _ => UnknownRepr
+    }
+  }
+  
+  val htmlCharsets = Set("text/html", "application/xhtml+xml")
+  
+  def acceptsHTML(ct: Iterable[String]) =
+    ! (htmlCharsets & ct.toSet).isEmpty
+  
+  def fromAcceptedContentTypes(ct: Iterable[String]): Representation = {
+    Lang(ct) map RDFRepr.apply getOrElse {
+      if (acceptsHTML(ct))
+        HTMLRepr
+      else
+        UnknownRepr
+    }
+  }
+  
+  /** implements http://www.w3.org/2001/tag/doc/metaDataInURI-31 and http://www.w3.org/2001/tag/doc/mime-respect
+    * 
+    * if there is no known suffix (eg. the URI was already the authoritative one),
+    * inspects the given accepted content types
+    * 
+    * This knows only about the RDF and HTML charsets
+    */
+  def apply(
+      suffixOpt: Option[String],
+      ct: Iterable[String]): Representation = {
+    suffixOpt map fromSuffix match {
+      case None | Some(UnknownRepr) => fromAcceptedContentTypes(ct)
+      case Some(repr) => repr
+    }
+  }
+}
+
+case class RDFRepr(lang: Lang) extends Representation
+case object HTMLRepr extends Representation
+case object UnknownRepr extends Representation
+case object NoRepr extends Representation