01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. The ASF licenses this file to You
04: * under the Apache License, Version 2.0 (the "License"); you may not
05: * 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. 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;
21: import java.util.HashSet;
22: import java.util.Set;
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 = Namespace
32: .getNamespace("app", PubControlModule.URI);
33:
34: public String getNamespaceUri() {
35: return PubControlModule.URI;
36: }
37:
38: private static final Set NAMESPACES;
39:
40: static {
41: Set nss = new HashSet();
42: nss.add(PUBCONTROL_NS);
43: NAMESPACES = Collections.unmodifiableSet(nss);
44: }
45:
46: public Set getNamespaces() {
47: return NAMESPACES;
48: }
49:
50: public void generate(Module module, Element element) {
51: PubControlModule m = (PubControlModule) module;
52: String 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 name, String value) {
59: Element element = new Element(name, PUBCONTROL_NS);
60: element.addContent(value);
61: return element;
62: }
63:
64: }
|