Clover coverage report - Flock Flock - 0.7-dev
Coverage timestamp: Thu Jan 30 2003 01:35:37 EST
file stats: LOC: 137   Methods: 11
NCLOC: 81   Classes: 1
This license of Clover is provided to support the development of Flock only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover.
 
 Source file Conditionals Statements Methods TOTAL
Feed.java 0% 0% 0% 0%
 1   
 package net.sf.flock.impl;
 2   
 
 3   
 import java.net.MalformedURLException;
 4   
 import java.net.URL;
 5   
 import java.util.ArrayList;
 6   
 import java.util.Date;
 7   
 import java.util.Iterator;
 8   
 import java.util.List;
 9   
 
 10   
 import net.sf.flock.FeedI;
 11   
 import net.sf.flock.ItemI;
 12   
 import net.sf.flock.SubscriptionInfoI;
 13   
 
 14   
 
 15   
 /**
 16   
  * @version $Revision$
 17   
  * @author $Author$
 18   
  */
 19   
 class Feed implements FeedI {
 20   
 
 21   
     private String title = "New feed";
 22   
     private URL site;
 23   
     private List items = new ArrayList();
 24   
     private SubscriptionInfoI subscriptionInfo;
 25   
 
 26   
 
 27   
     /**
 28   
      * Constructor Feed.
 29   
      * @param subscriptionInfoI
 30   
      */
 31  0
     public Feed(SubscriptionInfoI subscriptionInfo) {
 32  0
         this.subscriptionInfo = subscriptionInfo;
 33   
     }
 34   
 
 35   
     /**
 36   
      * Constructor Feed.
 37   
      */
 38  0
     public Feed() {
 39   
         
 40   
     }
 41   
 
 42   
     
 43   
     /**
 44   
      * @return site, or new URL("http://") if it's null
 45   
      * @see net.sf.flock.FeedI#getSite()
 46   
      */
 47  0
     public URL getSite() {
 48  0
         if (site!=null) {
 49  0
             return site;
 50   
         } else {
 51  0
             try {
 52  0
                 return new URL("http://");
 53   
             } catch (MalformedURLException e) {
 54  0
                 return null;
 55   
             }
 56   
         }
 57   
     }
 58   
 
 59  0
     public void setSite(URL site) {
 60  0
         this.site = site;
 61   
     }
 62   
 
 63   
     /**
 64   
      * @see net.sf.flock.FeedI#getItems()
 65   
      */
 66  0
     public List getItems() {
 67  0
         return this.items;
 68   
     }
 69   
 
 70  0
     public ItemI newItem(Date creationTime, String title, String description, URL link) {
 71  0
         Item item = new Item(this);
 72  0
         item.setCreationTime(creationTime);
 73  0
         item.setTitle(title);
 74  0
         item.setDescription(description);
 75  0
         item.setLink(link);
 76  0
         this.items.add( item );
 77  0
         return item;
 78   
     }
 79   
     
 80   
 
 81   
     /**
 82   
      * @see net.sf.flock.FeedI#getTitle()
 83   
      */
 84  0
     public String getTitle() {
 85  0
         return this.title;
 86   
     }
 87   
     
 88  0
     public void setTitle(String title) {
 89  0
         if (title==null) {
 90  0
             throw new IllegalArgumentException("Title cannot be null");    
 91   
         }
 92  0
         this.title = title;
 93   
     }
 94   
 
 95   
     /**
 96   
      * @see net.sf.flock.FeedI#merge(FeedI)
 97   
      */
 98  0
     public List merge(FeedI feed) {
 99  0
         this.setTitle( feed.getTitle() );
 100  0
         this.setSite( feed.getSite() );
 101   
 
 102  0
         List newItems = new ArrayList();
 103  0
         for (Iterator i=feed.getItems().iterator(); i.hasNext(); ) {
 104  0
             ItemI a = (ItemI)i.next();
 105  0
             if (!this.getItems().contains(a)) {
 106  0
                 newItems.add(
 107   
                     this.newItem(
 108   
                         a.getCreationTime(),
 109   
                         a.getTitle(),
 110   
                         a.getDescription(),
 111   
                         a.getLink()
 112   
                     )
 113   
                 );
 114   
             }
 115   
         }
 116   
 
 117  0
         return newItems;
 118   
     }
 119   
 
 120   
 
 121   
     /**
 122   
      * @see net.sf.flock.FeedInfoI#getSubscriptionInfo()
 123   
      */
 124  0
     public SubscriptionInfoI getSubscriptionInfo() {
 125  0
         return subscriptionInfo;
 126   
     }
 127   
 
 128   
     /**
 129   
      * Sets the subscriptionInfo.
 130   
      * @param subscriptionInfo The subscriptionInfo to set
 131   
      */
 132  0
     public void setSubscriptionInfo(SubscriptionInfoI subscriptionInfo) {
 133  0
         this.subscriptionInfo = subscriptionInfo;
 134   
     }
 135   
 
 136   
 }
 137