1 2 17 18 19 24 package org.apache.poi.hssf.record; 25 26 import org.apache.poi.util.LittleEndian; 27 28 36 37 public class BlankRecord 38 extends Record 39 implements CellValueRecordInterface, Comparable 40 { 41 public final static short sid = 0x201; 42 private int field_1_row; 44 private short field_2_col; 45 private short field_3_xf; 46 47 48 49 public BlankRecord() 50 { 51 } 52 53 60 61 public BlankRecord(short id, short size, byte [] data) 62 { 63 super(id, size, data); 64 } 65 66 74 75 public BlankRecord(short id, short size, byte [] data, int offset) 76 { 77 super(id, size, data, offset); 78 } 79 80 protected void fillFields(byte [] data, short size, int offset) 81 { 82 field_1_row = LittleEndian.getUShort(data, 0 + offset); 84 field_2_col = LittleEndian.getShort(data, 2 + offset); 85 field_3_xf = LittleEndian.getShort(data, 4 + offset); 86 } 87 88 94 95 protected void validateSid(short id) 96 { 97 if (id != sid) 98 { 99 throw new RecordFormatException("NOT A BLANKRECORD!"); 100 } 101 } 102 103 107 108 public void setRow(int row) 110 { 111 field_1_row = row; 112 } 113 114 119 120 public int getRow() 122 { 123 return field_1_row; 124 } 125 126 131 132 public short getColumn() 133 { 134 return field_2_col; 135 } 136 137 143 144 public void setXFIndex(short xf) 145 { 146 field_3_xf = xf; 147 } 148 149 154 155 public short getXFIndex() 156 { 157 return field_3_xf; 158 } 159 160 165 166 public void setColumn(short col) 167 { 168 field_2_col = col; 169 } 170 171 public boolean isBefore(CellValueRecordInterface i) 172 { 173 if (this.getRow() > i.getRow()) 174 { 175 return false; 176 } 177 if ((this.getRow() == i.getRow()) 178 && (this.getColumn() > i.getColumn())) 179 { 180 return false; 181 } 182 if ((this.getRow() == i.getRow()) 183 && (this.getColumn() == i.getColumn())) 184 { 185 return false; 186 } 187 return true; 188 } 189 190 public boolean isAfter(CellValueRecordInterface i) 191 { 192 if (this.getRow() < i.getRow()) 193 { 194 return false; 195 } 196 if ((this.getRow() == i.getRow()) 197 && (this.getColumn() < i.getColumn())) 198 { 199 return false; 200 } 201 if ((this.getRow() == i.getRow()) 202 && (this.getColumn() == i.getColumn())) 203 { 204 return false; 205 } 206 return true; 207 } 208 209 public boolean isEqual(CellValueRecordInterface i) 210 { 211 return ((this.getRow() == i.getRow()) 212 && (this.getColumn() == i.getColumn())); 213 } 214 215 public boolean isInValueSection() 216 { 217 return true; 218 } 219 220 public boolean isValue() 221 { 222 return true; 223 } 224 225 228 229 public short getSid() 230 { 231 return BlankRecord.sid; 232 } 233 234 public String toString() 235 { 236 StringBuffer buffer = new StringBuffer (); 237 238 buffer.append("[BLANK]\n"); 239 buffer.append("row = ").append(Integer.toHexString(getRow())) 240 .append("\n"); 241 buffer.append("col = ").append(Integer.toHexString(getColumn())) 242 .append("\n"); 243 buffer.append("xf = ") 244 .append(Integer.toHexString(getXFIndex())).append("\n"); 245 buffer.append("[/BLANK]\n"); 246 return buffer.toString(); 247 } 248 249 256 257 public int serialize(int offset, byte [] data) 258 { 259 LittleEndian.putShort(data, 0 + offset, sid); 260 LittleEndian.putShort(data, 2 + offset, ( short ) 6); 261 LittleEndian.putShort(data, 4 + offset, ( short ) getRow()); 263 LittleEndian.putShort(data, 6 + offset, getColumn()); 264 LittleEndian.putShort(data, 8 + offset, getXFIndex()); 265 return getRecordSize(); 266 } 267 268 public int getRecordSize() 269 { 270 return 10; 271 } 272 273 public int compareTo(Object obj) 274 { 275 CellValueRecordInterface loc = ( CellValueRecordInterface ) obj; 276 277 if ((this.getRow() == loc.getRow()) 278 && (this.getColumn() == loc.getColumn())) 279 { 280 return 0; 281 } 282 if (this.getRow() < loc.getRow()) 283 { 284 return -1; 285 } 286 if (this.getRow() > loc.getRow()) 287 { 288 return 1; 289 } 290 if (this.getColumn() < loc.getColumn()) 291 { 292 return -1; 293 } 294 if (this.getColumn() > loc.getColumn()) 295 { 296 return 1; 297 } 298 return -1; 299 } 300 301 public boolean equals(Object obj) 302 { 303 if (!(obj instanceof CellValueRecordInterface)) 304 { 305 return false; 306 } 307 CellValueRecordInterface loc = ( CellValueRecordInterface ) obj; 308 309 if ((this.getRow() == loc.getRow()) 310 && (this.getColumn() == loc.getColumn())) 311 { 312 return true; 313 } 314 return false; 315 } 316 317 public Object clone() { 318 BlankRecord rec = new BlankRecord(); 319 rec.field_1_row = field_1_row; 320 rec.field_2_col = field_2_col; 321 rec.field_3_xf = field_3_xf; 322 return rec; 323 } 324 } 325 | Popular Tags |