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 PasswordRecord 32 extends Record 33 { 34 public final static short sid = 0x13; 35 private short field_1_password; 37 public PasswordRecord() 38 { 39 } 40 41 48 49 public PasswordRecord(short id, short size, byte [] data) 50 { 51 super(id, size, data); 52 } 53 54 62 63 public PasswordRecord(short id, short size, byte [] data, int offset) 64 { 65 super(id, size, data, offset); 66 } 67 68 protected void validateSid(short id) 69 { 70 if (id != sid) 71 { 72 throw new RecordFormatException("NOT A PASSWORD RECORD"); 73 } 74 } 75 76 protected void fillFields(byte [] data, short size, int offset) 77 { 78 field_1_password = LittleEndian.getShort(data, 0 + offset); 79 } 80 81 86 87 public void setPassword(short password) 88 { 89 field_1_password = password; 90 } 91 92 97 98 public short getPassword() 99 { 100 return field_1_password; 101 } 102 103 public String toString() 104 { 105 StringBuffer buffer = new StringBuffer (); 106 107 buffer.append("[PASSWORD]\n"); 108 buffer.append(" .password = ") 109 .append(Integer.toHexString(getPassword())).append("\n"); 110 buffer.append("[/PASSWORD]\n"); 111 return buffer.toString(); 112 } 113 114 public int serialize(int offset, byte [] data) 115 { 116 LittleEndian.putShort(data, 0 + offset, sid); 117 LittleEndian.putShort(data, 2 + offset, 118 (( short ) 0x02)); LittleEndian.putShort(data, 4 + offset, getPassword()); 120 return getRecordSize(); 121 } 122 123 public int getRecordSize() 124 { 125 return 6; 126 } 127 128 public short getSid() 129 { 130 return this.sid; 131 } 132 133 136 public Object clone() { 137 PasswordRecord clone = new PasswordRecord(); 138 clone.setPassword(field_1_password); 139 return clone; 140 } 141 142 } 143 | Popular Tags |