1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 import org.apache.poi.util.LittleEndian; 22 23 32 33 public class LabelSSTRecord 34 extends Record 35 implements CellValueRecordInterface, Comparable 36 { 37 public final static short sid = 0xfd; 38 private int field_1_row; 40 private short field_2_column; 41 private short field_3_xf_index; 42 private int field_4_sst_index; 43 44 public LabelSSTRecord() 45 { 46 } 47 48 55 56 public LabelSSTRecord(short id, short size, byte [] data) 57 { 58 super(id, size, data); 59 } 60 61 69 70 public LabelSSTRecord(short id, short size, byte [] data, int offset) 71 { 72 super(id, size, data, offset); 73 } 74 75 protected void validateSid(short id) 76 { 77 if (id != sid) 78 { 79 throw new RecordFormatException("NOT A valid LabelSST RECORD"); 80 } 81 } 82 83 protected void fillFields(byte [] data, short size, int offset) 84 { 85 field_1_row = LittleEndian.getUShort(data, 0 + offset); 87 field_2_column = LittleEndian.getShort(data, 2 + offset); 88 field_3_xf_index = LittleEndian.getShort(data, 4 + offset); 89 field_4_sst_index = LittleEndian.getInt(data, 6 + offset); 90 } 91 92 public void setRow(int row) 94 { 95 field_1_row = row; 96 } 97 98 public void setColumn(short col) 99 { 100 field_2_column = col; 101 } 102 103 109 110 public void setXFIndex(short index) 111 { 112 field_3_xf_index = index; 113 } 114 115 121 122 public void setSSTIndex(int index) 123 { 124 field_4_sst_index = index; 125 } 126 127 public int getRow() 129 { 130 return field_1_row; 131 } 132 133 public short getColumn() 134 { 135 return field_2_column; 136 } 137 138 144 145 public short getXFIndex() 146 { 147 return field_3_xf_index; 148 } 149 150 156 157 public int getSSTIndex() 158 { 159 return field_4_sst_index; 160 } 161 162 public String toString() 163 { 164 StringBuffer buffer = new StringBuffer (); 165 166 buffer.append("[LABELSST]\n"); 167 buffer.append(" .row = ") 168 .append(Integer.toHexString(getRow())).append("\n"); 169 buffer.append(" .column = ") 170 .append(Integer.toHexString(getColumn())).append("\n"); 171 buffer.append(" .xfindex = ") 172 .append(Integer.toHexString(getXFIndex())).append("\n"); 173 buffer.append(" .sstindex = ") 174 .append(Integer.toHexString(getSSTIndex())).append("\n"); 175 buffer.append("[/LABELSST]\n"); 176 return buffer.toString(); 177 } 178 179 public int serialize(int offset, byte [] data) 180 { 181 LittleEndian.putShort(data, 0 + offset, sid); 182 LittleEndian.putShort(data, 2 + offset, ( short ) 10); 183 LittleEndian.putShort(data, 4 + offset, ( short )getRow()); 185 LittleEndian.putShort(data, 6 + offset, getColumn()); 186 LittleEndian.putShort(data, 8 + offset, getXFIndex()); 187 LittleEndian.putInt(data, 10 + offset, getSSTIndex()); 188 return getRecordSize(); 189 } 190 191 public int getRecordSize() 192 { 193 return 14; 194 } 195 196 public short getSid() 197 { 198 return this.sid; 199 } 200 201 public boolean isBefore(CellValueRecordInterface i) 202 { 203 if (this.getRow() > i.getRow()) 204 { 205 return false; 206 } 207 if ((this.getRow() == i.getRow()) 208 && (this.getColumn() > i.getColumn())) 209 { 210 return false; 211 } 212 if ((this.getRow() == i.getRow()) 213 && (this.getColumn() == i.getColumn())) 214 { 215 return false; 216 } 217 return true; 218 } 219 220 public boolean isAfter(CellValueRecordInterface i) 221 { 222 if (this.getRow() < i.getRow()) 223 { 224 return false; 225 } 226 if ((this.getRow() == i.getRow()) 227 && (this.getColumn() < i.getColumn())) 228 { 229 return false; 230 } 231 if ((this.getRow() == i.getRow()) 232 && (this.getColumn() == i.getColumn())) 233 { 234 return false; 235 } 236 return true; 237 } 238 239 public boolean isEqual(CellValueRecordInterface i) 240 { 241 return ((this.getRow() == i.getRow()) 242 && (this.getColumn() == i.getColumn())); 243 } 244 245 public boolean isInValueSection() 246 { 247 return true; 248 } 249 250 public boolean isValue() 251 { 252 return true; 253 } 254 255 public int compareTo(Object obj) 256 { 257 CellValueRecordInterface loc = ( CellValueRecordInterface ) obj; 258 259 if ((this.getRow() == loc.getRow()) 260 && (this.getColumn() == loc.getColumn())) 261 { 262 return 0; 263 } 264 if (this.getRow() < loc.getRow()) 265 { 266 return -1; 267 } 268 if (this.getRow() > loc.getRow()) 269 { 270 return 1; 271 } 272 if (this.getColumn() < loc.getColumn()) 273 { 274 return -1; 275 } 276 if (this.getColumn() > loc.getColumn()) 277 { 278 return 1; 279 } 280 return -1; 281 } 282 283 public boolean equals(Object obj) 284 { 285 if (!(obj instanceof CellValueRecordInterface)) 286 { 287 return false; 288 } 289 CellValueRecordInterface loc = ( CellValueRecordInterface ) obj; 290 291 if ((this.getRow() == loc.getRow()) 292 && (this.getColumn() == loc.getColumn())) 293 { 294 return true; 295 } 296 return false; 297 } 298 299 public Object clone() { 300 LabelSSTRecord rec = new LabelSSTRecord(); 301 rec.field_1_row = field_1_row; 302 rec.field_2_column = field_2_column; 303 rec.field_3_xf_index = field_3_xf_index; 304 rec.field_4_sst_index = field_4_sst_index; 305 return rec; 306 } 307 } 308 | Popular Tags |