KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snipsnap > semanticweb > rss > NewSnipFeeder


1 /*
2  * This file is part of "SnipSnap Radeox Rendering Engine".
3  *
4  * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
5  * All Rights Reserved.
6  *
7  * Please visit http://radeox.org/ for updates and contact.
8  *
9  * --LICENSE NOTICE--
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  * --LICENSE NOTICE--
24  */

25
26 package org.snipsnap.semanticweb.rss;
27
28 import org.snipsnap.snip.Blog;
29 import org.snipsnap.snip.SnipSpaceFactory;
30 import org.snipsnap.snip.Snip;
31 import org.snipsnap.snip.SnipSpace;
32 import org.snipsnap.snip.storage.query.QueryKit;
33 import org.snipsnap.snip.storage.query.Query;
34 import org.snipsnap.snip.storage.query.SnipQuery;
35 import org.snipsnap.app.Application;
36 import org.snipsnap.feeder.Feeder;
37
38 import java.util.List JavaDoc;
39
40 /*
41  * Generates a feed of new snips without comments from a space which can then be
42  * serialized to RSS, RDF, Atom, ...
43  *
44  * @author stephan
45  * @team sonicteam
46  * @version $Id: NewSnipFeeder.java 1606 2004-05-17 10:56:18Z leo $
47  */

48
49 public class NewSnipFeeder implements Feeder {
50   private SnipSpace space;
51   private String JavaDoc snipName;
52   private Query newAndNotCommentQuery = new SnipQuery() {
53       public boolean fit(Snip snip) {
54         return isComment(snip) && (snip.getVersion() == 0);
55       }
56     };
57
58   public NewSnipFeeder() {
59     this(Application.get().getConfiguration().getStartSnip());
60   }
61
62   private NewSnipFeeder(String JavaDoc snipName) {
63     this.snipName = snipName;
64     space = SnipSpaceFactory.getInstance();
65   }
66
67   public String JavaDoc getName() {
68     return "newsnipsonly";
69   }
70
71   public List JavaDoc getFeed() {
72     List JavaDoc changed = space.getChanged();
73     return QueryKit.query(changed, newAndNotCommentQuery);
74   }
75
76   public Snip getContextSnip() {
77     return space.load(snipName);
78   }
79
80   public boolean isComment(Snip snip) {
81     return (snip.getName().indexOf("comment") >=0);
82   }
83 }
84
Popular Tags