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/locate FeedLocator.java
Date Mon, 04 Oct 2004 00:59:47 GMT
burton      2004/10/03 17:59:47

  Modified:    feedparser/src/java/org/apache/commons/feedparser
                        AtomFeedParser.java
               feedparser/src/java/org/apache/commons/feedparser/impl
                        DebugFeedParserListener.java
               feedparser/src/java/org/apache/commons/feedparser/locate
                        FeedLocator.java
  Log:
  Now supports the atom:link mechanism with ALL links being called back
  
  Revision  Changes    Path
  1.13      +37 -1     jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/AtomFeedParser.java
  
  Index: AtomFeedParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/AtomFeedParser.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AtomFeedParser.java	31 Aug 2004 21:00:32 -0000	1.12
  +++ AtomFeedParser.java	4 Oct 2004 00:59:47 -0000	1.13
  @@ -159,6 +159,8 @@
               
               listener.onItem( state, title, link, description, link );
   
  +            doLink( state, listener, child );
  +            
               doMeta( state, listener, child );
   
               doContent( state, listener, child );
  @@ -171,6 +173,40 @@
   
       }
   
  +    private static void doLink( FeedParserState state,
  +                                FeedParserListener listener,
  +                                Element current ) throws Exception {
  +
  +        if ( listener instanceof LinkFeedParserListener == false )
  +            return;
  +
  +        LinkFeedParserListener lfpl = (LinkFeedParserListener)listener;
  +        
  +        XPath xpath = new XPath( "atom:link" );
  +        xpath.setNamespaceContext( NS.context );
  +
  +        List items = xpath.selectNodes( current );
  +
  +        Iterator it = items.iterator();
  +            
  +        //update items.
  +        while ( it.hasNext() ) {
  +
  +            Element link = (Element)it.next();
  +            
  +            String href = link.getAttributeValue( "href" );
  +            String rel = link.getAttributeValue( "rel" );
  +            String type = link.getAttributeValue( "type" );
  +
  +            String title = null;
  +            long length = -1;
  +
  +            lfpl.onLink( state, rel, type, href, title, length );
  +            
  +        }
  +        
  +    }
  +    
       private static void doContent( FeedParserState state,
                                      FeedParserListener listener,
                                      Element current ) throws Exception {
  
  
  
  1.9       +24 -2     jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/impl/DebugFeedParserListener.java
  
  Index: DebugFeedParserListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/impl/DebugFeedParserListener.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DebugFeedParserListener.java	31 Aug 2004 21:00:32 -0000	1.8
  +++ DebugFeedParserListener.java	4 Oct 2004 00:59:47 -0000	1.9
  @@ -32,7 +32,8 @@
       extends DefaultFeedParserListener
       implements FeedParserListener,
                  FeedDirectoryParserListener,
  -               MetaFeedParserListener {
  +               MetaFeedParserListener,
  +               LinkFeedParserListener {
   
       PrintStream out = System.out;
   
  @@ -159,6 +160,27 @@
       public void onCreated( FeedParserState state, Date date ) throws FeedParserException
{
   
           out.println( "onCreated: " + date.toString() );
  +        
  +    }
  +
  +    // **** LinkFeedParserListener **********************************************
  +
  +    /**
  +     *
  +     * 
  +     * @param length The length of the content or -1 if not specified.
  +     */
  +    public void onLink( FeedParserState state,
  +                        String rel,
  +                        String type,
  +                        String href,
  +                        String title,
  +                        long length ) throws FeedParserException {
  +
  +        out.println( "onLink: " );
  +        out.println( "\trel: " + rel );
  +        out.println( "\thref: " + href );
  +        out.println( "\ttype: " + type );
           
       }
   
  
  
  
  1.23      +6 -1      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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- FeedLocator.java	30 Sep 2004 19:27:38 -0000	1.22
  +++ FeedLocator.java	4 Oct 2004 00:59:47 -0000	1.23
  @@ -104,7 +104,12 @@
           //String resource = "file:///projects/feedparser/tests/locate5.html";
           //String resource = "file:///projects/feedparser/tests/locate6.html";
   
  -        String resource = "http://flickr.com/photos/tags/cat/";
  +        
  +        //FIXME: add UNIT TESTS for Yahoo Groups and Flickr
  +        String resource = "http://groups.yahoo.com/group/aggregators/";
  +
  +        //String resource = "http://flickr.com/photos/tags/cats";
  +
           
           //String resource = "file:///projects/feedparser/tests/locate8.html";
   
  
  
  

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