1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 import org.apache.poi.util.LittleEndian; 22 23 31 32 public class RefModeRecord 33 extends Record 34 { 35 public final static short sid = 0xf; 36 public final static short USE_A1_MODE = 1; 37 public final static short USE_R1C1_MODE = 0; 38 private short field_1_mode; 39 40 public RefModeRecord() 41 { 42 } 43 44 51 52 public RefModeRecord(short id, short size, byte [] data) 53 { 54 super(id, size, data); 55 } 56 57 65 66 public RefModeRecord(short id, short size, byte [] data, int offset) 67 { 68 super(id, size, data, offset); 69 } 70 71 protected void validateSid(short id) 72 { 73 if (id != sid) 74 { 75 throw new RecordFormatException("NOT An RefMode RECORD"); 76 } 77 } 78 79 protected void fillFields(byte [] data, short size, int offset) 80 { 81 field_1_mode = LittleEndian.getShort(data, 0 + offset); 82 } 83 84 91 92 public void setMode(short mode) 93 { 94 field_1_mode = mode; 95 } 96 97 103 104 public short getMode() 105 { 106 return field_1_mode; 107 } 108 109 public String toString() 110 { 111 StringBuffer buffer = new StringBuffer (); 112 113 buffer.append("[REFMODE]\n"); 114 buffer.append(" .mode = ") 115 .append(Integer.toHexString(getMode())).append("\n"); 116 buffer.append("[/REFMODE]\n"); 117 return buffer.toString(); 118 } 119 120 public int serialize(int offset, byte [] data) 121 { 122 LittleEndian.putShort(data, 0 + offset, sid); 123 LittleEndian.putShort(data, 2 + offset, ( short ) 0x2); 124 LittleEndian.putShort(data, 4 + offset, getMode()); 125 return getRecordSize(); 126 } 127 128 public int getRecordSize() 129 { 130 return 6; 131 } 132 133 public short getSid() 134 { 135 return this.sid; 136 } 137 138 public Object clone() { 139 RefModeRecord rec = new RefModeRecord(); 140 rec.field_1_mode = field_1_mode; 141 return rec; 142 } 143 } 144 | Popular Tags |