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