commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bur...@apache.org
Subject svn commit: r151107 - in jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser: DefaultFeedParserListener.java MetaFeedParser.java impl/DebugFeedParserListener.java
Date Thu, 03 Feb 2005 02:50:40 GMT
Author: burton
Date: Wed Feb  2 18:50:39 2005
New Revision: 151107

URL: http://svn.apache.org/viewcvs?view=rev&rev=151107
Log:
support for new onAuthor methods

Modified:
    jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/DefaultFeedParserListener.java
    jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/MetaFeedParser.java
    jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/impl/DebugFeedParserListener.java

Modified: jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/DefaultFeedParserListener.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/DefaultFeedParserListener.java?view=diff&r1=151106&r2=151107
==============================================================================
--- jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/DefaultFeedParserListener.java
(original)
+++ jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/DefaultFeedParserListener.java
Wed Feb  2 18:50:39 2005
@@ -106,6 +106,13 @@
     public void onGenerator( FeedParserState state, String content ) throws FeedParserException
{}
     public void onGeneratorEnd() throws FeedParserException {}
 
+    public void onAuthor( FeedParserState state,
+                          String name,
+                          String email,
+                          String resource ) throws FeedParserException {}
+
+    public void onAuthorEnd() throws FeedParserException {}
+
     // **** ModContentFeedParserListener ****************************************
 
     public void onContentEncoded( FeedParserState state,

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&r1=151106&r2=151107
==============================================================================
--- 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
Wed Feb  2 18:50:39 2005
@@ -32,7 +32,7 @@
  * @author <a href="mailto:burton@apache.org">Kevin A. Burton (burtonator)</a>
  * @version $Id$
  */
-public class MetaFeedParser {
+public class MetaFeedParser extends BaseParser {
 
     /**
      * 
@@ -55,7 +55,60 @@
         //confirm but I think they are working correctly
 
         parseGUID( state, mfp );
-        
+
+        parseAuthor( state, mfp );
+
+    }
+
+    private static void parseAuthor( FeedParserState state,
+                                     MetaFeedParserListener listener )
+        throws FeedParserException {
+
+        Element element = null;
+
+        String name = null;
+        String email = null;
+        String resource = null;
+
+        try {
+            
+            //atom:author
+
+            element = state.current.getChild( "author", NS.ATOM );
+
+            if ( element != null ) {
+                name = selectText( "atom:name", element );
+                email = selectText( "atom:email", element );
+                resource = selectText( "atom:uri", element );
+            }
+
+            //dc:creator (RSS 1.0)
+            element = state.current.getChild( "creator", NS.DC );
+
+            if ( element != null )
+                name = element.getText();
+                
+            //author (RSS 2.0)
+            element = state.current.getChild( "author" );
+
+            if ( element != null )
+                name = element.getText();
+
+            if ( name != null && ! "".equals( name ) ) {
+
+                listener.onAuthor( state,
+                                   name,
+                                   email,
+                                   resource );
+                
+                listener.onAuthorEnd();
+
+            }
+
+        } catch ( Exception e ) {
+            throw new FeedParserException( e );
+        }
+
     }
 
     private static void parseGUID( FeedParserState state,
@@ -67,13 +120,13 @@
         String guid = null;
         boolean isPermalink = false;
         
-        id = state.current.getChild(  "id", NS.ATOM );
+        id = state.current.getChild( "id", NS.ATOM );
 
         if ( id != null ) {
             guid = id.getText();
         }
 
-        id = state.current.getChild(  "guid" );
+        id = state.current.getChild( "guid" );
 
         if ( id != null ) {
 

Modified: jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/impl/DebugFeedParserListener.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/impl/DebugFeedParserListener.java?view=diff&r1=151106&r2=151107
==============================================================================
--- jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/impl/DebugFeedParserListener.java
(original)
+++ jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/impl/DebugFeedParserListener.java
Wed Feb  2 18:50:39 2005
@@ -172,6 +172,17 @@
 
     }
 
+    public void onAuthor( FeedParserState state,
+                          String name,
+                          String email,
+                          String resource ) throws FeedParserException {
+
+        out.println( "onAuthor: name:" + name );
+        out.println( "          email: " + email );
+        out.println( "          resource: " + resource );
+
+    }
+
     // **** LinkFeedParserListener **********************************************
 
     /**



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


Mime
View raw message