1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 import org.apache.poi.util.LittleEndian; 22 23 30 31 public class CodepageRecord 32 extends Record 33 { 34 public final static short sid = 0x42; 35 private short field_1_codepage; 37 42 43 public final static short CODEPAGE = ( short ) 0x4b0; 44 45 public CodepageRecord() 46 { 47 } 48 49 56 57 public CodepageRecord(short id, short size, byte [] data) 58 { 59 super(id, size, data); 60 } 61 62 70 71 public CodepageRecord(short id, short size, byte [] data, int offset) 72 { 73 super(id, size, data, offset); 74 } 75 76 protected void validateSid(short id) 77 { 78 if (id != sid) 79 { 80 throw new RecordFormatException("NOT A CODEPAGE RECORD"); 81 } 82 } 83 84 protected void fillFields(byte [] data, short size, int offset) 85 { 86 field_1_codepage = LittleEndian.getShort(data, 0 + offset); 87 } 88 89 95 96 public void setCodepage(short cp) 97 { 98 field_1_codepage = cp; 99 } 100 101 107 108 public short getCodepage() 109 { 110 return field_1_codepage; 111 } 112 113 public String toString() 114 { 115 StringBuffer buffer = new StringBuffer (); 116 117 buffer.append("[CODEPAGE]\n"); 118 buffer.append(" .codepage = ") 119 .append(Integer.toHexString(getCodepage())).append("\n"); 120 buffer.append("[/CODEPAGE]\n"); 121 return buffer.toString(); 122 } 123 124 public int serialize(int offset, byte [] data) 125 { 126 LittleEndian.putShort(data, 0 + offset, sid); 127 LittleEndian.putShort(data, 2 + offset, 128 (( short ) 0x02)); LittleEndian.putShort(data, 4 + offset, getCodepage()); 130 return getRecordSize(); 131 } 132 133 public int getRecordSize() 134 { 135 return 6; 136 } 137 138 public short getSid() 139 { 140 return this.sid; 141 } 142 } 143 | Popular Tags |