1 package com.github.mygreen.cellformatter;
2
3 import java.util.Date;
4 import java.util.TimeZone;
5
6 import com.github.mygreen.cellformatter.lang.MSColor;
7
8
9
10
11
12
13
14
15
16
17 public class CellFormatResult {
18
19
20
21
22 private Object value;
23
24
25
26
27 private String text;
28
29
30
31
32 private MSColor textColor;
33
34
35
36
37 private String sectionPattern;
38
39
40
41
42 private FormatCellType cellType;
43
44
45
46
47
48
49 public Object getValue() {
50 return value;
51 }
52
53
54
55
56
57
58 public double getValueAsDoulbe() {
59 return (double) value;
60 }
61
62
63
64
65
66
67
68 public Date getValueAsDate() {
69 return getValueAsDate(null);
70 }
71
72
73
74
75
76
77
78
79
80 public Date getValueAsDate(final TimeZone tz) {
81 long time = ((Date) value).getTime();
82 long offset;
83 if(tz == null) {
84 offset = TimeZone.getDefault().getRawOffset();
85 } else {
86 offset = tz.getRawOffset();
87 }
88
89 return new Date(time - offset);
90 }
91
92
93
94
95
96
97 public String getValueAsString() {
98 return (String) value;
99 }
100
101
102
103
104
105
106 public boolean getValueAsBoolean() {
107 return (boolean) value;
108 }
109
110
111
112
113
114 public boolean isBlank() {
115 return getCellType() == FormatCellType.Blank;
116 }
117
118
119
120
121
122 public boolean isBoolean() {
123 return getCellType() == FormatCellType.Boolean;
124 }
125
126
127
128
129
130 public boolean isDate() {
131 return getCellType() == FormatCellType.Date;
132 }
133
134
135
136
137
138 public boolean isNumber() {
139 return getCellType() == FormatCellType.Number;
140 }
141
142
143
144
145
146 public boolean isText() {
147 return getCellType() == FormatCellType.Text;
148 }
149
150
151
152
153
154 public boolean isError() {
155 return getCellType() == FormatCellType.Error;
156 }
157
158
159
160
161
162 public void setValue(Object value) {
163 this.value = value;
164 }
165
166
167
168
169
170 public MSColor getTextColor() {
171 return textColor;
172 }
173
174
175
176
177
178 public void setTextColor(MSColor textColor) {
179 this.textColor = textColor;
180 }
181
182
183
184
185
186 public String getText() {
187 return text;
188 }
189
190
191
192
193
194 public void setText(String text) {
195 this.text = text;
196 }
197
198
199
200
201
202 public String getSectionPattern() {
203 return sectionPattern;
204 }
205
206
207
208
209
210 public void setSectionPattern(String sectionPattern) {
211 this.sectionPattern = sectionPattern;
212 }
213
214
215
216
217
218
219
220 public FormatCellType getCellType() {
221 return cellType;
222 }
223
224
225
226
227
228 public void setCellType(FormatCellType cellType) {
229 this.cellType = cellType;
230 }
231 }