Author: burton Date: Wed Feb 2 18:23:27 2005 New Revision: 151102 URL: http://svn.apache.org/viewcvs?view=rev&rev=151102 Log: dox for a more advanced feedparser.....
Modified: jakarta/commons/sandbox/feedparser/trunk/build.xml jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/example/HelloFeedParser.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&r1=151101&r2=151102 ============================================================================== --- jakarta/commons/sandbox/feedparser/trunk/build.xml (original) +++ jakarta/commons/sandbox/feedparser/trunk/build.xml Wed Feb 2 18:23:27 2005 @@ -141,10 +141,10 @@ <target name="test" depends="jar,compile.test" description="Run junit tests." if="junit.available"> <junit printsummary="withOutAndErr" - fork="true" - filtertrace="true" - haltonfailure="true" - haltonerror="false"> + fork="true" + filtertrace="true" + haltonfailure="true" + haltonerror="false"> <sysproperty key="feedparser.home" value="${feedparser.home}"/> <classpath> <path refid="project.classpath"/> Modified: jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/example/HelloFeedParser.java URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/example/HelloFeedParser.java?view=diff&r1=151101&r2=151102 ============================================================================== --- jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/example/HelloFeedParser.java (original) +++ jakarta/commons/sandbox/feedparser/trunk/src/java/org/apache/commons/feedparser/example/HelloFeedParser.java Wed Feb 2 18:23:27 2005 @@ -40,6 +40,15 @@ //create a listener for handling our callbacks FeedParserListener listener = new DefaultFeedParserListener() { + public void onChannel( FeedParserState state, + String title, + String link, + String description ) throws FeedParserException { + + System.out.println( "Found a new channel: " + title ); + + } + public void onItem( FeedParserState state, String title, String link, 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&r1=151101&r2=151102 ============================================================================== --- jakarta/commons/sandbox/feedparser/trunk/xdocs/index.xml (original) +++ jakarta/commons/sandbox/feedparser/trunk/xdocs/index.xml Wed Feb 2 18:23:27 2005 @@ -207,10 +207,22 @@ </p> <source> + +//create a new FeedParser... FeedParser parser = FeedParserFactory.newFeedParser(); +//create a listener for handling our callbacks FeedParserListener listener = new DefaultFeedParserListener() { + public void onChannel( FeedParserState state, + String title, + String link, + String description ) throws FeedParserException { + + System.out.println( "Found a new channel: " + title ); + + } + public void onItem( FeedParserState state, String title, String link, @@ -221,9 +233,29 @@ } + public void onCreated( FeedParserState state, Date date ) throws FeedParserException { + System.out.println( "Which was created on: " + date ); + } + }; -parser.parse( listener, new URL( "http://peerfear.org/rss/index.rss" ).openStream() ); +//specify the feed we want to fetch + +String resource = "http://peerfear.org/rss/index.rss"; + +if ( args.length == 1 ) + resource = args[0]; + +System.out.println( "Fetching resource:" + resource ); + +//use the FeedParser network IO package to fetch our resource URL +ResourceRequest request = ResourceRequestFactory.getResourceRequest( resource ); + +//grab our input stream +InputStream is = request.getInputStream(); + +//start parsing our feed and have the above onItem methods called +parser.parse( listener, is, resource ); </source> @@ -367,6 +399,38 @@ </section> --> + + <section name="Visualizing FeedParser Events"> + + <p> + + The FeedParser includes a sample console application which + accepts a URL to a feed, parses it, receives events, and then + outputs them to the console. + + </p> + + <source> +%shell% java org.apache.commons.feedparser.Main http://www.eakes.org/blog/atom.xml +debug: init() +onLocale: en +debug: onChannel + title : Michael Eakes + link : 'http://www.eakes.org/blog/' + description : The Weblog of Michael Eakes +debug: onChannelEnd +debug: onItem + title : Flickr and Good URI Design + link : 'http://www.eakes.org/blog/archives/2005/01/flickr_uris.html' + description : I noticed that Flickr had some pretty sweet URIs, but I wanted to find out exactly what it was that made them good. To brush up on URI design, I scoured this great list of resources compiled by Tanya Rabourn:... +onLink: + rel: alternate + href: http://www.eakes.org/blog/archives/2005/01/flickr_uris.html + type: text/html + + </source> + + </section> <section name="Alternative RSS/Atom and Feed Parsers"> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]