KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > syndication > io > impl > RSS091NetscapeParser


1 /*
2  * Copyright 2004 Sun Microsystems, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 org.jdom.*;
20
21 /**
22  */

23 public class RSS091NetscapeParser extends RSS091UserlandParser {
24
25     public RSS091NetscapeParser() {
26         this("rss_0.91N");
27     }
28
29     protected RSS091NetscapeParser(String JavaDoc type) {
30         super(type);
31     }
32
33     static final String JavaDoc ELEMENT_NAME = "rss";
34     static final String JavaDoc PUBLIC_ID = "-//Netscape Communications//DTD RSS 0.91//EN";
35     static final String JavaDoc SYSTEM_ID = "http://my.netscape.com/publish/formats/rss-0.91.dtd";
36
37     public boolean isMyType(Document document) {
38         boolean ok = false;
39         Element rssRoot = document.getRootElement();
40         ok = rssRoot.getName().equals("rss");
41         if (ok) {
42             ok = false;
43             Attribute version = rssRoot.getAttribute("version");
44             if (version!=null) {
45                 ok = version.getValue().equals(getRSSVersion());
46                 if (ok) {
47                     ok = false;
48                     DocType docType = document.getDocType();
49
50                     if (docType!=null) {
51                         ok = ELEMENT_NAME.equals(docType.getElementName());
52                         ok = ok && PUBLIC_ID.equals(docType.getPublicID());
53                         ok = ok && SYSTEM_ID.equals(docType.getSystemID());
54                     }
55                 }
56             }
57         }
58         return ok;
59     }
60
61     protected boolean isHourFormat24(Element rssRoot) {
62         return false;
63     }
64
65     protected String JavaDoc getTextInputLabel() {
66         return "textinput";
67     }
68
69 }
70
Popular Tags