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.WireFeed;
20 import com.sun.syndication.feed.rss.Channel;
21 import com.sun.syndication.feed.rss.Description;
22 import com.sun.syndication.feed.rss.Guid;
23 import com.sun.syndication.feed.rss.Item;
24 import org.jdom.Element;
25
26 import java.util.List;
27
28
29
30 public class RSS094Parser extends RSS093Parser {
31
32 public RSS094Parser() {
33 this("rss_0.94");
34 }
35
36 protected RSS094Parser(String type) {
37 super(type);
38 }
39
40 protected String getRSSVersion() {
41 return "0.94";
42 }
43
44 protected WireFeed parseChannel(Element rssRoot) {
45 Channel channel = (Channel) super.parseChannel(rssRoot);
46 Element eChannel = rssRoot.getChild("channel",getRSSNamespace());
47
48 List eCats = eChannel.getChildren("category",getRSSNamespace());
49 channel.setCategories(parseCategories(eCats));
50
51 Element eTtl = eChannel.getChild("ttl",getRSSNamespace());
52 if (eTtl!=null && eTtl.getText() != null ) {
53 Integer ttlValue = null;
54 try{
55 ttlValue = new Integer(eTtl.getText());
56 } catch(NumberFormatException nfe ){
57 ;
58 }
59 if (ttlValue != null) {
60 channel.setTtl(ttlValue.intValue());
61 }
62 }
63
64 return channel;
65 }
66
67 public Item parseItem(Element rssRoot,Element eItem) {
68 Item item = super.parseItem(rssRoot,eItem);
69 item.setExpirationDate(null);
70
71 Element e = eItem.getChild("author",getRSSNamespace());
72 if (e!=null) {
73 item.setAuthor(e.getText());
74 }
75
76 e = eItem.getChild("guid",getRSSNamespace());
77 if (e!=null) {
78 Guid guid = new Guid();
79 String att = e.getAttributeValue("isPermaLink");
80 if (att!=null) {
81 guid.setPermaLink(att.equalsIgnoreCase("true"));
82 }
83 guid.setValue(e.getText());
84 item.setGuid(guid);
85 }
86
87 e = eItem.getChild("comments",getRSSNamespace());
88 if (e!=null) {
89 item.setComments(e.getText());
90 }
91
92 return item;
93 }
94
95 protected Description parseItemDescription(Element rssRoot,Element eDesc) {
96 Description desc = super.parseItemDescription(rssRoot,eDesc);
97 String att = eDesc.getAttributeValue("type");
98 if (att==null) {
99 att = "text/html";
100 }
101 desc.setType(att);
102 return desc;
103 }
104
105 }