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 MMSRecord 33 extends Record 34 { 35 public final static short sid = 0xC1; 36 private byte field_1_addMenuCount; private byte field_2_delMenuCount; 39 public MMSRecord() 40 { 41 } 42 43 50 51 public MMSRecord(short id, short size, byte [] data) 52 { 53 super(id, size, data); 54 } 55 56 64 65 public MMSRecord(short id, short size, byte [] data, int offset) 66 { 67 super(id, size, data, offset); 68 } 69 70 protected void validateSid(short id) 71 { 72 if (id != sid) 73 { 74 throw new RecordFormatException("NOT A MMS RECORD"); 75 } 76 } 77 78 protected void fillFields(byte [] data, short size, int offset) 79 { 80 field_1_addMenuCount = data[ 0 + offset ]; 81 field_2_delMenuCount = data[ 1 + offset ]; 82 } 83 84 88 89 public void setAddMenuCount(byte am) 90 { 91 field_1_addMenuCount = am; 92 } 93 94 98 99 public void setDelMenuCount(byte dm) 100 { 101 field_2_delMenuCount = dm; 102 } 103 104 108 109 public byte getAddMenuCount() 110 { 111 return field_1_addMenuCount; 112 } 113 114 118 119 public byte getDelMenuCount() 120 { 121 return field_2_delMenuCount; 122 } 123 124 public String toString() 125 { 126 StringBuffer buffer = new StringBuffer (); 127 128 buffer.append("[MMS]\n"); 129 buffer.append(" .addMenu = ") 130 .append(Integer.toHexString(getAddMenuCount())).append("\n"); 131 buffer.append(" .delMenu = ") 132 .append(Integer.toHexString(getDelMenuCount())).append("\n"); 133 buffer.append("[/MMS]\n"); 134 return buffer.toString(); 135 } 136 137 public int serialize(int offset, byte [] data) 138 { 139 LittleEndian.putShort(data, 0 + offset, sid); 140 LittleEndian.putShort(data, 2 + offset, 141 (( short ) 0x02)); data[ 4 + offset ] = getAddMenuCount(); 143 data[ 5 + offset ] = getDelMenuCount(); 144 return getRecordSize(); 145 } 146 147 public int getRecordSize() 148 { 149 return 6; 150 } 151 152 public short getSid() 153 { 154 return this.sid; 155 } 156 } 157 | Popular Tags |