public class RssView implements View {
@SuppressWarnings("unchecked")
public void render(HttpServletRequest req, HttpServletResponse resp,
Object obj) throws Throwable {
Channel channel = new Channel();
channel.setCopyright("Ngqa copy right");
channel.setLink(req.getRequestURL().toString());
channel.setTitle("Ngqa questions");
if (obj instanceof Pager) {
Pager<Question> pager = (Pager<Question>) obj;
for (Question question : pager.getData()) {
channel.addItem(Helpers.makeQuestionURL(question), question.getTitle(), question.getContent());
}
} else if (obj instanceof Question) {
Question question = (Question) obj;
channel.addItem(Helpers.makeQuestionURL(question), question.getTitle(), question.getContent());
}
resp.getWriter().write(channel.getFeed("rss"));
}