1 |
|
package liquibase.util.csv.opencsv.bean; |
2 |
|
|
3 |
|
import liquibase.util.csv.opencsv.CSVReader; |
4 |
|
|
5 |
|
import java.beans.BeanInfo; |
6 |
|
import java.beans.IntrospectionException; |
7 |
|
import java.beans.Introspector; |
8 |
|
import java.beans.PropertyDescriptor; |
9 |
|
import java.io.IOException; |
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
|
|
| 0% |
Uncovered Elements: 36 (36) |
Complexity: 16 |
Complexity Density: 0.94 |
|
24 |
|
public class HeaderColumnNameMappingStrategy implements MappingStrategy { |
25 |
|
protected String[] header; |
26 |
|
protected PropertyDescriptor[] descriptors; |
27 |
|
protected Class type; |
28 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
29 |
0
|
public void captureHeader(CSVReader reader) throws IOException {... |
30 |
0
|
header = reader.readNext(); |
31 |
|
} |
32 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
33 |
0
|
public PropertyDescriptor findDescriptor(int col) throws IntrospectionException {... |
34 |
0
|
String columnName = getColumnName(col); |
35 |
0
|
return (null != columnName && columnName.trim().length() > 0) ? findDescriptor(columnName) : null; |
36 |
|
} |
37 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 3 |
Complexity Density: 3 |
|
38 |
0
|
protected String getColumnName(int col) {... |
39 |
0
|
return (null != header && col < header.length) ? header[col] : null; |
40 |
|
} |
41 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
42 |
0
|
protected PropertyDescriptor findDescriptor(String name) throws IntrospectionException {... |
43 |
0
|
if (null == descriptors) |
44 |
0
|
descriptors = loadDescriptors(getType()); |
45 |
0
|
for (int i = 0; i < descriptors.length; i++) { |
46 |
0
|
PropertyDescriptor desc = descriptors[i]; |
47 |
0
|
if (matches(name, desc)) |
48 |
0
|
return desc; |
49 |
|
} |
50 |
0
|
return null; |
51 |
|
} |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
53 |
0
|
protected boolean matches(String name, PropertyDescriptor desc) {... |
54 |
0
|
return desc.getName().equals(name); |
55 |
|
} |
56 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
57 |
0
|
protected PropertyDescriptor[] loadDescriptors(Class cls) throws IntrospectionException {... |
58 |
0
|
BeanInfo beanInfo = Introspector.getBeanInfo(cls); |
59 |
0
|
return beanInfo.getPropertyDescriptors(); |
60 |
|
} |
61 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
0
|
public Object createBean() throws InstantiationException, IllegalAccessException {... |
63 |
0
|
return type.newInstance(); |
64 |
|
} |
65 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
0
|
public Class getType() {... |
67 |
0
|
return type; |
68 |
|
} |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
0
|
public void setType(Class type) {... |
71 |
0
|
this.type = type; |
72 |
|
} |
73 |
|
} |