1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.sf.ediknight;
21
22 import java.io.IOException;
23 import java.io.InputStream;
24 import java.io.OutputStream;
25
26 import org.xml.sax.ContentHandler;
27
28
29 /***
30 * @author Holger Joest
31 */
32 public interface Converter {
33
34 /***
35 * Returns the converter configuration.
36 *
37 * @return the configuration
38 */
39 ConverterConfiguration getConfiguration();
40
41
42 /***
43 * Sets the converter configuration.
44 *
45 * @param configuration the configuration to set
46 */
47 void setConfiguration(ConverterConfiguration configuration);
48
49
50 /***
51 * Choose an appropriate parser depending on the content
52 * read from an input stream.
53 * <p>
54 * The method returns a (possibly different) instance
55 * of an input stream that will give exactly the same
56 * sequence of bytes that would have been given by
57 * <code>stream</code>.
58 *
59 * @param stream the input stream
60 * @return the restored input stream
61 * @throws ConfigurationException if there's a serious configuration problem
62 * @throws IOException if an I/O error occurs
63 */
64 InputStream recognize(InputStream stream)
65 throws ConfigurationException, IOException;
66
67
68 /***
69 * Returns the parser.
70 *
71 * @return the parser
72 */
73 Parser<Format> getParser();
74
75
76 /***
77 * Return a content handler for a given format.
78 *
79 * @param format the format
80 * @param out an output stream
81 * @return the content handler
82 * @throws ConfigurationException if there's a configuration error
83 */
84 ContentHandler getContentHandler(
85 String format, OutputStream out)
86 throws ConfigurationException;
87
88 }
89