1
2
3
4
5
6
7
8
9
10
11
12
13
14 package olg.csv.bean.impl;
15
16 import olg.csv.base.Cell;
17 import olg.csv.bean.ICellProcessor;
18
19
20
21
22
23
24
25
26
27
28 public final class CellProcessor<B> implements Comparable<CellProcessor<B>>, ICellProcessor<B> {
29
30
31
32 private int rang;
33
34
35
36
37 private String name;
38
39
40
41
42 private PropertyFormatter propertyFormatter;
43
44
45
46
47
48
49
50
51
52
53
54 public CellProcessor(String rang, String name, PropertyFormatter propertyFormatter) {
55 super();
56 this.rang = Cell.fromSheetCellNumber(rang);
57 this.name = name;
58 this.propertyFormatter = propertyFormatter;
59 }
60
61
62
63
64
65
66 public int getRang() {
67 return rang;
68 }
69
70
71
72
73
74
75 public String getName() {
76 return name;
77 }
78
79
80
81
82
83
84
85 public PropertyFormatter getPropertyFormatter() {
86 return propertyFormatter;
87 }
88
89
90
91
92
93
94
95 public void setRang(int rang) {
96 this.rang = rang;
97 }
98
99
100
101
102
103
104
105 public void setName(String name) {
106 this.name = name;
107 }
108
109
110
111
112
113
114
115 public void setPropertyFormatter(PropertyFormatter propertyFormatter) {
116 this.propertyFormatter = propertyFormatter;
117 }
118
119
120
121 public int compareTo(CellProcessor<B> columnFormatter) {
122 return this.rang - columnFormatter.rang;
123 }
124
125 @Override
126 public int hashCode() {
127 final int prime = 31;
128 int result = 1;
129 result = prime * result + ((name == null) ? 0 : name.hashCode());
130 result = prime * result + ((propertyFormatter == null) ? 0 : propertyFormatter.hashCode());
131 result = prime * result + rang;
132 return result;
133 }
134
135 @Override
136 public boolean equals(Object obj) {
137 if (this == obj) {
138 return true;
139 }
140 if (obj == null) {
141 return false;
142 }
143 if (getClass() != obj.getClass()) {
144 return false;
145 }
146 CellProcessor<?> other = (CellProcessor<?>) obj;
147 if (name == null) {
148 if (other.name != null) {
149 return false;
150 }
151 } else if (!name.equals(other.name)) {
152 return false;
153 }
154 if (propertyFormatter == null) {
155 if (other.propertyFormatter != null) {
156 return false;
157 }
158 } else if (!propertyFormatter.equals(other.propertyFormatter)) {
159 return false;
160 }
161 if (rang != other.rang) {
162 return false;
163 }
164 return true;
165 }
166
167
168
169
170 public Cell transform(B e) {
171 return new Cell(this.getRang(), this.getPropertyFormatter().toString(e));
172 }
173
174
175
176
177 public Cell getHeader() {
178 return new Cell(this.getRang(), this.getName());
179 }
180 }