de.nava.informa.parsers
Class FeedParser

java.lang.Object
  extended by de.nava.informa.parsers.FeedParser

public class FeedParser
extends Object

Parser class which allows reading in of RSS news channels. The concrete rules how the XML elements map to our channel object model are delegated to version specific private classes.

Currently the FeedParser support RSS formats 0.9x, 1.0 (RDF), 2.0 and Atom 0.3.

It's possible to specify class of custom XML parser to use instead of standard Crimson parser (JDK). Use setSaxDriverClassName() method for that.

Author:
Niko Schmuck

Constructor Summary
FeedParser()
           
 
Method Summary
static void main(String[] args)
           
static ChannelIF parse(ChannelBuilderIF cBuilder, File aFile)
          Parse feed presented by file and build channel.
static ChannelIF parse(ChannelBuilderIF cBuilder, InputSource inpSource, URL baseLocation)
          Parse feed from input source with base location set and create channel.
static ChannelIF parse(ChannelBuilderIF cBuilder, InputStream stream)
          Parse feed presented by InputStream and build channel.
static ChannelIF parse(ChannelBuilderIF cBuilder, Reader reader)
          Parse feed presented by Reader and build channel.
static ChannelIF parse(ChannelBuilderIF cBuilder, String url)
          Parser feed behind the given URL and build channel.
static ChannelIF parse(ChannelBuilderIF cBuilder, URL aURL)
          Parser feed behind the given URL and build channel.
static void setSaxDriverClassName(String className)
          Sets the name of SAX2 Driver class to use for parsing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FeedParser

public FeedParser()
Method Detail

setSaxDriverClassName

public static void setSaxDriverClassName(String className)
                                  throws ClassNotFoundException
Sets the name of SAX2 Driver class to use for parsing. The class should implement XMLReader interface and should exist in current class-loading paths. The method will check these conditions before accepting specified class name.

Parameters:
className - name of SAX2 Driver class.
Throws:
ClassNotFoundException - if class isn't found in the class path.
ClassCastException - if class isn't implementing XMLReader interface.

parse

public static ChannelIF parse(ChannelBuilderIF cBuilder,
                              String url)
                       throws IOException,
                              ParseException
Parser feed behind the given URL and build channel.

Parameters:
cBuilder - specific channel builder to use.
url - URL to use as data source.
Returns:
parsed channel.
Throws:
IOException - if IO errors occur.
ParseException - if parsing is not possible.

parse

public static ChannelIF parse(ChannelBuilderIF cBuilder,
                              URL aURL)
                       throws IOException,
                              ParseException
Parser feed behind the given URL and build channel.

Parameters:
cBuilder - specific channel builder to use.
aURL - URL to use as data source.
Returns:
parsed channel.
Throws:
IOException - if IO errors occur.
ParseException - if parsing is not possible.

parse

public static ChannelIF parse(ChannelBuilderIF cBuilder,
                              Reader reader)
                       throws IOException,
                              ParseException
Parse feed presented by Reader and build channel.

Parameters:
cBuilder - specific channel builder to use.
reader - reader setup to read feed data.
Returns:
parsed channel.
Throws:
IOException - if IO errors occur.
ParseException - if parsing is not possible.

parse

public static ChannelIF parse(ChannelBuilderIF cBuilder,
                              InputStream stream)
                       throws IOException,
                              ParseException
Parse feed presented by InputStream and build channel.

Parameters:
cBuilder - specific channel builder to use.
stream - stream setup to read feed data.
Returns:
parsed channel.
Throws:
IOException - if IO errors occur.
ParseException - if parsing is not possible.

parse

public static ChannelIF parse(ChannelBuilderIF cBuilder,
                              File aFile)
                       throws IOException,
                              ParseException
Parse feed presented by file and build channel.

Parameters:
cBuilder - specific channel builder to use.
aFile - file to read data from.
Returns:
parsed channel.
Throws:
IOException - if IO errors occur.
ParseException - if parsing is not possible.

parse

public static ChannelIF parse(ChannelBuilderIF cBuilder,
                              InputSource inpSource,
                              URL baseLocation)
                       throws IOException,
                              ParseException
Parse feed from input source with base location set and create channel.

Parameters:
cBuilder - specific channel builder to use.
inpSource - input source of data.
baseLocation - base location of feed.
Returns:
parsed channel.
Throws:
IOException - if IO errors occur.
ParseException - if parsing is not possible.

main

public static void main(String[] args)
                 throws IOException,
                        ParseException
Throws:
IOException
ParseException


Copyright © 2002-2007 Niko Schmuck. All Rights Reserved.