1 /
55
56 package org.apache.poi.hssf.record;
57
58 import org.apache.poi.util.LittleEndian;
59
60
68
69 public class LabelSSTRecord
70 extends Record
71 implements CellValueRecordInterface, Comparable
72 {
73 public final static short sid = 0xfd;
74 private short field_1_row;
75 private short field_2_column;
76 private short field_3_xf_index;
77 private int field_4_sst_index;
78
79 public LabelSSTRecord()
80 {
81 }
82
83
90
91 public LabelSSTRecord(short id, short size, byte [] data)
92 {
93 super(id, size, data);
94 }
95
96
104
105 public LabelSSTRecord(short id, short size, byte [] data, int offset)
106 {
107 super(id, size, data, offset);
108 }
109
110 protected void validateSid(short id)
111 {
112 if (id != sid)
113 {
114 throw new RecordFormatException("NOT A valid LabelSST RECORD");
115 }
116 }
117
118 protected void fillFields(byte [] data, short size, int offset)
119 {
120 field_1_row = LittleEndian.getShort(data, 0 + offset);
121 field_2_column = LittleEndian.getShort(data, 2 + offset);
122 field_3_xf_index = LittleEndian.getShort(data, 4 + offset);
123 field_4_sst_index = LittleEndian.getInt(data, 6 + offset);
124 }
125
126 public void setRow(short row)
127 {
128 field_1_row = row;
129 }
130
131 public void setColumn(short col)
132 {
133 field_2_column = col;
134 }
135
136
142
143 public void setXFIndex(short index)
144 {
145 field_3_xf_index = index;
146 }
147
148
154
155 public void setSSTIndex(int index)
156 {
157 field_4_sst_index = index;
158 }
159
160 public short getRow()
161 {
162 return field_1_row;
163 }
164
165 public short getColumn()
166 {
167 return field_2_column;
168 }
169
170
176
177 public short getXFIndex()
178 {
179 return field_3_xf_index;
180 }
181
182
188
189 public int getSSTIndex()
190 {
191 return field_4_sst_index;
192 }
193
194 public String toString()
195 {
196 StringBuffer buffer = new StringBuffer();
197
198 buffer.append("[LABELSST]\n");
199 buffer.append(" .row = ")
200 .append(Integer.toHexString(getRow())).append("\n");
201 buffer.append(" .column = ")
202 .append(Integer.toHexString(getColumn())).append("\n");
203 buffer.append(" .xfindex = ")
204 .append(Integer.toHexString(getXFIndex())).append("\n");
205 buffer.append(" .sstindex = ")
206 .append(Integer.toHexString(getSSTIndex())).append("\n");
207 buffer.append("[/LABELSST]\n");
208 return buffer.toString();
209 }
210
211 public int serialize(int offset, byte [] data)
212 {
213 LittleEndian.putShort(data, 0 + offset, sid);
214 LittleEndian.putShort(data, 2 + offset, ( short ) 10);
215 LittleEndian.putShort(data, 4 + offset, getRow());
216 LittleEndian.putShort(data, 6 + offset, getColumn());
217 LittleEndian.putShort(data, 8 + offset, getXFIndex());
218 LittleEndian.putInt(data, 10 + offset, getSSTIndex());
219 return getRecordSize();
220 }
221
222 public int getRecordSize()
223 {
224 return 14;
225 }
226
227 public short getSid()
228 {
229 return this.sid;
230 }
231
232 public boolean isBefore(CellValueRecordInterface i)
233 {
234 if (this.getRow() > i.getRow())
235 {
236 return false;
237 }
238 if ((this.getRow() == i.getRow())
239 && (this.getColumn() > i.getColumn()))
240 {
241 return false;
242 }
243 if ((this.getRow() == i.getRow())
244 && (this.getColumn() == i.getColumn()))
245 {
246 return false;
247 }
248 return true;
249 }
250
251 public boolean isAfter(CellValueRecordInterface i)
252 {
253 if (this.getRow() < i.getRow())
254 {
255 return false;
256 }
257 if ((this.getRow() == i.getRow())
258 && (this.getColumn() < i.getColumn()))
259 {
260 return false;
261 }
262 if ((this.getRow() == i.getRow())
263 && (this.getColumn() == i.getColumn()))
264 {
265 return false;
266 }
267 return true;
268 }
269
270 public boolean isEqual(CellValueRecordInterface i)
271 {
272 return ((this.getRow() == i.getRow())
273 && (this.getColumn() == i.getColumn()));
274 }
275
276 public boolean isInValueSection()
277 {
278 return true;
279 }
280
281 public boolean isValue()
282 {
283 return true;
284 }
285
286 public int compareTo(Object obj)
287 {
288 CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
289
290 if ((this.getRow() == loc.getRow())
291 && (this.getColumn() == loc.getColumn()))
292 {
293 return 0;
294 }
295 if (this.getRow() < loc.getRow())
296 {
297 return -1;
298 }
299 if (this.getRow() > loc.getRow())
300 {
301 return 1;
302 }
303 if (this.getColumn() < loc.getColumn())
304 {
305 return -1;
306 }
307 if (this.getColumn() > loc.getColumn())
308 {
309 return 1;
310 }
311 return -1;
312 }
313
314 public boolean equals(Object obj)
315 {
316 if (!(obj instanceof CellValueRecordInterface))
317 {
318 return false;
319 }
320 CellValueRecordInterface loc = ( CellValueRecordInterface ) obj;
321
322 if ((this.getRow() == loc.getRow())
323 && (this.getColumn() == loc.getColumn()))
324 {
325 return true;
326 }
327 return false;
328 }
329 }
330