You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by et...@apache.org on 2008/06/04 08:34:44 UTC

svn commit: r663005 - in /incubator/shindig/trunk/java/gadgets/src: main/java/org/apache/shindig/gadgets/spec/View.java test/java/org/apache/shindig/gadgets/spec/ViewTest.java

Author: etnu
Date: Tue Jun  3 23:34:43 2008
New Revision: 663005

URL: http://svn.apache.org/viewvc?rev=663005&view=rev
Log:
Applied patch for SHINDIG-333. This also helps with the functional requirements in SHINDIG-313, though it's not clear that it completely satisfies the use case.


Modified:
    incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/View.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/ViewTest.java

Modified: incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/View.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/View.java?rev=663005&r1=663004&r2=663005&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/View.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/View.java Tue Jun  3 23:34:43 2008
@@ -47,6 +47,14 @@
   }
 
   /**
+   * Content@type - the raw, possibly non-standard string
+   */
+  private final String rawType;
+  public String getRawType() {
+    return rawType;
+  }
+
+  /**
    * Content@href
    *
    * All substitutions
@@ -104,7 +112,7 @@
   public String toString() {
     StringBuilder buf = new StringBuilder();
     buf.append("<Content type=\"")
-       .append(type.toString().toLowerCase())
+       .append(rawType)
        .append("\" href=\"")
        .append(href)
        .append("\" view=\"")
@@ -126,10 +134,11 @@
 
     boolean quirks = true;
     URI href = null;
+    String contentType = null;
     ContentType type = null;
     StringBuilder content = new StringBuilder();
     for (Element element : elements) {
-      String contentType = XmlUtil.getAttribute(element, "type");
+      contentType = XmlUtil.getAttribute(element, "type");
       if (contentType != null) {
         ContentType newType = ContentType.parse(contentType);
         if (type != null && newType != type) {
@@ -147,6 +156,7 @@
     this.needsUserPrefSubstitution = this.content.contains("__UP_");
     this.quirks = quirks;
     this.href = href;
+    this.rawType = contentType;
     this.type = type;
     if (type == ContentType.URL && this.href == null) {
       throw new SpecParserException(
@@ -166,6 +176,7 @@
   private View(View view) {
     needsUserPrefSubstitution = view.needsUserPrefSubstitution;
     name = view.name;
+    rawType = view.rawType;
     type = view.type;
     quirks = view.quirks;
   }

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/ViewTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/ViewTest.java?rev=663005&r1=663004&r2=663005&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/ViewTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/spec/ViewTest.java Tue Jun  3 23:34:43 2008
@@ -45,6 +45,7 @@
     assertEquals(viewName, view.getName());
     assertEquals(false, view.getQuirks());
     assertEquals(View.ContentType.HTML, view.getType());
+    assertEquals("html", view.getRawType());
     assertEquals(content, view.getContent());
   }
 
@@ -58,6 +59,17 @@
    assertEquals(body1 + body2, view.getContent());
   }
 
+  public void testNonStandardContentType() throws Exception {
+    String contentType = "html-inline";
+    String xml = "<Content" +
+                 " type=\"" + contentType + "\"" +
+                 " quirks=\"false\"><![CDATA[blah]]></Content>";
+    View view = new View("default", Arrays.asList(XmlUtil.parse(xml)));
+
+    assertEquals(View.ContentType.HTML, view.getType());
+    assertEquals(contentType, view.getRawType());
+  }
+
   public void testContentTypeConflict() throws Exception {
     String content1 = "<Content type=\"html\"/>";
     String content2