abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r564958 - in /incubator/abdera/java/trunk: contrib/rss/src/main/java/org/apache/abdera/contrib/rss/ core/src/main/java/org/apache/abdera/model/ core/src/test/java/org/apache/abdera/test/core/ parser/src/main/java/org/apache/abdera/parser/stax/
Date Sat, 11 Aug 2007 18:46:48 GMT
Author: jmsnell
Date: Sat Aug 11 11:46:47 2007
New Revision: 564958

URL: http://svn.apache.org/viewvc?view=rev&rev=564958
Log:
Provide a way of inserting an extension element before another one (some extensions are sensitive
to the ordering of their child elements)

Modified:
    incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssCategory.java
    incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssGuid.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElement.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElementWrapper.java
    incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/core/CoreTest.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java

Modified: incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssCategory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssCategory.java?view=diff&rev=564958&r1=564957&r2=564958
==============================================================================
--- incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssCategory.java
(original)
+++ incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssCategory.java
Sat Aug 11 11:46:47 2007
@@ -25,10 +25,10 @@
 import org.apache.abdera.i18n.iri.IRI;
 import org.apache.abdera.model.Category;
 import org.apache.abdera.model.Element;
-import org.apache.abdera.model.ElementWrapper;
+import org.apache.abdera.model.ExtensibleElementWrapper;
 
 public class RssCategory 
-  extends ElementWrapper 
+  extends ExtensibleElementWrapper 
   implements Category {
 
   public RssCategory(Element internal) {

Modified: incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssGuid.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssGuid.java?view=diff&rev=564958&r1=564957&r2=564958
==============================================================================
--- incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssGuid.java
(original)
+++ incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssGuid.java
Sat Aug 11 11:46:47 2007
@@ -25,12 +25,12 @@
 import org.apache.abdera.factory.Factory;
 import org.apache.abdera.i18n.iri.IRI;
 import org.apache.abdera.model.Element;
-import org.apache.abdera.model.ElementWrapper;
+import org.apache.abdera.model.ExtensibleElementWrapper;
 import org.apache.abdera.model.IRIElement;
 import org.apache.abdera.model.Link;
 
 public class RssGuid 
-  extends ElementWrapper 
+  extends ExtensibleElementWrapper 
   implements IRIElement, Link {
 
   public RssGuid(Element internal) {

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElement.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElement.java?view=diff&rev=564958&r1=564957&r2=564958
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElement.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElement.java
Sat Aug 11 11:46:47 2007
@@ -63,11 +63,23 @@
   void addExtension(Element extension);
 
   /**
+   * Adds an individual extension element before the specified element 
+   */
+  void addExtension(Element extension, Element before);
+  
+  /**
    * Adds an individual extension element
    * @param qname An extension element to create
    * @return The newly created extension element
    */
   <T extends Element>T addExtension(QName qname);
+  
+  /**
+   * Adds an individual extension element
+   * @param qname An extension element to create
+   * @return The newly created extension element
+   */
+  <T extends Element>T addExtension(QName qname, QName before);
   
   /**
    * Adds an individual extension element

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElementWrapper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElementWrapper.java?view=diff&rev=564958&r1=564957&r2=564958
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElementWrapper.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElementWrapper.java
Sat Aug 11 11:46:47 2007
@@ -97,5 +97,13 @@
   public void setMustPreserveWhitespace(boolean preserve) {
     getExtInternal().setMustPreserveWhitespace(preserve);
   }
+
+  public void addExtension(Element extension, Element before) {
+    getExtInternal().addExtension(extension,before);
+  }
+
+  public <T extends Element> T addExtension(QName qname, QName before) {
+    return getExtInternal().addExtension(qname,before);
+  }
   
 }

Modified: incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/core/CoreTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/core/CoreTest.java?view=diff&rev=564958&r1=564957&r2=564958
==============================================================================
--- incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/core/CoreTest.java
(original)
+++ incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/core/CoreTest.java
Sat Aug 11 11:46:47 2007
@@ -720,6 +720,12 @@
 
     public void writeTo(Writer writer) throws IOException {
     }
+
+    public void addExtension(Element extension, Element before) {}
+
+    public <T extends Element> T addExtension(QName qname, QName before) {
+      return null;
+    }
     
   }
   
@@ -1362,6 +1368,12 @@
     }
 
     public void writeTo(Writer writer) throws IOException {
+    }
+
+    public void addExtension(Element extension, Element before) {}
+
+    public <T extends Element> T addExtension(QName qname, QName before) {
+      return null;
     }
     
   }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java?view=diff&rev=564958&r1=564957&r2=564958
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java
Sat Aug 11 11:46:47 2007
@@ -181,4 +181,25 @@
     }
     return t;
   }
+
+  public void addExtension(Element extension, Element before) {
+    if (before == null) {
+      addExtension(extension);
+    } else {
+      extension.setParentElement(this);
+      ((OMElement)before).insertSiblingBefore((OMElement)extension);
+    }
+  }
+
+  public <T extends Element> T addExtension(QName qname, QName before) {
+    OMElement el = getFirstChildWithName(before);
+    T element = getFactory().newElement(qname);
+    if (el == null) {
+      addExtension(element);
+    } else {
+      element.setParentElement(this);
+      el.insertSiblingBefore((OMElement)element);
+    }
+    return element;
+  }
 }



Mime
View raw message