org.apache.commons.feedparser
Class DefaultFeedParserListener

java.lang.Object
  extended by org.apache.commons.feedparser.DefaultFeedParserListener
All Implemented Interfaces:
ContentFeedParserListener, FeedLifecycleListener, FeedParserListener, MetaFeedParserListener, ModContentFeedParserListener, XHTMLFeedParserListener
Direct Known Subclasses:
DebugFeedParserListener, DefaultFeedDirectoryParserListener, RSS10_OutputFeedParserListener, Test

public abstract class DefaultFeedParserListener
extends Object
implements FeedParserListener, MetaFeedParserListener, ModContentFeedParserListener, XHTMLFeedParserListener, ContentFeedParserListener

Default implemmentation of a FeedParserListener with noop methods. This can be used as a base class for new implementations which do not need most of the functionality of a FeedParserListener. Its recommended (but not required) that implementors extend this interface to that when new methods are added to the FeedParserListener that upgrades to this library do not break your application.

Version:
$Id: DefaultFeedParserListener.java 373614 2006-01-30 22:31:21Z mvdb $
Author:
Kevin A. Burton (burtonator)
See Also:
FeedParserListener

Constructor Summary
DefaultFeedParserListener()
           
 
Method Summary
 void finished()
          Called when the feed has finished parsing.
 Object getContext()
           
 void init()
          Called prior to event parsing to signal the parsing of a new feed.
 void onAuthor(FeedParserState state, String name, String email, String resource)
          Provided for author information across RSS 2.0, atom, dc:creator in RSS 1.0.
 void onAuthorEnd()
           
 void onChannel(FeedParserState state, String title, String link, String description)
          Called when a channel item is found.
 void onChannelEnd()
           
 void onComments(FeedParserState state, String resource)
           
 void onCommentsEnd()
           
 void onCommentsFeed(FeedParserState state, String resource)
           
 void onCommentsFeedEnd()
           
 void onContent(FeedParserState state, String type, String format, String encoding, String mode, String value, boolean isSummary)
          Called when new content is found.
 void onContentEncoded(FeedParserState state, String value)
           
 void onContentEncodedEnd()
           
 void onContentEnd()
           
 void onContentItem(FeedParserState state, String format, String encoding, org.jdom.Element value)
           
 void onContentItemEnd()
           
 void onCopyright(FeedParserState state, String content)
           
 void onCopyrightEnd()
           
 void onCreated(FeedParserState state, Date date)
          http://www.mnot.net/drafts/draft-nottingham-atom-format-00.html#rfc.section.3.2.8
 void onCreatedEnd()
           
 void onFeedVersion(FeedVersion version)
          Called when we are first able to determine the feed version for this feed.
 void onGenerator(FeedParserState state, String content)
          Called when a generator contruct is found within Atom or RSS 2.0
 void onGeneratorEnd()
           
 void onGUID(FeedParserState state, String value, boolean isPermalink)
          Used to represent RSS 2.0 GUIDs and atom:id constructs.
 void onGUIDEnd()
           
 void onImage(FeedParserState state, String title, String link, String url)
          Called when an RSS image is found.
 void onImageEnd()
           
 void onIssued(FeedParserState state, String content)
          http://www.mnot.net/drafts/draft-nottingham-atom-format-00.html#rfc.section.3.2.7
 void onIssuedEnd()
           
 void onItem(FeedParserState state, String title, String link, String description, String permalink)
          Called when an RSS item or Atom entry is found.
 void onItemEnd()
           
 void onLocale(FeedParserState state, Locale locale)
          Called when we've found an xml:lang or a dc:lang on Atom and RSS feeds.
 void onLocaleEnd()
           
 void onSubject(FeedParserState state, String content)
          RSS 2.0 category.
 void onSubjectEnd()
           
 void onXHTMLBody(FeedParserState state, org.jdom.Element value)
           
 void onXHTMLBodyEnd()
           
 void setContext(Object context)
          Set this context that this FeedParserListener is executing within.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFeedParserListener

public DefaultFeedParserListener()
Method Detail

onFeedVersion

public void onFeedVersion(FeedVersion version)
                   throws FeedParserException
Description copied from interface: FeedParserListener
Called when we are first able to determine the feed version for this feed. Ideally implementations should call this BEFORE onChannel but depending on the parser infrastructure this might not be possible. Should be called before init()

Specified by:
onFeedVersion in interface FeedParserListener
Throws:
FeedParserException

init

public void init()
          throws FeedParserException
Description copied from interface: FeedLifecycleListener
Called prior to event parsing to signal the parsing of a new feed.

Specified by:
init in interface FeedLifecycleListener
Throws:
FeedParserException

setContext

public void setContext(Object context)
                throws FeedParserException
Description copied from interface: FeedLifecycleListener
Set this context that this FeedParserListener is executing within. This can be used with anonymous listeners to pass contextual information about threads they are working within, etc.

Specified by:
setContext in interface FeedLifecycleListener
Throws:
FeedParserException

getContext

public Object getContext()
                  throws FeedParserException
Specified by:
getContext in interface FeedLifecycleListener
Throws:
FeedParserException

onChannel

public void onChannel(FeedParserState state,
                      String title,
                      String link,
                      String description)
               throws FeedParserException
Description copied from interface: FeedParserListener
Called when a channel item is found.

Specified by:
onChannel in interface FeedParserListener
Throws:
FeedParserException

onChannelEnd

public void onChannelEnd()
                  throws FeedParserException
Specified by:
onChannelEnd in interface FeedParserListener
Throws:
FeedParserException

onImage

public void onImage(FeedParserState state,
                    String title,
                    String link,
                    String url)
             throws FeedParserException
Description copied from interface: FeedParserListener
Called when an RSS image is found.

Specified by:
onImage in interface FeedParserListener
Throws:
FeedParserException

onImageEnd

public void onImageEnd()
                throws FeedParserException
Specified by:
onImageEnd in interface FeedParserListener
Throws:
FeedParserException

onItem

public void onItem(FeedParserState state,
                   String title,
                   String link,
                   String description,
                   String permalink)
            throws FeedParserException
Description copied from interface: FeedParserListener
Called when an RSS item or Atom entry is found.

Specified by:
onItem in interface FeedParserListener
Throws:
FeedParserException

onItemEnd

public void onItemEnd()
               throws FeedParserException
Specified by:
onItemEnd in interface FeedParserListener
Throws:
FeedParserException

finished

public void finished()
              throws FeedParserException
Description copied from interface: FeedLifecycleListener
Called when the feed has finished parsing.

Specified by:
finished in interface FeedLifecycleListener
Throws:
FeedParserException

onCopyright

public void onCopyright(FeedParserState state,
                        String content)
                 throws FeedParserException
Specified by:
onCopyright in interface MetaFeedParserListener
Throws:
FeedParserException

onCopyrightEnd

public void onCopyrightEnd()
                    throws FeedParserException
Specified by:
onCopyrightEnd in interface MetaFeedParserListener
Throws:
FeedParserException

onCreated

public void onCreated(FeedParserState state,
                      Date date)
               throws FeedParserException
http://www.mnot.net/drafts/draft-nottingham-atom-format-00.html#rfc.section.3.2.8

Specified by:
onCreated in interface MetaFeedParserListener
Throws:
FeedParserException

onCreatedEnd

public void onCreatedEnd()
                  throws FeedParserException
Specified by:
onCreatedEnd in interface MetaFeedParserListener
Throws:
FeedParserException

onSubject

public void onSubject(FeedParserState state,
                      String content)
               throws FeedParserException
Description copied from interface: MetaFeedParserListener
RSS 2.0 category. Dublin Core.

Specified by:
onSubject in interface MetaFeedParserListener
Throws:
FeedParserException

onSubjectEnd

public void onSubjectEnd()
                  throws FeedParserException
Specified by:
onSubjectEnd in interface MetaFeedParserListener
Throws:
FeedParserException

onIssued

public void onIssued(FeedParserState state,
                     String content)
              throws FeedParserException
http://www.mnot.net/drafts/draft-nottingham-atom-format-00.html#rfc.section.3.2.7

Specified by:
onIssued in interface MetaFeedParserListener
Throws:
FeedParserException

onIssuedEnd

public void onIssuedEnd()
                 throws FeedParserException
Specified by:
onIssuedEnd in interface MetaFeedParserListener
Throws:
FeedParserException

onLocale

public void onLocale(FeedParserState state,
                     Locale locale)
              throws FeedParserException
Description copied from interface: MetaFeedParserListener
Called when we've found an xml:lang or a dc:lang on Atom and RSS feeds.

Specified by:
onLocale in interface MetaFeedParserListener
Throws:
FeedParserException

onLocaleEnd

public void onLocaleEnd()
                 throws FeedParserException
Specified by:
onLocaleEnd in interface MetaFeedParserListener
Throws:
FeedParserException

onGUID

public void onGUID(FeedParserState state,
                   String value,
                   boolean isPermalink)
            throws FeedParserException
Description copied from interface: MetaFeedParserListener
Used to represent RSS 2.0 GUIDs and atom:id constructs. For Atom isPermalink should be ignored.

Specified by:
onGUID in interface MetaFeedParserListener
Throws:
FeedParserException

onGUIDEnd

public void onGUIDEnd()
               throws FeedParserException
Specified by:
onGUIDEnd in interface MetaFeedParserListener
Throws:
FeedParserException

onGenerator

public void onGenerator(FeedParserState state,
                        String content)
                 throws FeedParserException
Description copied from interface: MetaFeedParserListener
Called when a generator contruct is found within Atom or RSS 2.0

Specified by:
onGenerator in interface MetaFeedParserListener
Throws:
FeedParserException

onGeneratorEnd

public void onGeneratorEnd()
                    throws FeedParserException
Specified by:
onGeneratorEnd in interface MetaFeedParserListener
Throws:
FeedParserException

onAuthor

public void onAuthor(FeedParserState state,
                     String name,
                     String email,
                     String resource)
              throws FeedParserException
Description copied from interface: MetaFeedParserListener
Provided for author information across RSS 2.0, atom, dc:creator in RSS 1.0. Both email, and resource may be null if not specified. TODO: what does RSS 0.91, 0.9, etc provide? NOTE that this is not yet 100% compatible with FOAF person constructs. FOAF provides additional metadata including title, firstName, surname, nick, etc which we don't provide with this method. We'll probably add additional events for this in the future.

Specified by:
onAuthor in interface MetaFeedParserListener
Throws:
FeedParserException

onAuthorEnd

public void onAuthorEnd()
                 throws FeedParserException
Specified by:
onAuthorEnd in interface MetaFeedParserListener
Throws:
FeedParserException

onComments

public void onComments(FeedParserState state,
                       String resource)
                throws FeedParserException
Specified by:
onComments in interface MetaFeedParserListener
Throws:
FeedParserException

onCommentsEnd

public void onCommentsEnd()
                   throws FeedParserException
Specified by:
onCommentsEnd in interface MetaFeedParserListener
Throws:
FeedParserException

onCommentsFeed

public void onCommentsFeed(FeedParserState state,
                           String resource)
                    throws FeedParserException
Specified by:
onCommentsFeed in interface MetaFeedParserListener
Throws:
FeedParserException

onCommentsFeedEnd

public void onCommentsFeedEnd()
                       throws FeedParserException
Specified by:
onCommentsFeedEnd in interface MetaFeedParserListener
Throws:
FeedParserException

onContentEncoded

public void onContentEncoded(FeedParserState state,
                             String value)
                      throws FeedParserException
Specified by:
onContentEncoded in interface ModContentFeedParserListener
Throws:
FeedParserException

onContentEncodedEnd

public void onContentEncodedEnd()
                         throws FeedParserException
Specified by:
onContentEncodedEnd in interface ModContentFeedParserListener
Throws:
FeedParserException

onContentItem

public void onContentItem(FeedParserState state,
                          String format,
                          String encoding,
                          org.jdom.Element value)
                   throws FeedParserException
Specified by:
onContentItem in interface ModContentFeedParserListener
Throws:
FeedParserException

onContentItemEnd

public void onContentItemEnd()
                      throws FeedParserException
Specified by:
onContentItemEnd in interface ModContentFeedParserListener
Throws:
FeedParserException

onXHTMLBody

public void onXHTMLBody(FeedParserState state,
                        org.jdom.Element value)
                 throws FeedParserException
Specified by:
onXHTMLBody in interface XHTMLFeedParserListener
Throws:
FeedParserException

onXHTMLBodyEnd

public void onXHTMLBodyEnd()
                    throws FeedParserException
Specified by:
onXHTMLBodyEnd in interface XHTMLFeedParserListener
Throws:
FeedParserException

onContent

public void onContent(FeedParserState state,
                      String type,
                      String format,
                      String encoding,
                      String mode,
                      String value,
                      boolean isSummary)
               throws FeedParserException
Description copied from interface: ContentFeedParserListener
Called when new content is found.

Specified by:
onContent in interface ContentFeedParserListener
type - (Atom) Content constructs MAY have a "type" attribute, whose value indicates the media type of the content. When present, this attribute's value MUST be a registered media type [RFC2045]. If not present, its value MUST be considered to be "text/plain". 3.1.2 "mode" Attribute
format - (RSS 1.0 mod_content) Required. An empty element with an rdf:resource attribute that points to a URI representing the format of the content:item. Suggested best practice is to use the list of RDDL natures.
encoding - (RSS 1.0 mod_content) Optional. An empty element with an rdf:resource attribute that points to a URI representing the encoding of the content:item. An encoding is a reversable method of including content within the RSS file.
mode - (Atom) Content constructs MAY have a "mode" attribute, whose value indicates the method used to encode the content. When present, this attribute's value MUST be listed below. If not present, its value MUST be considered to be "xml". "xml": A mode attribute with the value "xml" indicates that the element's content is inline xml (for example, namespace-qualified XHTML). "escaped": A mode attribute with the value "escaped" indicates that the element's content is an escaped string. Processors MUST unescape the element's content before considering it as content of the indicated media type. "base64": A mode attribute with the value "base64" indicates that the element's content is base64-encoded [RFC2045]. Processors MUST decode the element's content before considering it as content of the the indicated media type.
value - String value of the found content. if this is Base64 encoded content we do NOT decode the value but return it as a string. This is done because the content might be binary and returning as a string would be invalid.
isSummary - True if this is just a summary of the content and not the full content. This is only known for Atom feeds.
Throws:
FeedParserException

onContentEnd

public void onContentEnd()
                  throws FeedParserException
Specified by:
onContentEnd in interface ContentFeedParserListener
Throws:
FeedParserException


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.