View Javadoc

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 com.sun.syndication.feed.module.SyModule;
20  import com.sun.syndication.feed.module.ModuleI;
21  import com.sun.syndication.feed.module.SyModuleI;
22  import com.sun.syndication.io.ModuleGenerator;
23  import org.jdom.Element;
24  import org.jdom.Namespace;
25  
26  import java.util.HashMap;
27  import java.util.Map;
28  
29  /***
30   * Feed Generator for SY Module
31   * <p/>
32   *
33   * @author Elaine Chien
34   *
35   */
36  
37  public class SyModuleGenerator implements ModuleGenerator {
38  
39      private static final String SY_URI  = "http://purl.org/rss/1.0/modules/syndication/";
40      private static final Namespace SY_NS  = Namespace.getNamespace("sy", SY_URI);
41  
42      public String getNamespaceUri() {
43          return SY_URI;
44      }
45  
46      public void generate(ModuleI module, Element element) {
47  
48          SyModuleI syModule = (SyModuleI)module;
49  
50          Element updatePeriodElement = new Element("updatePeriod", SY_NS);
51          updatePeriodElement.addContent(syModule.getUpdatePeriod().toString());
52          element.addContent(updatePeriodElement);
53  
54          Element updateFrequencyElement = new Element("updateFrequency", SY_NS);
55          updateFrequencyElement.addContent(String.valueOf(syModule.getUpdateFrequency()));
56          element.addContent(updateFrequencyElement);
57  
58          Element updateBaseElement = new Element("updateBase", SY_NS);
59          updateBaseElement.addContent(DateParser.parseW3CDateTime(syModule.getUpdateBase()));
60          element.addContent(updateBaseElement);
61      }
62  }