You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2005/01/30 03:23:32 UTC

svn commit: r149095 - in jakarta/commons/sandbox/feedparser/trunk: . src/java/org/apache/commons/feedparser xdocs

Author: burton
Date: Sat Jan 29 18:23:30 2005
New Revision: 149095

URL: http://svn.apache.org/viewcvs?view=rev&rev=149095
Log:
RSS 2.0 and Atom GUID refactor and init of support
Modified:
   jakarta/commons/sandbox/feedparser/trunk/build.xml
   jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/AtomFeedParser.java
   jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/MetaFeedParser.java
   jakarta/commons/sandbox/feedparser/trunk/xdocs/index.xml

Modified: jakarta/commons/sandbox/feedparser/trunk/build.xml
Url: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/feedparser/trunk/build.xml?view=diff&rev=149095&p1=jakarta/commons/sandbox/feedparser/trunk/build.xml&r1=149094&p2=jakarta/commons/sandbox/feedparser/trunk/build.xml&r2=149095
==============================================================================
--- jakarta/commons/sandbox/feedparser/trunk/build.xml	(original)
+++ jakarta/commons/sandbox/feedparser/trunk/build.xml	Sat Jan 29 18:23:30 2005
@@ -11,13 +11,20 @@
     <property environment="env"/>
     <property file="build.properties"/>
     <property name="project" value="feedparser"/>
+    <property name="product" value="FeedParser"/>
+
     <property name="version.major" value="0"/>
     <property name="version.minor" value="5"/>
     <property name="version.sub" value="0"/>
     <property name="version.desc" value="beta"/>
+
+    <property name="version" value="${version.major}.${version.minor}.${version.sub}"/>
+
     <property name="docs.dest" value="./site"/>
     <property name="docs.src" value="./xdocs"/>
 
+    <property name="year" value="2005"/>
+
     <path id="anakia.classpath">
         <fileset dir="${jakarta.site2.home}/lib">
             <include name="*.jar"/>
@@ -165,8 +172,8 @@
                  version="true"
                  use="true"
                  link="${javadoc.link}"
-                 windowtitle="${Name} ${version} API"
-                 doctitle="${Name} ${version} API"
+                 windowtitle="${product} ${version} API"
+                 doctitle="${product} ${version} API"
                  bottom="Copyright &amp;copy; ${year} Apache Software Foundation.  All Rights Reserved.">
 
         </javadoc>

Modified: jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/AtomFeedParser.java
Url: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/AtomFeedParser.java?view=diff&rev=149095&p1=jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/AtomFeedParser.java&r1=149094&p2=jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/AtomFeedParser.java&r2=149095
==============================================================================
--- jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/AtomFeedParser.java	(original)
+++ jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/AtomFeedParser.java	Sat Jan 29 18:23:30 2005
@@ -336,6 +336,8 @@
                                 FeedParserListener listener,
                                 Element element ) throws Exception {
 
+        //FIXME: move this code to MetaFeedParser...
+        
         if ( ! (listener instanceof MetaFeedParserListener) ) 
             return;
 
@@ -348,18 +350,6 @@
             mlistener.onSubject( state, subject );
             mlistener.onSubjectEnd();
         } 
-
-        Element id = element.getChild(  "id", NS.ATOM );
-        
-        if ( id != null ) {
-
-            mlistener.onGUID( state,
-                              id.getText(),
-                              false );
-
-            mlistener.onGUIDEnd();
-
-        }
 
     }
 

Modified: jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/MetaFeedParser.java
Url: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/MetaFeedParser.java?view=diff&rev=149095&p1=jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/MetaFeedParser.java&r1=149094&p2=jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/MetaFeedParser.java&r2=149095
==============================================================================
--- jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/MetaFeedParser.java	(original)
+++ jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/MetaFeedParser.java	Sat Jan 29 18:23:30 2005
@@ -30,7 +30,7 @@
  * Handles parsing RSS metadata including dates
  *
  * @author <a href="mailto:burton@apache.org">Kevin A. Burton (burtonator)</a>
- * @version $Id: MetaFeedParser.java,v 1.3 2005/01/23 09:49:50 burton Exp $
+ * @version $Id$
  */
 public class MetaFeedParser {
 
@@ -44,47 +44,90 @@
         //MetaFeedParser to be used by both Atom and RSS.  Also the date
         //handling below needs to be generic.
         
-        if ( listener instanceof MetaFeedParserListener ) {
+        if ( listener instanceof MetaFeedParserListener == false )
+            return;
 
-            MetaFeedParserListener mfp = (MetaFeedParserListener)listener;
+        MetaFeedParserListener mfp = (MetaFeedParserListener)listener;
 
-            if ( parseDate( "date", NS.DC, mfp, state ) )
-                return;
+        parseDate( state, mfp );
+        
+        //FIXME: make sure RSS .9 is working and 0.91.  I just need to
+        //confirm but I think they are working correctly
 
-            // http://www.mnot.net/drafts/draft-nottingham-atom-format-02.html#rfc.section.4.13.8
-            // 
-            // The "atom:created" element is a Date construct that indicates the
-            // time that the entry was created. atom:entry elements MAY contain
-            // an atom:created element, but MUST NOT contain more than one.
+        parseGUID( state, mfp );
+        
+    }
 
-            // The content of an atom:created element MUST have a time zone
-            // whose value SHOULD be "UTC".
-            
-            if ( parseDate( "created", NS.ATOM, mfp, state ) )
-                return;
+    private static void parseGUID( FeedParserState state,
+                                   MetaFeedParserListener listener )
+        throws FeedParserException {
 
-            // http://www.mnot.net/drafts/draft-nottingham-atom-format-02.html#rfc.section.4.13.8
-            //            
-            // If atom:created is not present, its content MUST considered to be
-            // the same as that of atom:modified.
+        Element id = null;
 
-            if ( parseDate( "modified", NS.ATOM, mfp, state ) )
-                return;
+        String guid = null;
+        boolean isPermalink = false;
+        
+        id = state.current.getChild(  "id", NS.ATOM );
 
-            //support RSS 2.0 and RSS 0.9x dates.
+        if ( id != null ) {
+            guid = id.getText();
+        }
 
-            if ( parseDate( "pubDate", null, mfp, state, false ) )
-                return;
+        id = state.current.getChild(  "guid" );
 
-            //FIXME: make sure RSS .9 is working and 0.91.  I just need to
-            //confirm but I think they are working correctly
+        if ( id != null ) {
 
-            
+            guid = id.getText();
+            isPermalink = "true".equals( id.getAttributeValue( "isPermalink" ) );
             
         }
 
+        if ( guid != null ) {
+
+            listener.onGUID( state,
+                             guid,
+                             isPermalink );
+            
+            listener.onGUIDEnd();
+
+        }
+        
     }
 
+    private static void parseDate( FeedParserState state,
+                                   MetaFeedParserListener listener )
+        throws FeedParserException {
+
+        if ( parseDate( "date", NS.DC, listener, state ) )
+            return;
+
+        // http://www.mnot.net/drafts/draft-nottingham-atom-format-02.html#rfc.section.4.13.8
+        // 
+        // The "atom:created" element is a Date construct that indicates the
+        // time that the entry was created. atom:entry elements MAY contain
+        // an atom:created element, but MUST NOT contain more than one.
+
+        // The content of an atom:created element MUST have a time zone
+        // whose value SHOULD be "UTC".
+        
+        if ( parseDate( "created", NS.ATOM, listener, state ) )
+            return;
+
+        // http://www.mnot.net/drafts/draft-nottingham-atom-format-02.html#rfc.section.4.13.8
+        //            
+        // If atom:created is not present, its content MUST considered to be
+        // the same as that of atom:modified.
+
+        if ( parseDate( "modified", NS.ATOM, listener, state ) )
+            return;
+
+        //support RSS 2.0 and RSS 0.9x dates.
+
+        if ( parseDate( "pubDate", null, listener, state, false ) )
+            return;
+
+    }
+    
     private static boolean parseDate( String name,
                                       Namespace ns,
                                       MetaFeedParserListener listener,

Modified: jakarta/commons/sandbox/feedparser/trunk/xdocs/index.xml
Url: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/feedparser/trunk/xdocs/index.xml?view=diff&rev=149095&p1=jakarta/commons/sandbox/feedparser/trunk/xdocs/index.xml&r1=149094&p2=jakarta/commons/sandbox/feedparser/trunk/xdocs/index.xml&r2=149095
==============================================================================
--- jakarta/commons/sandbox/feedparser/trunk/xdocs/index.xml	(original)
+++ jakarta/commons/sandbox/feedparser/trunk/xdocs/index.xml	Sat Jan 29 18:23:30 2005
@@ -222,11 +222,11 @@
             </p>
 
             <p>
-                We try to follow Postel's law here and require allow feeds to
-                pass in this situation.  We may adopt a policy in the future for
-                both strict XML parsing and strict format compliance which would
+                We try to follow Postel's law here and allow feeds to pass in
+                this situation.  We may adopt a policy in the future for both
+                strict XML parsing and strict format compliance which would
                 trigger exception in the event of a feed not exactly matching
-                the specification.  
+                the specification.
             </p>
 
             <p>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org