1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.supercsv.util;
17
18 import java.io.Serializable;
19 import java.util.ArrayList;
20 import java.util.List;
21
22
23
24
25
26
27
28
29
30
31 public final class CsvContext implements Serializable {
32
33 private static final long serialVersionUID = 1L;
34
35
36 private int lineNumber;
37
38
39 private int rowNumber;
40
41
42 private int columnNumber;
43
44
45 private List<Object> rowSource;
46
47
48
49
50
51
52
53
54
55
56
57 public CsvContext(final int lineNumber, final int rowNumber, final int columnNumber) {
58 this.lineNumber = lineNumber;
59 this.rowNumber = rowNumber;
60 this.columnNumber = columnNumber;
61 }
62
63
64
65
66
67
68 public CsvContext(final CsvContext c) {
69 this (c.lineNumber, c.rowNumber, c.columnNumber);
70
71 if (c.rowSource != null) {
72
73
74
75 this.rowSource = new ArrayList<Object>(c.rowSource);
76 }
77 }
78
79
80
81
82 public int getLineNumber() {
83 return lineNumber;
84 }
85
86
87
88
89
90 public void setLineNumber(int lineNumber) {
91 this.lineNumber = lineNumber;
92 }
93
94
95
96
97 public int getRowNumber() {
98 return rowNumber;
99 }
100
101
102
103
104
105 public void setRowNumber(int rowNumber) {
106 this.rowNumber = rowNumber;
107 }
108
109
110
111
112 public int getColumnNumber() {
113 return columnNumber;
114 }
115
116
117
118
119
120 public void setColumnNumber(int columnNumber) {
121 this.columnNumber = columnNumber;
122 }
123
124
125
126
127 public List<Object> getRowSource() {
128 return rowSource;
129 }
130
131
132
133
134
135 public void setRowSource(List<Object> rowSource) {
136 this.rowSource = rowSource;
137 }
138
139
140
141
142 @Override
143 public String toString() {
144 return String.format("{lineNo=%d, rowNo=%d, columnNo=%d, rowSource=%s}", lineNumber, rowNumber, columnNumber,
145 rowSource);
146 }
147
148
149
150
151 @Override
152 public int hashCode() {
153 final int prime = 31;
154 int result = 1;
155 result = prime * result + columnNumber;
156 result = prime * result + rowNumber;
157 result = prime * result + lineNumber;
158 result = prime * result + ((rowSource == null) ? 0 : rowSource.hashCode());
159 return result;
160 }
161
162
163
164
165 @Override
166 public boolean equals(Object obj) {
167 if( this == obj ) {
168 return true;
169 }
170 if( obj == null ) {
171 return false;
172 }
173 if( getClass() != obj.getClass() ) {
174 return false;
175 }
176 final CsvContext other = (CsvContext) obj;
177 if( columnNumber != other.columnNumber ) {
178 return false;
179 }
180 if( rowNumber != other.rowNumber ) {
181 return false;
182 }
183 if( lineNumber != other.lineNumber ) {
184 return false;
185 }
186 if( rowSource == null ) {
187 if( other.rowSource != null ) {
188 return false;
189 }
190 } else if( !rowSource.equals(other.rowSource) ) {
191 return false;
192 }
193 return true;
194 }
195
196 }