org.stringer.rss
Class Feed

java.lang.Object
  |
  +--org.stringer.rss.Feed

public class Feed
extends java.lang.Object

RSS 1.0 is structurally similar to previous versions of RSS -- similar enough that we can simply treat it as XML and write a single function to extract information out of either an RSS 0.91 or RSS 1.0 feed. However, there are some significant differences that our code will need to be aware of:

  1. The root element is rdf:RDF instead of rss. We'll either need to handle both explicitly or just ignore the name of the root element altogether and blindly look for useful information inside it.
  2. RSS 1.0 uses namespaces extensively. The RSS 1.0 namespace is http://purl.org/rss/1.0/, and it's defined as the default namespace. The feed also uses http://www.w3.org/1999/02/22-rdf-syntax-ns# for the RDF-specific elements (which we'll simply be ignoring for our purposes) and http://purl.org/dc/elements/1.1/ (Dublin Core) for the additional metadata of article authors and publishing dates.
  3. Less obvious but still important, the item elements are outside the channel element. (In RSS 0.91, the item elements were inside the channel. In RSS 0.90, they were outside; in RSS 2.0, they're inside. Whee.) So we can't be picky about where we look for items.
  4. Finally, you'll notice there is an extra items element within the channel. It's only useful to RDF parsers, and we're going to ignore it and assume that the order of the items within the RSS feed is given by their order of the item elements.

    Author:
    R. Kevin Cole

    Field Summary
    (package private)  java.lang.Integer AVANTGO
               
    (package private)  nu.xom.Builder builder
               
    protected  java.util.LinkedList channels
               
    protected  nu.xom.Document document
               
    protected  java.io.File file
               
    protected  java.io.FileInputStream fileIn
               
    protected  java.util.Hashtable linkToItemMap
               
    (package private)  IThreadListener listener
               
    (package private) static org.apache.log4j.Logger logger
               
    protected  java.lang.String namespacePrefix
               
    (package private) static java.util.Hashtable namespaces
               
    protected  java.lang.String namespaceUri
               
    (package private)  java.lang.Integer OCS05
               
    (package private)  java.lang.Integer OPML
               
    protected  Channel rootChannel
               
    (package private)  java.lang.Integer RSS090
               
    (package private)  java.lang.Integer RSS091
               
    (package private)  java.lang.Integer RSS092
               
    (package private)  java.lang.Integer RSS093
               
    (package private)  java.lang.Integer RSS094
               
    (package private)  java.lang.Integer RSS10
               
    (package private)  java.lang.Integer RSS20
               
    protected  java.lang.String title
               
    protected  java.lang.String uri
               
    protected  java.lang.Object userObject
               
     
    Constructor Summary
    Feed()
               
    Feed(java.lang.String uri)
               
    Feed(java.lang.String feedUri, IThreadListener listener)
               
    Feed(java.lang.String uri, java.lang.String title)
               
     
    Method Summary
     void execute()
               
     Channel getChannel()
               
     java.util.List getChannels()
               
     nu.xom.Document getDocument()
               
     Item getItemForLink(java.lang.String url)
               
     Channel getRootChannel()
               
     java.lang.String getTitle()
               
     java.lang.String getURI()
               
     java.lang.Object getUserObject()
               
    static void main(java.lang.String[] args)
              A test routine.
    protected  void resolve(nu.xom.Element element, Channel parent)
              Search the element tree for channels.
     java.lang.Thread saveFeed()
               
     void setURI(java.lang.String uri)
               
     void setUserObject(java.lang.Object o)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    RSS090

    java.lang.Integer RSS090

    RSS091

    java.lang.Integer RSS091

    RSS092

    java.lang.Integer RSS092

    RSS093

    java.lang.Integer RSS093

    RSS094

    java.lang.Integer RSS094

    RSS10

    java.lang.Integer RSS10

    RSS20

    java.lang.Integer RSS20

    OCS05

    java.lang.Integer OCS05

    AVANTGO

    java.lang.Integer AVANTGO

    OPML

    java.lang.Integer OPML

    namespaces

    static java.util.Hashtable namespaces

    logger

    static org.apache.log4j.Logger logger

    document

    protected nu.xom.Document document

    userObject

    protected java.lang.Object userObject

    channels

    protected java.util.LinkedList channels

    rootChannel

    protected Channel rootChannel

    uri

    protected java.lang.String uri

    file

    protected java.io.File file

    fileIn

    protected java.io.FileInputStream fileIn

    title

    protected java.lang.String title

    namespaceUri

    protected java.lang.String namespaceUri

    namespacePrefix

    protected java.lang.String namespacePrefix

    linkToItemMap

    protected java.util.Hashtable linkToItemMap

    builder

    nu.xom.Builder builder

    listener

    IThreadListener listener
    Constructor Detail

    Feed

    public Feed()

    Feed

    public Feed(java.lang.String uri,
                java.lang.String title)

    Feed

    public Feed(java.lang.String uri)

    Feed

    public Feed(java.lang.String feedUri,
                IThreadListener listener)
    Method Detail

    getDocument

    public nu.xom.Document getDocument()

    setUserObject

    public void setUserObject(java.lang.Object o)

    getUserObject

    public java.lang.Object getUserObject()

    getChannels

    public java.util.List getChannels()

    getRootChannel

    public Channel getRootChannel()

    getChannel

    public Channel getChannel()

    getURI

    public java.lang.String getURI()

    getTitle

    public java.lang.String getTitle()

    getItemForLink

    public Item getItemForLink(java.lang.String url)

    main

    public static void main(java.lang.String[] args)
                     throws java.lang.Exception
    A test routine.

    java.lang.Exception

    setURI

    public void setURI(java.lang.String uri)

    saveFeed

    public java.lang.Thread saveFeed()
                              throws StringerException
    StringerException

    execute

    public void execute()
                 throws StringerException
    StringerException

    resolve

    protected void resolve(nu.xom.Element element,
                           Channel parent)
    Search the element tree for channels.



    Copyright © R. Kevin Cole. All Rights Reserved.