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 CountryRecord 34 extends Record 35 { 36 public final static short sid = 0x8c; 37 38 private short field_1_default_country; 40 private short field_2_current_country; 41 42 public CountryRecord() 43 { 44 } 45 46 53 54 public CountryRecord(short id, short size, byte [] data) 55 { 56 super(id, size, data); 57 } 58 59 67 68 public CountryRecord(short id, short size, byte [] data, int offset) 69 { 70 super(id, size, data, offset); 71 } 72 73 protected void validateSid(short id) 74 { 75 if (id != sid) 76 { 77 throw new RecordFormatException("NOT A Country RECORD"); 78 } 79 } 80 81 protected void fillFields(byte [] data, short size, int offset) 82 { 83 field_1_default_country = LittleEndian.getShort(data, 0 + offset); 84 field_2_current_country = LittleEndian.getShort(data, 2 + offset); 85 } 86 87 92 93 public void setDefaultCountry(short country) 94 { 95 field_1_default_country = country; 96 } 97 98 103 104 public void setCurrentCountry(short country) 105 { 106 field_2_current_country = country; 107 } 108 109 114 115 public short getDefaultCountry() 116 { 117 return field_1_default_country; 118 } 119 120 125 126 public short getCurrentCountry() 127 { 128 return field_2_current_country; 129 } 130 131 public String toString() 132 { 133 StringBuffer buffer = new StringBuffer (); 134 135 buffer.append("[COUNTRY]\n"); 136 buffer.append(" .defaultcountry = ") 137 .append(Integer.toHexString(getDefaultCountry())).append("\n"); 138 buffer.append(" .currentcountry = ") 139 .append(Integer.toHexString(getCurrentCountry())).append("\n"); 140 buffer.append("[/COUNTRY]\n"); 141 return buffer.toString(); 142 } 143 144 public int serialize(int offset, byte [] data) 145 { 146 LittleEndian.putShort(data, 0 + offset, sid); 147 LittleEndian.putShort(data, 2 + offset, 148 (( short ) 0x04)); LittleEndian.putShort(data, 4 + offset, getDefaultCountry()); 150 LittleEndian.putShort(data, 6 + offset, getCurrentCountry()); 151 return getRecordSize(); 152 } 153 154 public int getRecordSize() 155 { 156 return 8; 157 } 158 159 public short getSid() 160 { 161 return this.sid; 162 } 163 } 164 | Popular Tags |