View Javadoc
1   /*
2    * Copyright (C) 2019 sw4j.org
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16   */
17  package org.sw4j.tool.barcode.random.codedata;
18  
19  import java.io.IOException;
20  import java.io.InputStream;
21  import java.io.OutputStream;
22  import org.sw4j.tool.barcode.random.config.CodeType;
23  import org.sw4j.tool.barcode.random.config.EncodingConfig;
24  
25  /**
26   * <p>
27   * This interface is an abstraction for the application to be able to read different input and output formats (e.g.
28   * streams from a file or from other transports like HTTP).
29   * </p>
30   * @author Uwe Plonus &lt;u.plonus@gmail.com&gt;
31   */
32  public interface CodeData {
33  
34      /**
35       * <p>
36       * Returns an input stream for reading the source data.
37       * </p>
38       * @return an {@code InputStream} for reading the input data.
39       * @throws IOException if the creation of the {@code InputStream} fails.
40       */
41      InputStream getInput() throws IOException;
42  
43      /**
44       * <p>
45       * Returns an output stream for writing the output csv data.
46       * </p>
47       * @return an {@code OutputStream} for writing the output csv data.
48       * @throws IOException if the creation of the {@code OutputStream} fails.
49       */
50      OutputStream getOutput() throws IOException;
51  
52      /**
53       * <p>
54       * Returns an individual output stream for writing the barcode for the given identifier and format.
55       * </p>
56       * @param type the type of the code to write.
57       * @param format the format of the random number (e.g. hex)
58       * @param ident the identifier from the input file.
59       * @param suffix the suffix of the file.
60       * @return an {@code OutputStream} for writing the individual barcode.
61       * @throws IOException if the creation of the {@code OutputStream} fails.
62       */
63      OutputStream getOutputForIdent(CodeType type, EncodingConfig format, String ident, String suffix) throws IOException;
64  
65  }