View Javadoc
1   /*
2    * #%L
3    * Coser :: Business
4    * %%
5    * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
6    * %%
7    * This program is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU Lesser General Public License as 
9    * published by the Free Software Foundation, either version 3 of the 
10   * License, or (at your option) any later version.
11   * 
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Lesser Public License for more details.
16   * 
17   * You should have received a copy of the GNU General Lesser Public 
18   * License along with this program.  If not, see
19   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
20   * #L%
21   */
22  
23  package fr.ifremer.coser.storage;
24  
25  import java.io.Serializable;
26  import java.util.Iterator;
27  
28  /**
29   * Data storage utiliser pour manipuler dans l'application des
30   * tableau de String, mais les stocker en back différement.
31   * 
32   * Cette interface respecte globalement l'interface d'une {@link java.util.List}.
33   * 
34   * @author chatellier
35   * @version $Revision$
36   * 
37   * Last update : $Date$
38   * By : $Author$
39   */
40  public interface DataStorage extends Iterable<String[]> , Serializable {
41  
42      /**
43       * Add new data into storage.
44       * 
45       * @param data data to add
46       */
47      public void add(String[] data);
48      
49      /**
50       * Add new data into storage.
51       * 
52       * @param index index to insert data
53       * @param data data to add
54       */
55      public void add(int index, String[] data);
56  
57      /**
58       * Get data at specified index.
59       * 
60       * @param index index
61       * @return data at index
62       */
63      public String[] get(int index);
64  
65      /**
66       * Storage size.
67       * 
68       * @return storage size
69       */
70      public int size();
71  
72      /**
73       * Replace data at specified index.
74       * 
75       * @param index index
76       * @param data data to set
77       * @return previous value
78       */
79      public String[] set(int index, String[] data);
80  
81      /**
82       * Remove value at index.
83       * 
84       * @param index index
85       * @return removed value
86       */
87      public String[] remove(int index);
88  
89      /**
90       * Real storage index of lineNumber.
91       * 
92       * @param lineNumber line number
93       * @return storage index
94       */
95      public int indexOf(String lineNumber);
96  
97      /**
98       * Return a new iterator, but skip first iterator element (csv header)
99       * by calling {@code next()} once.
100      * 
101      * @param skipFirstLine if {@code true}, skip first line
102      * @return an Iterator.
103      */
104     public Iterator<String[]> iterator(boolean skipFirstLine);
105 }