1
2
3 /* ====================================================================
4
5 * The Apache Software License, Version 1.1
6
7 *
8
9 * Copyright (c) 2002 The Apache Software Foundation. All rights
10
11 * reserved.
12
13 *
14
15 * Redistribution and use in source and binary forms, with or without
16
17 * modification, are permitted provided that the following conditions
18
19 * are met:
20
21 *
22
23 * 1. Redistributions of source code must retain the above copyright
24
25 * notice, this list of conditions and the following disclaimer.
26
27 *
28
29 * 2. Redistributions in binary form must reproduce the above copyright
30
31 * notice, this list of conditions and the following disclaimer in
32
33 * the documentation and/or other materials provided with the
34
35 * distribution.
36
37 *
38
39 * 3. The end-user documentation included with the redistribution,
40
41 * if any, must include the following acknowledgment:
42
43 * "This product includes software developed by the
44
45 * Apache Software Foundation (http://www.apache.org/)."
46
47 * Alternately, this acknowledgment may appear in the software itself,
48
49 * if and wherever such third-party acknowledgments normally appear.
50
51 *
52
53 * 4. The names "Apache" and "Apache Software Foundation" and
54
55 * "Apache POI" must not be used to endorse or promote products
56
57 * derived from this software without prior written permission. For
58
59 * written permission, please contact apache@apache.org.
60
61 *
62
63 * 5. Products derived from this software may not be called "Apache",
64
65 * "Apache POI", nor may "Apache" appear in their name, without
66
67 * prior written permission of the Apache Software Foundation.
68
69 *
70
71 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
72
73 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
74
75 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
76
77 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
78
79 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
80
81 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
82
83 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
84
85 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
86
87 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
88
89 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
90
91 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
92
93 * SUCH DAMAGE.
94
95 * ====================================================================
96
97 *
98
99 * This software consists of voluntary contributions made by many
100
101 * individuals on behalf of the Apache Software Foundation. For more
102
103 * information on the Apache Software Foundation, please see
104
105 * <http://www.apache.org/>.
106
107 */
108
109
110
111 /*
112
113 * BoolPtg.java
114
115 *
116
117 * Created on Septemeber 26, 2002, 7:37 PM
118
119 */
120
121 package org.apache.poi.hssf.record.formula;
122
123
124
125 import org.apache.poi.util.LittleEndian;
126
127 import org.apache.poi.hssf.util.SheetReferences;
128
129
130
131 /**
132
133 * Boolean (boolean)
134
135 * Stores a (java) boolean value in a formula.
136
137 * @author Paul Krause (pkrause at soundbite dot com)
138
139 * @author Andrew C. Oliver (acoliver at apache dot org)
140
141 * @author Jason Height (jheight at chariot dot net dot au)
142
143 */
144
145
146
147 public class BoolPtg
148
149 extends Ptg
150
151 {
152
153 public final static int SIZE = 2;
154
155 public final static byte sid = 0x1d;
156
157 private boolean field_1_value;
158
159
160
161 private String val;
162
163
164
165 private BoolPtg() {
166
167 //Required for clone methods
168
169 }
170
171
172
173 public BoolPtg(byte [] data, int offset)
174
175 {
176
177 field_1_value = (data[offset + 1] == 1);
178
179 }
180
181
182
183
184
185 public BoolPtg(String formulaToken) {
186
187 field_1_value = (formulaToken.equals("TRUE"));
188
189 }
190
191
192
193 public void setValue(boolean value)
194
195 {
196
197 field_1_value = value;
198
199 }
200
201
202
203 public boolean getValue()
204
205 {
206
207 return field_1_value;
208
209 }
210
211
212
213 public void writeBytes(byte [] array, int offset)
214
215 {
216
217 array[ offset + 0 ] = sid;
218
219 array[ offset + 1 ] = (byte) (field_1_value ? 1 : 0);
220
221 }
222
223
224
225 public int getSize()
226
227 {
228
229 return SIZE;
230
231 }
232
233
234
235 public String toFormulaString(SheetReferences refs)
236
237 {
238
239 return field_1_value ? "TRUE" : "FALSE";
240
241 }
242
243
244
245 public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
246
247
248
249 public Object clone() {
250
251 BoolPtg ptg = new BoolPtg();
252
253 ptg.field_1_value = field_1_value;
254
255 return ptg;
256
257 }
258
259 }
260
261 BoolPtgPtgSIZEsidfield_1_valuevalBoolPtgBoolPtgfield_1_valuedataoffsetBoolPtgformulaTokensetValuefield_1_valuevaluegetValuefield_1_valuewriteBytesarrayoffsetsidarrayoffsetfield_1_valuegetSizeSIZEtoFormulaStringSheetReferencesfield_1_valuegetDefaultOperandClassPtgCLASS_VALUEcloneBoolPtgBoolPtgptgfield_1_valuefield_1_valueptg