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 ProtectionRev4Record 33 extends Record 34 { 35 public final static short sid = 0x1af; 36 private short field_1_protect; 37 38 public ProtectionRev4Record() 39 { 40 } 41 42 49 50 public ProtectionRev4Record(short id, short size, byte [] data) 51 { 52 super(id, size, data); 53 } 54 55 63 64 public ProtectionRev4Record(short id, short size, byte [] data, 65 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 PROTECTION REV 4 RECORD"); 75 } 76 } 77 78 protected void fillFields(byte [] data, short size, int offset) 79 { 80 field_1_protect = LittleEndian.getShort(data, 0 + offset); 81 } 82 83 87 88 public void setProtect(boolean protect) 89 { 90 if (protect) 91 { 92 field_1_protect = 1; 93 } 94 else 95 { 96 field_1_protect = 0; 97 } 98 } 99 100 104 105 public boolean getProtect() 106 { 107 return (field_1_protect == 1); 108 } 109 110 public String toString() 111 { 112 StringBuffer buffer = new StringBuffer (); 113 114 buffer.append("[PROT4REV]\n"); 115 buffer.append(" .protect = ").append(getProtect()) 116 .append("\n"); 117 buffer.append("[/PROT4REV]\n"); 118 return buffer.toString(); 119 } 120 121 public int serialize(int offset, byte [] data) 122 { 123 LittleEndian.putShort(data, 0 + offset, sid); 124 LittleEndian.putShort(data, 2 + offset, 125 (( short ) 0x02)); LittleEndian.putShort(data, 4 + offset, field_1_protect); 127 return getRecordSize(); 128 } 129 130 public int getRecordSize() 131 { 132 return 6; 133 } 134 135 public short getSid() 136 { 137 return this.sid; 138 } 139 } 140 | Popular Tags |