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 HCenterRecord 33 extends Record 34 { 35 public final static short sid = 0x83; 36 private short field_1_hcenter; 37 38 public HCenterRecord() 39 { 40 } 41 42 49 50 public HCenterRecord(short id, short size, byte [] data) 51 { 52 super(id, size, data); 53 } 54 55 63 64 public HCenterRecord(short id, short size, byte [] data, int offset) 65 { 66 super(id, size, data, offset); 67 } 68 69 protected void validateSid(short id) 70 { 71 if (id != sid) 72 { 73 throw new RecordFormatException("NOT A HCenter RECORD"); 74 } 75 } 76 77 protected void fillFields(byte [] data, short size, int offset) 78 { 79 field_1_hcenter = LittleEndian.getShort(data, 0 + offset); 80 } 81 82 86 87 public void setHCenter(boolean hc) 88 { 89 if (hc == true) 90 { 91 field_1_hcenter = 1; 92 } 93 else 94 { 95 field_1_hcenter = 0; 96 } 97 } 98 99 103 104 public boolean getHCenter() 105 { 106 return (field_1_hcenter == 1); 107 } 108 109 public String toString() 110 { 111 StringBuffer buffer = new StringBuffer (); 112 113 buffer.append("[HCENTER]\n"); 114 buffer.append(" .hcenter = ").append(getHCenter()) 115 .append("\n"); 116 buffer.append("[/HCENTER]\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, ( short ) field_1_hcenter); 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 HCenterRecord rec = new HCenterRecord(); 140 rec.field_1_hcenter = field_1_hcenter; 141 return rec; 142 } 143 } 144 | Popular Tags |