org.apache.commons.feedparser.impl
Class DebugFeedParserListener

java.lang.Object
  extended by org.apache.commons.feedparser.DefaultFeedParserListener
      extended by org.apache.commons.feedparser.impl.DebugFeedParserListener
All Implemented Interfaces:
ContentFeedParserListener, FeedDirectoryParserListener, FeedLifecycleListener, FeedParserListener, LinkFeedParserListener, MetaFeedParserListener, ModContentFeedParserListener, TagFeedParserListener, XHTMLFeedParserListener
Direct Known Subclasses:
CaptureOutputFeedParserListener

public class DebugFeedParserListener
extends DefaultFeedParserListener
implements FeedParserListener, FeedDirectoryParserListener, MetaFeedParserListener, LinkFeedParserListener, TagFeedParserListener, ModContentFeedParserListener

Version:
$Id: DebugFeedParserListener.java 373622 2006-01-30 22:53:00Z mvdb $
Author:
Kevin A. Burton (burtonator)

Constructor Summary
DebugFeedParserListener()
           
DebugFeedParserListener(PrintStream out)
           
 
Method Summary
 void finished()
          Called when the feed has finished parsing.
 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 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 onCommentsFeed(FeedParserState state, String resource)
           
 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 onContentItem(FeedParserState state, String format, String encoding, org.jdom.Element value)
           
 void onCreated(FeedParserState state, Date date)
          http://www.mnot.net/drafts/draft-nottingham-atom-format-00.html#rfc.section.3.2.8
 void onFeedVersion(FeedVersion version)
          Called when we are first able to determine the feed version for this feed.
 void onFolder(FeedParserState state, String name)
          Called when a new Folder is found.
 void onFolderEnd()
           
 void onGUID(FeedParserState state, String value, boolean isPermalink)
          Used to represent RSS 2.0 GUIDs and atom:id constructs.
 void onImage(FeedParserState state, String title, String link, String url)
          Called when an RSS image is found.
 void onImageEnd()
           
 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 onLink(FeedParserState state, String rel, String type, String href, String title, long length)
           
 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 onRelation(FeedParserState state, String value)
          Called when we've found a relation for a given item.
 void onRelationEnd()
           
 void onTag(FeedParserState state, String tag, String tagspace)
           
 void onTagEnd()
           
 void setContext(Object context)
          Set this context that this FeedParserListener is executing within.
 
Methods inherited from class org.apache.commons.feedparser.DefaultFeedParserListener
getContext, onAuthorEnd, onCommentsEnd, onCommentsFeedEnd, onContentEncodedEnd, onContentEnd, onContentItemEnd, onCopyright, onCopyrightEnd, onCreatedEnd, onGenerator, onGeneratorEnd, onGUIDEnd, onIssued, onIssuedEnd, onSubject, onSubjectEnd, onXHTMLBody, onXHTMLBodyEnd
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.feedparser.FeedLifecycleListener
getContext
 
Methods inherited from interface org.apache.commons.feedparser.MetaFeedParserListener
onAuthorEnd, onCommentsEnd, onCommentsFeedEnd, onCopyright, onCopyrightEnd, onCreatedEnd, onGenerator, onGeneratorEnd, onGUIDEnd, onIssued, onIssuedEnd, onSubject, onSubjectEnd
 
Methods inherited from interface org.apache.commons.feedparser.ModContentFeedParserListener
onContentEncodedEnd, onContentItemEnd
 

Constructor Detail

DebugFeedParserListener

public DebugFeedParserListener()

DebugFeedParserListener

public DebugFeedParserListener(PrintStream out)
Method Detail

init

public void init()
Called prior to event parsing to signal the parsing of a new feed.

Specified by:
init in interface FeedLifecycleListener
Overrides:
init in class DefaultFeedParserListener

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
Overrides:
onFeedVersion in class DefaultFeedParserListener
Throws:
FeedParserException

setContext

public void setContext(Object context)
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
Overrides:
setContext in class DefaultFeedParserListener

onChannel

public void onChannel(FeedParserState state,
                      String title,
                      String link,
                      String description)
Called when a channel item is found.

Specified by:
onChannel in interface FeedParserListener
Overrides:
onChannel in class DefaultFeedParserListener

onChannelEnd

public void onChannelEnd()
Specified by:
onChannelEnd in interface FeedParserListener
Overrides:
onChannelEnd in class DefaultFeedParserListener

onImage

public void onImage(FeedParserState state,
                    String title,
                    String link,
                    String url)
Called when an RSS image is found.

Specified by:
onImage in interface FeedParserListener
Overrides:
onImage in class DefaultFeedParserListener

onImageEnd

public void onImageEnd()
Specified by:
onImageEnd in interface FeedParserListener
Overrides:
onImageEnd in class DefaultFeedParserListener

onItem

public void onItem(FeedParserState state,
                   String title,
                   String link,
                   String description,
                   String permalink)
Called when an RSS item or Atom entry is found.

Specified by:
onItem in interface FeedDirectoryParserListener
Specified by:
onItem in interface FeedParserListener
Overrides:
onItem in class DefaultFeedParserListener
title - The title of the feed or weblog. Maybe be null when not specified.
link - The HTML URL to the root of the weblog. Example: http://www.peerfear.org
permalink - The XML URL to the RSS/Atom feed for this weblog. This may be null in some situations when we don't have a feed URL
See Also:
FeedParserListener.onItem(org.apache.commons.feedparser.FeedParserState, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

onItemEnd

public void onItemEnd()
Specified by:
onItemEnd in interface FeedDirectoryParserListener
Specified by:
onItemEnd in interface FeedParserListener
Overrides:
onItemEnd in class DefaultFeedParserListener

finished

public void finished()
Called when the feed has finished parsing.

Specified by:
finished in interface FeedLifecycleListener
Overrides:
finished in class DefaultFeedParserListener

onFolder

public void onFolder(FeedParserState state,
                     String name)
              throws FeedParserException
Called when a new Folder is found. If feeds are in the default root folder this method is not called.

Specified by:
onFolder in interface FeedDirectoryParserListener
Throws:
FeedParserException

onFolderEnd

public void onFolderEnd()
                 throws FeedParserException
Specified by:
onFolderEnd in interface FeedDirectoryParserListener
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
Overrides:
onContent in class DefaultFeedParserListener
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

onCreated

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

Specified by:
onCreated in interface MetaFeedParserListener
Overrides:
onCreated in class DefaultFeedParserListener
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
Overrides:
onGUID in class DefaultFeedParserListener
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
Overrides:
onAuthor in class DefaultFeedParserListener
Throws:
FeedParserException

onComments

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

onCommentsFeed

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

onLink

public void onLink(FeedParserState state,
                   String rel,
                   String type,
                   String href,
                   String title,
                   long length)
            throws FeedParserException
Specified by:
onLink in interface LinkFeedParserListener
Parameters:
length - The length of the content or -1 if not specified.
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
Overrides:
onLocale in class DefaultFeedParserListener
Throws:
FeedParserException

onLocaleEnd

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

onRelation

public void onRelation(FeedParserState state,
                       String value)
Description copied from interface: FeedDirectoryParserListener
Called when we've found a relation for a given item. This way you can specify the relationship you have with a given entry in your directory. This is mostly for compatibility purposes with XFN so that the values can be 'met', 'date', 'sweetheart', 'friend'. For XFN we would call onItem() methods and then onRelation() methods with each of the relations passed.

Specified by:
onRelation in interface FeedDirectoryParserListener

onRelationEnd

public void onRelationEnd()
Specified by:
onRelationEnd in interface FeedDirectoryParserListener

onTag

public void onTag(FeedParserState state,
                  String tag,
                  String tagspace)
           throws FeedParserException
Specified by:
onTag in interface TagFeedParserListener
Throws:
FeedParserException

onTagEnd

public void onTagEnd()
              throws FeedParserException
Specified by:
onTagEnd in interface TagFeedParserListener
Throws:
FeedParserException

onContentEncoded

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

onContentItem

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


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