1 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 = 32 Namespace.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 } 65 | Popular Tags |