1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 import org.apache.poi.util.LittleEndian; 22 23 34 35 public class IterationRecord 36 extends Record 37 { 38 public final static short sid = 0x11; 39 private short field_1_iteration; 40 41 public IterationRecord() 42 { 43 } 44 45 52 53 public IterationRecord(short id, short size, byte [] data) 54 { 55 super(id, size, data); 56 } 57 58 66 67 public IterationRecord(short id, short size, byte [] data, int offset) 68 { 69 super(id, size, data, offset); 70 } 71 72 protected void validateSid(short id) 73 { 74 if (id != sid) 75 { 76 throw new RecordFormatException("NOT An ITERATION RECORD"); 77 } 78 } 79 80 protected void fillFields(byte [] data, short size, int offset) 81 { 82 field_1_iteration = LittleEndian.getShort(data, 0 + offset); 83 } 84 85 89 90 public void setIteration(boolean iterate) 91 { 92 if (iterate) 93 { 94 field_1_iteration = 1; 95 } 96 else 97 { 98 field_1_iteration = 0; 99 } 100 } 101 102 107 108 public boolean getIteration() 109 { 110 return (field_1_iteration == 1); 111 } 112 113 public String toString() 114 { 115 StringBuffer buffer = new StringBuffer (); 116 117 buffer.append("[ITERATION]\n"); 118 buffer.append(" .iteration = ").append(getIteration()) 119 .append("\n"); 120 buffer.append("[/ITERATION]\n"); 121 return buffer.toString(); 122 } 123 124 public int serialize(int offset, byte [] data) 125 { 126 LittleEndian.putShort(data, 0 + offset, sid); 127 LittleEndian.putShort(data, 2 + offset, ( short ) 0x2); 128 LittleEndian.putShort(data, 4 + offset, field_1_iteration); 129 return getRecordSize(); 130 } 131 132 public int getRecordSize() 133 { 134 return 6; 135 } 136 137 public short getSid() 138 { 139 return this.sid; 140 } 141 142 public Object clone() { 143 IterationRecord rec = new IterationRecord(); 144 rec.field_1_iteration = field_1_iteration; 145 return rec; 146 } 147 } 148 | Popular Tags |