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.service.flatfile;
17  
18  import org.aludratest.content.flat.data.FlatFileBeanData;
19  import org.aludratest.content.flat.data.RowTypeData;
20  import org.aludratest.service.Interaction;
21  
22  /**
23   * {@link Interaction} interface of the {@link FlatFileService}.
24   * @author Volker Bergmann
25   */
26  public interface FlatFileInteraction extends Interaction {
27  
28      /** Polls the file system until a file at the given path is found 
29       *  or a timeout occurs. 
30       *  @param elementType 
31       *  @param filePath the full path of the requested file */
32      void waitUntilExists(String elementType, String filePath);
33  
34      /** Polls the file system until no file is found at the given path.
35       *  @param filePath */
36      void waitUntilNotExists(String filePath);
37  
38      /** Deletes a file.
39       *  @param filePath the path of the file to delete */
40      public void delete(String filePath);
41  
42      /** Creates a writer for persisting 
43       *  FlatFileBeans or JavaBean data structures. 
44       *  @param filePath the path of the file to write
45       *  @param overwrite flag that indicates whether pre-existing files may be overwritten
46       *  @return the id of the created writer */
47      Object createWriter(String filePath, boolean overwrite);
48  
49      /** Writes an object as flat file row. 
50       *  @param bean a FlatFileBean to write
51       *  @param writerId the id of the writer */
52      void writeRow(Object bean, Object writerId);
53  
54      /** Closes the writer. 
55       *  @param writerId the id of the writer */
56      void closeWriter(Object writerId);
57  
58      /** Creates a reader for reading JavaBeans. 
59       *  @param  filePath the path of the file to read
60       *  @return the id of the created reader */
61      Object createReader(String filePath);
62  
63      /** Adds a RowType to a BeanFlatFileReader. 
64       *  @param rowType a {@link RowTypeData} to be applied by the flat file reader
65       *  @param readerId the id of the reader */
66      void addRowType(RowTypeData rowType, Object readerId);
67  
68      /** Reads a flat file row and provides it as Java object. 
69       *  @param  readerId the id of the reader
70       *  @return a FlatFileBean holding the content of the parsed flat file row */
71      FlatFileBeanData readRow(Object readerId);
72  
73      /** Closes the reader. 
74       *  @param readerId the id of the reader */
75      void closeReader(Object readerId);
76  
77  }