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