1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.sun.syndication.io;
18
19 import com.sun.syndication.io.FeedException;
20 import com.sun.syndication.io.WireFeedOutput;
21 import com.sun.syndication.feed.synd.SyndFeedI;
22 import org.jdom.Document;
23
24 import java.io.IOException;
25 import java.io.Writer;
26 import java.io.File;
27
28 /***
29 * Generates an XML document (String, File, OutputStream, Writer, W3C DOM document or JDOM document)
30 * out of an SyndFeed..
31 * <p>
32 * It delegates to a WireFeedOutput to generate all feed types.
33 * <p>
34 * @author Alejandro Abdelnur
35 *
36 */
37 public class SyndFeedOutput {
38 private WireFeedOutput _feedOutput;
39
40 /***
41 * Creates a SyndFeedOutput instance.
42 * <p>
43 *
44 */
45 public SyndFeedOutput() {
46 _feedOutput = new WireFeedOutput();
47 }
48
49 /***
50 * Creates a String with the XML representation for the given SyndFeed.
51 * <p>
52 * @param feed Abstract feed to create XML representation from. The type of the SyndFeed must match
53 * the type given to the FeedOuptut constructor.
54 * @return a String with the XML representation for the given SyndFeed.
55 * @throws FeedException thrown if the XML representation for the feed could not be created.
56 *
57 */
58 public String outputString(SyndFeedI feed) throws FeedException {
59 return _feedOutput.outputString(feed.createWireFeed());
60 }
61
62 /***
63 * Creates a File containing with the XML representation for the given SyndFeed.
64 * <p>
65 * @param feed Abstract feed to create XML representation from. The type of the SyndFeed must match
66 * the type given to the FeedOuptut constructor.
67 * @param file the file where to write the XML representation for the given SyndFeed.
68 * @throws IOException thrown if there was some problem writing to the File.
69 * @throws FeedException thrown if the XML representation for the feed could not be created.
70 *
71 */
72 public void output(SyndFeedI feed,File file) throws IOException, FeedException {
73 _feedOutput.output(feed.createWireFeed(),file);
74 }
75
76 /***
77 * Writes to an Writer the XML representation for the given SyndFeed.
78 * <p>
79 * @param feed Abstract feed to create XML representation from. The type of the SyndFeed must match
80 * the type given to the FeedOuptut constructor.
81 * @param writer Writer to write the XML representation for the given SyndFeed.
82 * @throws IOException thrown if there was some problem writing to the Writer.
83 * @throws FeedException thrown if the XML representation for the feed could not be created.
84 *
85 */
86 public void output(SyndFeedI feed,Writer writer) throws IOException, FeedException {
87 _feedOutput.output(feed.createWireFeed(),writer);
88 }
89
90 /***
91 * Creates a W3C DOM document for the given SyndFeed.
92 * <p>
93 * @param feed Abstract feed to create W3C DOM document from. The type of the SyndFeed must match
94 * the type given to the FeedOuptut constructor.
95 * @return the W3C DOM document for the given SyndFeed.
96 * @throws FeedException thrown if the W3C DOM document for the feed could not be created.
97 *
98 */
99 public org.w3c.dom.Document outputW3CDom(SyndFeedI feed) throws FeedException {
100 return _feedOutput.outputW3CDom(feed.createWireFeed());
101 }
102
103 /***
104 * Creates a JDOM document for the given SyndFeed.
105 * <p>
106 * @param feed Abstract feed to create JDOM document from. The type of the SyndFeed must match
107 * the type given to the FeedOuptut constructor.
108 * @return the JDOM document for the given SyndFeed.
109 * @throws FeedException thrown if the JDOM document for the feed could not be created.
110 *
111 */
112 public Document outputJDom(SyndFeedI feed) throws FeedException {
113 return _feedOutput.outputJDom(feed.createWireFeed());
114 }
115
116 }