01: /*
02: * Copyright 2004 Sun Microsystems, Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not 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.
15: *
16: */
17: package org.apache.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 = Namespace
31: .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
53: .getEncoded()));
54: }
55: }
56:
57: protected Element generateSimpleElement(String name, String value) {
58: Element element = new Element(name, CONTENT_NS);
59: element.addContent(value);
60: return element;
61: }
62:
63: }
|