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.separatedfile;
17  
18  import org.aludratest.content.separated.data.SeparatedFileBeanData;
19  import org.aludratest.service.Interaction;
20  
21  /**
22   * {@link Interaction} interface of the {@link SeparatedFileService}.
23   * @author Volker Bergmann
24   */
25  public interface SeparatedFileInteraction extends Interaction {
26  
27      /** Polls the file system until a file at the given path is found 
28       *  or a timeout occurs. 
29       *  @param elementType 
30       *  @param filePath the full path of the requested file */
31      void waitUntilExists(String elementType, String filePath);
32  
33      /** Polls the file system until no file is found at the given path.
34       *  @param filePath */
35      void waitUntilNotExists(String filePath);
36  
37      /** Deletes a file.
38       *  @param filePath the path of the file to delete */
39      public void delete(String filePath);
40  
41      /** Creates a writer for persisting 
42       *  SeparatedFileBeans or JavaBean data structures. 
43       *  @param filePath the path of the file to write
44       *  @param overwrite flag that indicates whether pre-existing files may be overwritten
45       *  @param beanClass the type of the bean Objects to write
46       *  @param separator the separator character to use
47       * @param header 
48       *  @return the id of the created writer */
49      Object createWriter(String filePath, boolean overwrite, 
50              Class<? extends SeparatedFileBeanData> beanClass, char separator, String header);
51  
52      /** Writes an object as separated file row. 
53       *  @param bean a SeparatedFileBean to write
54       *  @param writerId the id of the writer */
55      void writeRow(SeparatedFileBeanData bean, Object writerId);
56  
57      /** Closes the writer. 
58       *  @param writerId the id of the writer */
59      void closeWriter(Object writerId);
60  
61      /** Creates a reader for reading JavaBeans. 
62       *  @param  filePath the path of the file to read
63       *  @param beanClass the type of the bean Objects to write
64       *  @param separator the separator character to use
65       *  @return the id of the created reader */
66      Object createReader(String filePath, 
67              Class<? extends SeparatedFileBeanData> beanClass, char separator);
68  
69      /**
70       * Reads a header line from a separated file.
71       * @param readerId
72       * @return the content of the header
73       */
74      String readHeader(Object readerId);
75  
76      /** Reads a separated file row and provides it as Java object. 
77       *  @param  readerId the id of the reader
78       *  @return a SeparatedFileBean holding the content of the parsed separated file row */
79      SeparatedFileBeanData readRow(Object readerId);
80  
81      /** Closes the reader. 
82       *  @param readerId the id of the reader */
83      void closeReader(Object readerId);
84  
85  }