1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.sun.syndication.io.impl;
18
19 import com.sun.syndication.feed.rss.Description;
20 import com.sun.syndication.feed.rss.Item;
21 import com.sun.syndication.feed.rss.Channel;
22 import com.sun.syndication.io.FeedException;
23 import org.jdom.Element;
24 import org.jdom.Namespace;
25
26 import java.util.List;
27
28 /***
29 * Feed Generator for RSS 1.0
30 * <p/>
31 *
32 * @author Elaine Chien
33 *
34 */
35
36 public class RSS10Generator extends RSS090Generator {
37 private static final String RSS_URI = "http://purl.org/rss/1.0/";
38 private static final Namespace RSS_NS = Namespace.getNamespace(RSS_URI);
39
40 public RSS10Generator() {
41 super("rss_1.0");
42 }
43
44 protected RSS10Generator(String feedType) {
45 super(feedType);
46 }
47
48 protected Namespace getFeedNamespace() {
49 return RSS_NS;
50 }
51
52 protected void populateChannel(Channel channel,Element eChannel) {
53 super.populateChannel(channel,eChannel);
54 List items = channel.getItems();
55 if (items.size()>0) {
56 Element eItems = new Element("items",getFeedNamespace());
57 Element eSeq = new Element("Seq",getRDFNamespace());
58 for (int i=0;i<items.size();i++) {
59 Item item = (Item) items.get(i);
60 Element eLi = new Element("li",getRDFNamespace());
61 String link = item.getLink();
62 if (link!=null) {
63 eLi.setAttribute("resource",link);
64 }
65 eSeq.addContent(eLi);
66 }
67 eItems.addContent(eSeq);
68 eChannel.addContent(eItems);
69 }
70 }
71
72 protected void populateItem(Item item,Element eItem) {
73 super.populateItem(item,eItem);
74 String link = item.getLink();
75 if (link!=null) {
76 eItem.setAttribute("about",link,getRDFNamespace());
77 }
78 Description description = item.getDescription();
79 if (description!=null) {
80 eItem.addContent(generateSimpleElement("description",description.getValue()));
81 }
82 }
83
84 protected void checkItemsConstraints(Element parent) throws FeedException {
85 }
86
87 protected void checkItemConstraints(Element eItem) throws FeedException {
88 super.checkItemConstraints(eItem);
89 checkLength(eItem,"description", 0, 500);
90 }
91
92 }
93