View Javadoc

1   /*
2    * EDI-Knight Integration and Transformation Platform
3    * Copyright (C) 2006-2007 Holger Joest <hjoest@users.sourceforge.net>
4    *
5    * This program is free software; you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation; either version 2 of the License, or
8    * (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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