Coverage Report - org.apache.commons.feedparser.impl.DebugFeedParserListener
 
Classes in this File Line Coverage Branch Coverage Complexity
DebugFeedParserListener
0%
0/72
N/A
1
 
 1  
 /*
 2  
  * Copyright 1999,2004 The Apache Software Foundation.
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.apache.commons.feedparser.impl;
 18  
 
 19  
 import java.io.PrintStream;
 20  
 import java.util.Date;
 21  
 import java.util.Locale;
 22  
 
 23  
 import org.apache.commons.feedparser.DefaultFeedParserListener;
 24  
 import org.apache.commons.feedparser.FeedDirectoryParserListener;
 25  
 import org.apache.commons.feedparser.FeedParserException;
 26  
 import org.apache.commons.feedparser.FeedParserListener;
 27  
 import org.apache.commons.feedparser.FeedParserState;
 28  
 import org.apache.commons.feedparser.FeedVersion;
 29  
 import org.apache.commons.feedparser.LinkFeedParserListener;
 30  
 import org.apache.commons.feedparser.MetaFeedParserListener;
 31  
 import org.apache.commons.feedparser.ModContentFeedParserListener;
 32  
 import org.apache.commons.feedparser.TagFeedParserListener;
 33  
 import org.jdom.Element;
 34  
 
 35  
 /**
 36  
  *
 37  
  * @author <a href="mailto:burton@apache.org">Kevin A. Burton (burtonator)</a>
 38  
  * @version $Id: DebugFeedParserListener.java 373622 2006-01-30 22:53:00Z mvdb $
 39  
  */
 40  
 public class DebugFeedParserListener
 41  
     extends DefaultFeedParserListener
 42  
     implements FeedParserListener,
 43  
                FeedDirectoryParserListener,
 44  
                MetaFeedParserListener,
 45  
                LinkFeedParserListener,
 46  
                TagFeedParserListener,
 47  
                ModContentFeedParserListener {
 48  
 
 49  0
     PrintStream out = System.out;
 50  
 
 51  0
     public DebugFeedParserListener() { }
 52  
 
 53  0
     public DebugFeedParserListener( PrintStream out ) {
 54  0
         this.out = out;
 55  0
     }
 56  
 
 57  
     /**
 58  
      * Called prior to event parsing to signal the parsing of a new feed.
 59  
      *
 60  
      * 
 61  
      */
 62  
     public void init() {
 63  0
         out.println( "init()" );
 64  0
     }
 65  
 
 66  
     public void onFeedVersion( FeedVersion version ) throws FeedParserException {
 67  0
         out.println( "onFeedVersion: " + version );
 68  0
     }
 69  
 
 70  0
     public void setContext( Object context ) {}
 71  
 
 72  
     /**
 73  
      * Called when a channel item is found.
 74  
      *
 75  
      * 
 76  
      */
 77  
     public void onChannel( FeedParserState state,
 78  
                            String title,
 79  
                            String link,
 80  
                            String description ) {
 81  
 
 82  0
         out.println( "onChannel" );
 83  0
         out.println( "\ttitle : " + title );
 84  0
         out.println( "\tlink : '" + link + "'" );
 85  0
         out.println( "\tdescription : " + description );
 86  
 
 87  0
     }
 88  
 
 89  
     public void onChannelEnd() {
 90  
 
 91  0
         out.println( "onChannelEnd" );
 92  
         
 93  0
     }
 94  
 
 95  
     /**
 96  
      * Called when an RSS image is found.
 97  
      *
 98  
      * 
 99  
      */
 100  
     public void onImage( FeedParserState state,
 101  
                          String title,
 102  
                          String link,
 103  
                          String url ) {
 104  
 
 105  0
         out.println( "onImage" );
 106  
 
 107  0
     }
 108  
 
 109  
     public void onImageEnd() {
 110  0
         out.println( "onImageEnd" );
 111  0
     }
 112  
     
 113  
     /**
 114  
      * Called when an RSS item or Atom entry is found. 
 115  
      *
 116  
      * 
 117  
      */
 118  
     public void onItem( FeedParserState state,
 119  
                         String title,
 120  
                         String link,
 121  
                         String description,
 122  
                         String permalink ) {
 123  
 
 124  0
         out.println( "onItem" );
 125  
 
 126  0
         out.println( "\ttitle : " + title );
 127  0
         out.println( "\tlink : '" + link + "'" );
 128  0
         out.println( "\tdescription : " + description );
 129  
 
 130  0
     }
 131  
 
 132  
     public void onItemEnd() {
 133  0
         out.println( "onItemEnd" );
 134  0
     }
 135  
 
 136  
     /**
 137  
      * Called when the feed has finished parsing.
 138  
      *
 139  
      * 
 140  
      */
 141  
     public void finished() {
 142  0
         out.println( "finished" );
 143  0
     }
 144  
 
 145  
     /**
 146  
      * Called when a new Folder is found.  If feeds are in the default root
 147  
      * folder this method is not called.
 148  
      *
 149  
      * 
 150  
      */
 151  
     public void onFolder( FeedParserState state,
 152  
                           String name ) throws FeedParserException {
 153  
 
 154  0
         out.println( "onFolder: " + name );
 155  
 
 156  0
     }
 157  
 
 158  
     public void onFolderEnd() throws FeedParserException {
 159  
 
 160  0
     }
 161  
 
 162  
     public void onContent( FeedParserState state,
 163  
                            String type,
 164  
                            String format,
 165  
                            String encoding,
 166  
                            String mode,
 167  
                            String value,
 168  
                            boolean isSummary ) throws FeedParserException {
 169  
 
 170  0
         out.println( "onContent: " );
 171  0
         out.println( value );
 172  
         
 173  0
     }
 174  
 
 175  
     public void onCreated( FeedParserState state, Date date ) throws FeedParserException {
 176  
 
 177  0
         out.println( "onCreated: " + date.toString() );
 178  
 
 179  0
     }
 180  
 
 181  
     public void onGUID( FeedParserState state,
 182  
                         String value,
 183  
                         boolean isPermalink ) throws FeedParserException {
 184  
 
 185  0
         out.println( "onGUID: " + value );
 186  0
         out.println( "        isPermalink: " + isPermalink );
 187  
 
 188  0
     }
 189  
 
 190  
     public void onAuthor( FeedParserState state,
 191  
                           String name,
 192  
                           String email,
 193  
                           String resource ) throws FeedParserException {
 194  
 
 195  0
         out.println( "onAuthor: name:" + name );
 196  0
         out.println( "          email: " + email );
 197  0
         out.println( "          resource: " + resource );
 198  
 
 199  0
     }
 200  
 
 201  
     public void onComments( FeedParserState state,
 202  
                             String resource ) throws FeedParserException {
 203  
 
 204  0
         out.println( "onComments: " + resource );
 205  
 
 206  0
     }
 207  
 
 208  
     public void onCommentsFeed( FeedParserState state,
 209  
                                 String resource ) throws FeedParserException {
 210  
 
 211  0
         out.println( "onCommentsFeed: " + resource );
 212  
 
 213  0
     }
 214  
 
 215  
     // **** LinkFeedParserListener **********************************************
 216  
 
 217  
     /**
 218  
      *
 219  
      * 
 220  
      * @param length The length of the content or -1 if not specified.
 221  
      */
 222  
     public void onLink( FeedParserState state,
 223  
                         String rel,
 224  
                         String type,
 225  
                         String href,
 226  
                         String title,
 227  
                         long length ) throws FeedParserException {
 228  
 
 229  0
         out.println( "onLink: " );
 230  0
         out.println( "\trel: " + rel );
 231  0
         out.println( "\thref: " + href );
 232  0
         out.println( "\ttype: " + type );
 233  
         
 234  0
     }
 235  
 
 236  
     public void onLocale( FeedParserState state, Locale locale ) throws FeedParserException {
 237  
 
 238  0
         out.println( "onLocale: " + locale );
 239  
 
 240  0
     }
 241  
 
 242  
     public void onLocaleEnd() throws FeedParserException {
 243  
 
 244  0
         out.println( "onLocaleEnd" );
 245  
 
 246  0
     }
 247  
 
 248  
     public void onRelation( FeedParserState state,
 249  
                             String value ) {
 250  
 
 251  0
         out.println( "onRelation: " + value );
 252  
         
 253  0
     }
 254  
 
 255  
     public void onRelationEnd() {
 256  0
         out.println( "onRelationEnd" );
 257  0
     }
 258  
 
 259  
     // **** TagFeedParserListener ***********************************************
 260  
 
 261  
     public void onTag( FeedParserState state,
 262  
                        String tag,
 263  
                        String tagspace ) throws FeedParserException {
 264  
 
 265  0
         out.println( "onTag: tag: " + tag + " tagspace: " + tagspace );
 266  
 
 267  0
     }
 268  
 
 269  
     public void onTagEnd() throws FeedParserException {
 270  0
         out.println( "onTagEnd" );
 271  0
     }
 272  
 
 273  
     // **** ModContentFeedParserListener ****************************************
 274  
 
 275  
     public void onContentEncoded( FeedParserState state,
 276  
                                   String value ) throws FeedParserException {
 277  
 
 278  0
         out.println( "onContentEncoded: " );
 279  0
         out.println( value );
 280  
 
 281  0
     }
 282  
 
 283  
     public void onContentItem( FeedParserState state,
 284  
                                String format,
 285  
                                String encoding,
 286  
                                Element value ) throws FeedParserException {
 287  
 
 288  0
         out.println( "onContentItem: " );
 289  0
         out.println( value );
 290  
 
 291  0
     }
 292  
 
 293  
 }