1 17 package org.roller.util.rome; 18 19 import java.util.Collections ; 20 import java.util.HashSet ; 21 import java.util.Set ; 22 23 import org.jdom.Element; 24 import org.jdom.Namespace; 25 26 import com.sun.syndication.feed.module.Module; 27 import com.sun.syndication.io.ModuleGenerator; 28 29 public class ContentModuleGenerator implements ModuleGenerator { 30 private static final Namespace CONTENT_NS = 31 Namespace.getNamespace(ContentModule.URI); 32 33 public String getNamespaceUri() { 34 return ContentModule.URI; 35 } 36 37 private static final Set NAMESPACES; 38 39 static { 40 Set nss = new HashSet (); 41 nss.add(CONTENT_NS); 42 NAMESPACES = Collections.unmodifiableSet(nss); 43 } 44 45 public Set getNamespaces() { 46 return NAMESPACES; 47 } 48 49 public void generate(Module module, Element element) { 50 ContentModule fm = (ContentModule)module; 51 if (fm.getEncoded() != null) { 52 element.addContent(generateSimpleElement("encoding", fm.getEncoded())); 53 } 54 } 55 56 protected Element generateSimpleElement(String name, String value) { 57 Element element = new Element(name, CONTENT_NS); 58 element.addContent(value); 59 return element; 60 } 61 62 } 63 | Popular Tags |