1 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 ; 39 40 48 49 public class NewSnipFeeder implements Feeder { 50 private SnipSpace space; 51 private String 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 snipName) { 63 this.snipName = snipName; 64 space = SnipSpaceFactory.getInstance(); 65 } 66 67 public String getName() { 68 return "newsnipsonly"; 69 } 70 71 public List getFeed() { 72 List 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 |