abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r579328 - /incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONUtil.java
Date Tue, 25 Sep 2007 17:41:46 GMT
Author: jmsnell
Date: Tue Sep 25 10:41:39 2007
New Revision: 579328

URL: http://svn.apache.org/viewvc?rev=579328&view=rev
Log:
Some fixes to the output to remove bad commas

Modified:
    incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONUtil.java

Modified: incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONUtil.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONUtil.java?rev=579328&r1=579327&r2=579328&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONUtil.java
(original)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONUtil.java
Tue Sep 25 10:41:39 2007
@@ -89,7 +89,6 @@
 
       writeLanguageFields(element, writer);
       
-      writer.write(',');
       writeField("term", category.getTerm(), writer);
       if (category.getScheme() != null) {
         writer.write(',');
@@ -127,7 +126,7 @@
     } else if (element instanceof Content) {
       Content content = (Content)element;      
       writeLanguageFields(element, writer);
-      writer.write(',');      
+
       if (element.getResolvedBaseUri() != null) {
         writeField("base", element.getResolvedBaseUri().toASCIIString(), writer);
         writer.write(',');
@@ -282,7 +281,6 @@
       writeLanguageFields(element, writer);
       
       if (generator.getVersion() != null) {
-        writer.write(',');
         writeField("version", generator.getVersion(), writer);
       }    
       if (generator.getResolvedUri() != null) {
@@ -297,11 +295,9 @@
       Link link = (Link)element;
       
       writeLanguageFields(element, writer);
+
+      writeField("href", link.getResolvedHref().toASCIIString(), writer);
       
-      if (link.getResolvedHref() != null) {
-        writer.write(',');
-        writeField("href", link.getResolvedHref().toASCIIString(), writer);
-      }
       if (link.getRel() != null) {
         writer.write(',');
         writeField("rel", link.getRel(), writer);
@@ -322,7 +318,7 @@
         writer.write(',');
         writeField("length", link.getLength(), writer);
       }
-      
+
       writer.write(',');
       writeExtensions((ExtensibleElement)element,writer);
     } else if (element instanceof Person) {
@@ -330,7 +326,6 @@
       
       writeLanguageFields(element, writer);
       
-      writer.write(',');
       writeField("name",person.getName(),writer);
       writer.write(',');
       writeField("email",person.getEmail(),writer);
@@ -413,7 +408,6 @@
       
       writeLanguageFields(element, writer);
       
-      writer.write(',');
       if (element.getResolvedBaseUri() != null) {
         writeField("base", element.getResolvedBaseUri().toASCIIString(), writer);
         writer.write(',');
@@ -471,7 +465,7 @@
       writeQName(element.getQName(),writer);
       writer.write(',');
       writeLanguageFields(element, writer);
-      writer.write(',');
+
       if (element.getResolvedBaseUri() != null) {
         writeField("base", element.getResolvedBaseUri().toASCIIString(), writer);
         writer.write(',');
@@ -573,6 +567,7 @@
   private static void writeLanguageFields(Element element, Writer writer) throws IOException
{
     String lang = element.getLanguage();
     boolean whitespace = element.getMustPreserveWhitespace();
+    BidiHelper.Direction dir = BidiHelper.getDirection(element);
     if (lang != null) {
       writeField("language",lang,writer);
     }
@@ -582,11 +577,15 @@
       writeField("whitespace", "false", writer);
     }
     
-    BidiHelper.Direction dir = BidiHelper.getDirection(element);
     if (dir != null && dir != BidiHelper.Direction.UNSPECIFIED) {
       if (lang != null || !whitespace) writer.write(',');
       writeField("dir", dir.name().toLowerCase(), writer);
     }
+    
+    if (lang != null || 
+        !whitespace || 
+        (dir != null && dir != BidiHelper.Direction.UNSPECIFIED)) 
+      writer.write(',');
   }
   
   private static void writeElement(String name, Element element, Writer writer) throws IOException
{



Mime
View raw message