1   package net.sf.flock.hibernate;
2   
3   import java.net.URL;
4   import java.util.ArrayList;
5   import java.util.Date;
6   import java.util.Iterator;
7   import java.util.List;
8   
9   import net.sf.flock.FeedI;
10  import net.sf.flock.FeedInfoI;
11  import net.sf.flock.ItemI;
12  import net.sf.flock.SubscriptionInfoI;
13  
14  class Feed implements FeedI {
15  
16  	private Subscription subscription;
17  
18  	private String title = "New feed";
19  	private URL site;
20  	private List items = new ArrayList();
21  
22  	public Feed() {
23  	}
24  	
25  	public Feed(FeedInfoI info) {
26  		this.setSite(info.getSite());
27  		this.setTitle(info.getTitle());
28  	}
29  	/***
30  	 * @see net.sf.flock.FeedI#getItems()
31  	 */
32  	public List getItems() {
33  		return this.items;
34  	}
35  	
36  	protected void setItems(List items) {
37  		this.items = items;
38  		for (Iterator i=items.iterator(); i.hasNext(); ) {
39  			((Item)i.next()).setOrigin(this);
40  		}
41  	}
42  
43  	/***
44  	 * @see net.sf.flock.FeedI#newItem(java.util.Date, java.lang.String, java.lang.String, java.net.URL)
45  	 */
46  	public ItemI newItem(Date creationTime, String title, String description, URL link) {
47  		Item item = new Item();
48  		item.setOrigin(this);
49  		item.setCreationTime(creationTime);
50  		item.setTitle(title);
51  		item.setDescription(description);
52  		item.setLink(link);
53  		this.items.add( item );
54  		return item;
55  	}
56  
57  	/***
58  	 * @see net.sf.flock.FeedInfoI#getTitle()
59  	 */
60  	public String getTitle() {
61  		return this.title;
62  	}
63  
64  	/***
65  	 * @see net.sf.flock.FeedI#setTitle(java.lang.String)
66  	 */
67  	public void setTitle(String title) {
68  		this.title = title;
69  	}
70  
71  	/***
72  	 * @see net.sf.flock.FeedInfoI#getSite()
73  	 */
74  	public URL getSite() {
75  		return this.site;
76  	}
77  
78  	/***
79  	 * @see net.sf.flock.FeedI#setSite(java.net.URL)
80  	 */
81  	public void setSite(URL url) {
82  		this.site = url;
83  	}
84  
85  	/***
86  	 * @see net.sf.flock.FeedI#merge(net.sf.flock.FeedI)
87  	 */
88  	public List merge(FeedI feed) {
89  		// TODO: implement merge
90  		return null;
91  	}
92  
93      /***
94       * @see net.sf.flock.FeedInfoI#getSubscriptionInfo()
95       */
96      public SubscriptionInfoI getSubscriptionInfo() {
97          return this.subscription;
98      }
99  
100 	public Subscription getSubscription() {
101 		return subscription;
102 	}
103 
104 	void setSubscription(Subscription subscription) {
105 		this.subscription = subscription;
106 	}
107 
108 	public boolean equals(Object obj) {
109 		if (obj==null)
110 			return false;
111 		if (obj instanceof FeedI) {
112 			if ( site.equals(((FeedI)obj).getSite())) {
113 				 // TODO: implement deep checking 
114 				 return true;
115 			}
116 						
117 		}
118 		return false;
119 	}
120 }
This page was automatically generated by Maven