KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > webservices > atomprotocol > PubControlModuleGenerator


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * 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. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18 package org.apache.roller.webservices.atomprotocol;
19
20 import java.util.Collections JavaDoc;
21 import java.util.HashSet JavaDoc;
22 import java.util.Set JavaDoc;
23
24 import org.jdom.Element;
25 import org.jdom.Namespace;
26
27 import com.sun.syndication.feed.module.Module;
28 import com.sun.syndication.io.ModuleGenerator;
29
30 public class PubControlModuleGenerator implements ModuleGenerator {
31     private static final Namespace PUBCONTROL_NS =
32         Namespace.getNamespace("app", PubControlModule.URI);
33
34     public String JavaDoc getNamespaceUri() {
35         return PubControlModule.URI;
36     }
37
38     private static final Set JavaDoc NAMESPACES;
39
40     static {
41         Set JavaDoc nss = new HashSet JavaDoc();
42         nss.add(PUBCONTROL_NS);
43         NAMESPACES = Collections.unmodifiableSet(nss);
44     }
45
46     public Set JavaDoc getNamespaces() {
47         return NAMESPACES;
48     }
49
50     public void generate(Module module, Element element) {
51         PubControlModule m = (PubControlModule)module;
52         String JavaDoc draft = m.getDraft() ? "yes" : "no";
53         Element control = new Element("control", PUBCONTROL_NS);
54         control.addContent(generateSimpleElement("draft", draft));
55         element.addContent(control);
56     }
57
58     protected Element generateSimpleElement(String JavaDoc name, String JavaDoc value) {
59         Element element = new Element(name, PUBCONTROL_NS);
60         element.addContent(value);
61         return element;
62     }
63
64 }
65
Popular Tags