View Javadoc

1   package au.com.bytecode.opencsv.bean;
2   
3   
4   /**
5    Copyright 2007 Kyle Miller.
6   
7    Licensed under the Apache License, Version 2.0 (the "License");
8    you may not use this file except in compliance with the License.
9    You may obtain a copy of the License at
10  
11   http://www.apache.org/licenses/LICENSE-2.0
12  
13   Unless required by applicable law or agreed to in writing, software
14   distributed under the License is distributed on an "AS IS" BASIS,
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   See the License for the specific language governing permissions and
17   limitations under the License.
18   */
19  
20  import au.com.bytecode.opencsv.CSVReader;
21  
22  import java.beans.IntrospectionException;
23  import java.beans.PropertyDescriptor;
24  import java.io.IOException;
25  
26  public interface MappingStrategy<T> {
27  
28      /**
29       * Implementation will have to return a property descriptor from a bean based on the current column.
30       * @param col the column to find the description for
31       * @throws java.beans.IntrospectionException
32       * @return the related PropertyDescriptor
33       */
34      public abstract PropertyDescriptor findDescriptor(int col) throws IntrospectionException;
35  
36      public abstract T createBean() throws InstantiationException, IllegalAccessException;
37  
38      /**
39       * Implementation of this method can grab the header line before parsing begins to use to map columns
40       * to bean properties.
41       * @param reader the CSVReader to use for header parsing
42       * @throws java.io.IOException if parsing fails
43       */
44      public void captureHeader(CSVReader reader) throws IOException;
45  
46  }