01: /*
02: * Copyright 2004 Sun Microsystems, Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: *
16: */
17: package com.sun.syndication.io.impl;
18:
19: import com.sun.syndication.feed.rss.Description;
20: import org.jdom.Attribute;
21: import org.jdom.Document;
22: import org.jdom.Element;
23:
24: /**
25: */
26: public class RSS20Parser extends RSS094Parser {
27:
28: public RSS20Parser() {
29: this ("rss_2.0");
30: }
31:
32: protected RSS20Parser(String type) {
33: super (type);
34: }
35:
36: protected String getRSSVersion() {
37: return "2.0";
38: }
39:
40: protected boolean isHourFormat24(Element rssRoot) {
41: return false;
42: }
43:
44: protected Description parseItemDescription(Element rssRoot,
45: Element eDesc) {
46: Description desc = super .parseItemDescription(rssRoot, eDesc);
47: desc.setType("text/html"); // change as per https://rome.dev.java.net/issues/show_bug.cgi?id=26
48: return desc;
49: }
50:
51: public boolean isMyType(Document document) {
52: boolean ok;
53: Element rssRoot = document.getRootElement();
54: ok = rssRoot.getName().equals("rss");
55: if (ok) {
56: ok = false;
57: Attribute version = rssRoot.getAttribute("version");
58: if (version != null) {
59: // At this point, as far ROME is concerned RSS 2.0, 2.00 and
60: // 2.0.X are all the same, so let's use startsWith for leniency.
61: ok = version.getValue().startsWith(getRSSVersion());
62: }
63: }
64: return ok;
65: }
66:
67: }
|