View Javadoc
1   /*
2    * Copyright 2009 Olivier Godineau
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at http://www.apache.org/licenses/LICENSE-2.0
7    * 
8    * Unless required by applicable law or agreed to in writing, software
9    * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11   * License for the specific language governing permissions and limitations under
12   * the License.
13   */
14  package olg.csv.base;
15  
16  import java.io.Closeable;
17  
18  /**
19   * Writer Interface.
20   * 
21   * @author Olivier Godineau
22   * 
23   */
24  public interface IWriter extends Closeable {
25  
26  	/**
27  	 * Adds a row.
28  	 * 
29  	 * <p>
30  	 * The first row allows to define the size used along writing unless
31  	 * {@link #addLine(String[])} had been used first.
32  	 * </p>
33  	 * <p>
34  	 * Throws a WriterException when row size differs from initial size or row
35  	 * num is lesser than the expected next number line. Or if I/O error occurs
36  	 * during writing.
37  	 * </p>
38  	 * 
39  	 * @param row
40  	 *            the row. It's possible to use a row with no cells. In this
41  	 *            case, an empty line(a line wich all fields are null) is added.
42  	 *            It's possible to use a row with a num greater than the
43  	 *            expected number. In this case, empty lines are wroten as much
44  	 *            as necessary. It's possible to use row which all cells are not
45  	 *            specified. In this case the missing cells are added as empty
46  	 *            cells. Must be not null with cells correctly ordered and
47  	 *            size>0.
48  	 */
49  	void addRow(Row row);
50  
51  	/**
52  	 * Adds a row from the given String array. The first time this method define
53  	 * the size ( as the given string array length) used along writing unless
54  	 * {@link #addRow(Row)} had been used first.
55  	 * <p>
56  	 * Throws a WriterException when line size differs from initial size.
57  	 * </p>
58  	 * 
59  	 * @param values
60  	 *            the row. Must be not <code>null</code> with length >0. .
61  	 * 
62  	 */
63  	void addLine(String[] values);
64  
65  	/**
66  	 * Indicates if the file has a headers line.
67  	 * 
68  	 * @return true if the file has a headers line.
69  	 */
70  	boolean isWithHeaders();
71  }