View Javadoc
1   /*
2    * Copyright (C) 2010-2014 Hamburg Sud and the contributors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.aludratest.content.flat;
17  
18  import java.io.Reader;
19  import java.io.Writer;
20  import java.util.Locale;
21  
22  import org.aludratest.content.ContentHandler;
23  import org.aludratest.content.flat.data.FlatFileBeanData;
24  import org.aludratest.content.flat.data.RowTypeData;
25  
26  /**
27   * Interface for reading and writing flat files.
28   * @author Volker Bergmann
29   */
30  public interface FlatContent extends ContentHandler {
31  
32      /** Sets the locale of the content handler.
33       *  @param locale the locale to set */
34      void setLocale(Locale locale);
35  
36      /** Creates a writer for persisting 
37       *  FlatFileBeans or JavaBean data structures. 
38       *  @param out the writer to use for persisting the flat file content 
39       *  @return the id of the new writer */
40      Object createWriter(Writer out);
41  
42      /** Appends a row to the flat file writer denoted by the writerId. 
43       *  @param rowBean the FlatFileBean holding the data 
44       *  @param writerId the id of the writer with which to store the formatted text */
45      void writeRow(Object rowBean, Object writerId);
46  
47      /** Closes the writer and returns its content as string. 
48       *  @param writerId the id of the writer to close */
49      void closeWriter(Object writerId);
50  
51      /** Creates a reader object for reading JavaBeans. 
52       *  @param source the source reader that provides the flat file's character data
53       *  @return the id of the writer */
54      Object createReader(Reader source);
55  
56      /** Adds a RowType to a BeanFlatFileReader. 
57       *  @param rowType a {@link RowTypeData} for reader setup
58       *  @param readerId the id of the writer */
59      public void addRowType(RowTypeData rowType, Object readerId);
60  
61      /** Reads a flat file cell and provides it as Java object. 
62       *  @param readerId the id of the reader 
63       *  @return the id of the new reader */
64      FlatFileBeanData readRow(Object readerId);
65  
66      /** Closes a reader. 
67       *  @param readerId the id of the reader to close */
68      void closeReader(Object readerId);
69  
70  }