abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r596368 - in /incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax: FOMBuilder.java FOMElement.java
Date Mon, 19 Nov 2007 17:09:37 GMT
Author: jmsnell
Date: Mon Nov 19 09:09:36 2007
New Revision: 596368

URL: http://svn.apache.org/viewvc?rev=596368&view=rev
Log:
setText wasn't using FOMTextValue, which was causing the Json writer to fail.  It would have
caused other problems also.

Modified:
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java?rev=596368&r1=596367&r2=596368&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
Mon Nov 19 09:09:36 2007
@@ -37,6 +37,7 @@
 import org.apache.axiom.om.OMDocument;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMText;
@@ -377,14 +378,14 @@
           //if (isDataHandlerAware && Boolean.TRUE == parser.getProperty(OMConstants.IS_BINARY))
{
           if (Boolean.TRUE == parser.getProperty(OMConstants.IS_BINARY)) {
               Object dataHandler = parser.getProperty(OMConstants.DATA_HANDLER);
-              OMText text = omfactory.createOMText(dataHandler, true);
+              OMText text = new FOMTextValue(dataHandler,true,(OMFactory)this);
               omElement.addChild(text);
               return text;
           } else {
-              return omfactory.createOMText(omElement, value, textType);
+              return new FOMTextValue(omElement, value, textType, (OMFactory)this);
           }
       } catch (IllegalArgumentException e) {
-          return omfactory.createOMText(omElement, value, textType);
+          return new FOMTextValue(omElement, value, textType, (OMFactory)this);
       }
   }
 }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java?rev=596368&r1=596367&r2=596368&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
Mon Nov 19 09:09:36 2007
@@ -282,27 +282,26 @@
       attr.setAttributeValue(value);
     } else {
       if (value != null) {
-        if (qname.getNamespaceURI() != null) {
+        String uri = qname.getNamespaceURI();
+        String prefix = qname.getPrefix();
+        if (uri != null) {
+          OMNamespace ns = findNamespace(uri, prefix);
+          if (ns == null) ns = factory.createOMNamespace(uri, prefix);
           attr = factory.createOMAttribute(
-            qname.getLocalPart(), 
-            factory.createOMNamespace(
-              qname.getNamespaceURI(), 
-              qname.getPrefix()), 
-            value);
+            qname.getLocalPart(), ns, value);
         } else {
           attr = factory.createOMAttribute(
             qname.getLocalPart(), 
             null, 
             value);
         }
-        addAttribute(attr);
+        if (attr != null) addAttribute(attr);
       } else {
         removeAttribute(attr);
       }
     }
   }
   
-  
   protected <E extends Element>List<E> _getChildrenAsSet(QName qname) {
     FOMFactory factory = (FOMFactory) getFactory();
     return new FOMList(new FOMElementIteratorWrapper(
@@ -506,9 +505,16 @@
   
   public void setText(String text) {
     complete();
-    if (text != null)
-      super.setText(text);
-    else 
+    if (text != null) {
+      OMNode child = this.getFirstOMChild();
+      while (child != null) {
+          if (child.getType() == OMNode.TEXT_NODE) {
+              child.detach();
+          }
+          child = child.getNextOMSibling();
+      }
+      getOMFactory().createOMText(this, text);
+    } else 
       _removeAllChildren();
   }
 
@@ -854,4 +860,5 @@
       throws IOException {
     writeTo(getFactory().getAbdera().getWriterFactory().getWriter(writer),out,options);
   }
+
 }



Mime
View raw message