abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r556677 - in /incubator/abdera/java/trunk: contrib/rss/src/main/java/org/apache/abdera/contrib/rss/ core/src/main/java/org/apache/abdera/model/ parser/src/main/java/org/apache/abdera/parser/stax/
Date Mon, 16 Jul 2007 17:41:02 GMT
Author: jmsnell
Date: Mon Jul 16 10:41:01 2007
New Revision: 556677

URL: http://svn.apache.org/viewvc?view=rev&rev=556677
Log:
Add a utility method for converting a Source into an empty Feed

Modified:
    incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssFeed.java
    incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssSource.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Source.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMSource.java

Modified: incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssFeed.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssFeed.java?view=diff&rev=556677&r1=556676&r2=556677
==============================================================================
--- incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssFeed.java
(original)
+++ incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssFeed.java
Mon Jul 16 10:41:01 2007
@@ -537,4 +537,8 @@
   public String getVersion() {
     return super.getAttributeValue("version");
   }
+
+  public Feed getAsFeed() {
+    throw new UnsupportedOperationException("Converting to feed is not supported");
+  }
 }

Modified: incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssSource.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssSource.java?view=diff&rev=556677&r1=556676&r2=556677
==============================================================================
--- incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssSource.java
(original)
+++ incubator/abdera/java/trunk/contrib/rss/src/main/java/org/apache/abdera/contrib/rss/RssSource.java
Mon Jul 16 10:41:01 2007
@@ -31,6 +31,7 @@
 import org.apache.abdera.model.Div;
 import org.apache.abdera.model.Element;
 import org.apache.abdera.model.ExtensibleElementWrapper;
+import org.apache.abdera.model.Feed;
 import org.apache.abdera.model.Generator;
 import org.apache.abdera.model.IRIElement;
 import org.apache.abdera.model.Link;
@@ -383,6 +384,10 @@
 
   public Link getAlternateLink() {
     return self;
+  }
+
+  public Feed getAsFeed() {
+    throw new UnsupportedOperationException("Converting to feed is not supported");
   }
 
 }

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Source.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Source.java?view=diff&rev=556677&r1=556676&r2=556677
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Source.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Source.java Mon
Jul 16 10:41:01 2007
@@ -684,4 +684,8 @@
    */
   void setCollection(Collection collection);
   
+  /**
+   * Convert the Source element into an empty Feed element
+   */
+  Feed getAsFeed();
 }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMSource.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMSource.java?view=diff&rev=556677&r1=556676&r2=556677
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMSource.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMSource.java
Mon Jul 16 10:41:01 2007
@@ -18,6 +18,7 @@
 package org.apache.abdera.parser.stax;
 
 import java.util.Date;
+import java.util.Iterator;
 import java.util.List;
 
 import javax.activation.MimeTypeParseException;
@@ -30,6 +31,7 @@
 import org.apache.abdera.model.DateTime;
 import org.apache.abdera.model.Div;
 import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Feed;
 import org.apache.abdera.model.Generator;
 import org.apache.abdera.model.IRIElement;
 import org.apache.abdera.model.Link;
@@ -45,6 +47,7 @@
 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.OMXMLParserWrapper;
 
 public class FOMSource
@@ -600,6 +603,22 @@
       throws MimeTypeParseException {
     Link link = getAlternateLink(type, hreflang);
     return (link != null) ? link.getResolvedHref() : null;
+  }
+
+  public Feed getAsFeed() {
+    FOMFeed feed = (FOMFeed) ((FOMFactory)factory).newFeed();
+    for (Iterator i = this.getChildElements(); i.hasNext();) {
+      FOMElement child = (FOMElement)i.next();
+      if (!child.getQName().equals(ENTRY)) {
+        feed.addChild((OMNode)child.clone());
+      }
+    }
+    try {
+      if (this.getBaseUri() != null) {
+        feed.setBaseUri(this.getBaseUri());
+      }
+    } catch (Exception e) {}
+    return feed;
   }
 
 }



Mime
View raw message