commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bur...@apache.org
Subject cvs commit: jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/sax RSSFeedParser.java
Date Fri, 23 Apr 2004 17:45:43 GMT
burton      2004/04/23 10:45:43

  Modified:    feedparser/src/java/org/apache/commons/feedparser/locate
                        DiscoveryLocator.java FeedLocator.java
               feedparser/src/java/org/apache/commons/feedparser/sax
                        RSSFeedParser.java
  Added:       feedparser/src/java/org/apache/commons/feedparser
                        FeedList.java
  Log:
  support for better feed list introspection
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/FeedList.java
  
  Index: FeedList.java
  ===================================================================
  /*
   * Copyright 1999,2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package org.apache.commons.feedparser;
  
  import org.apache.commons.feedparser.locate.*;
  
  import org.jdom.*;
  import java.util.*;
  
  /**
   * Contains a list of all feeds found the the AutoDiscovery system.  Can also be
   * used when needing to refer to a list of feeds and provides util methods for
   * dealing with them
   * 
   * @author <a href="mailto:burton@apache.org">Kevin A. Burton (burtonator)</a>
   * @version $Id: FeedList.java,v 1.1 2004/04/23 17:45:43 burton Exp $
   */
  public class FeedList extends LinkedList implements List {
      
      private FeedReference adAtomFeed = null;
      
      private FeedReference adRSSFeed = null;
  
      /**
       * 
       * Get the RSS feed discovered via autodiscovery.
       *
       * @author <a href="mailto:burton@peerfear.org">Kevin Burton</a>
       */
      public FeedReference getAdRSSFeed() { 
          
          return this.adRSSFeed;
          
      }
  
      /**
       * 
       * Set the value of <code>adRSSFeed</code>.
       *
       * @author <a href="mailto:burton@peerfear.org">Kevin Burton</a>
       */
      public void setAdRSSFeed( FeedReference adRSSFeed ) { 
          
          this.adRSSFeed = adRSSFeed;
          
      }
  
      /**
       * 
       * Get the Atom feed discovered via autodiscovery.
       *
       * @author <a href="mailto:burton@peerfear.org">Kevin Burton</a>
       */
      public FeedReference getAdAtomFeed() { 
          
          return this.adAtomFeed;
          
      }
  
      /**
       * 
       * Set the value of <code>adAtomFeed</code>.
       *
       * @author <a href="mailto:burton@peerfear.org">Kevin Burton</a>
       */
      public void setAdAtomFeed( FeedReference adAtomFeed ) { 
          
          this.adAtomFeed = adAtomFeed;
          
      }
  
  }
  
  
  
  
  1.7       +13 -2     jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/DiscoveryLocator.java
  
  Index: DiscoveryLocator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/DiscoveryLocator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DiscoveryLocator.java	16 Apr 2004 20:20:00 -0000	1.6
  +++ DiscoveryLocator.java	23 Apr 2004 17:45:43 -0000	1.7
  @@ -16,6 +16,8 @@
   
   package org.apache.commons.feedparser.locate;
   
  +import org.apache.commons.feedparser.*;
  +
   import java.io.*;
   import java.util.*;
   import java.util.regex.*;
  @@ -51,7 +53,7 @@
        *
        * @author <a href="mailto:burton@peerfear.org">Kevin A. Burton</a>
        */
  -    public static final List locate( String resource, String content, List list )
  +    public static final List locate( String resource, String content, FeedList list )
           throws Exception {
   
           //this mechanism is easier but it isn't efficient.  I should just parse
  @@ -70,7 +72,16 @@
                   String href = m.group( 2 );
                   href = ResourceExpander.expand( resource, href );
   
  -                list.add( new FeedReference( href, type ) );
  +                FeedReference feedReference = new FeedReference( href, type );
  +                
  +                list.add( feedReference );
  +
  +                if ( type.equals( ATOM_MEDIA_TYPE ) )
  +                    list.setAdAtomFeed( feedReference );
  +
  +                if ( type.equals( RSS_MEDIA_TYPE ) )
  +                    list.setAdRSSFeed( feedReference );
  +
                   return list;
               }
               
  
  
  
  1.5       +7 -4      jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/FeedLocator.java
  
  Index: FeedLocator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/FeedLocator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FeedLocator.java	15 Apr 2004 04:57:18 -0000	1.4
  +++ FeedLocator.java	23 Apr 2004 17:45:43 -0000	1.5
  @@ -16,13 +16,16 @@
   
   package org.apache.commons.feedparser.locate;
   
  +import org.apache.commons.feedparser.*;
  +
   import org.peerfear.newsmonster.network.*;
   
   import java.io.*;
   import java.util.*;
   
   /**
  - *
  + * Method to determine feed URLs from a given. 
  + * 
    * @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
    */
   public class FeedLocator {
  @@ -36,7 +39,7 @@
        * @param resource The weblog we need to discover
        * @author <a href="mailto:burton@peerfear.org">Kevin A. Burton</a>
        */
  -    public static final List locate( String resource ) throws Exception {
  +    public static final FeedList locate( String resource ) throws Exception {
   
           //Use my network library when it's migrated into Apache.
           
  @@ -55,9 +58,9 @@
        *
        * @author <a href="mailto:burton@peerfear.org">Kevin Burton</a>
        */
  -    public static final List locate( String resource, String content ) throws Exception
{
  +    public static final FeedList locate( String resource, String content ) throws Exception
{
   
  -        LinkedList list = new LinkedList();
  +        FeedList list = new FeedList();
   
           DiscoveryLocator.locate( resource, content, list );
   
  
  
  
  1.2       +2 -2      jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/sax/RSSFeedParser.java
  
  Index: RSSFeedParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/sax/RSSFeedParser.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RSSFeedParser.java	23 Apr 2004 06:11:57 -0000	1.1
  +++ RSSFeedParser.java	23 Apr 2004 17:45:43 -0000	1.2
  @@ -181,7 +181,7 @@
           }
   
           public void endFeedElement() throws FeedParserException {
  -            System.out.println( " FIXME: (debug): " + getProperty( "value" ) );
  +            //System.out.println( " FIXME: (debug): " + getProperty( "value" ) );
           }
   
       }
  
  
  

---------------------------------------------------------------------
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