1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 24 import org.apache.poi.util.*; 25 26 33 public class DatRecord 34 extends Record 35 { 36 public final static short sid = 0x1063; 37 private short field_1_options; 38 private BitField horizontalBorder = new BitField(0x1); 39 private BitField verticalBorder = new BitField(0x2); 40 private BitField border = new BitField(0x4); 41 private BitField showSeriesKey = new BitField(0x8); 42 43 44 public DatRecord() 45 { 46 47 } 48 49 57 58 public DatRecord(short id, short size, byte [] data) 59 { 60 super(id, size, data); 61 62 } 63 64 73 74 public DatRecord(short id, short size, byte [] data, int offset) 75 { 76 super(id, size, data, offset); 77 78 } 79 80 85 protected void validateSid(short id) 86 { 87 if (id != sid) 88 { 89 throw new RecordFormatException("Not a Dat record"); 90 } 91 } 92 93 protected void fillFields(byte [] data, short size, int offset) 94 { 95 96 int pos = 0; 97 field_1_options = LittleEndian.getShort(data, pos + 0x0 + offset); 98 99 } 100 101 public String toString() 102 { 103 StringBuffer buffer = new StringBuffer (); 104 105 buffer.append("[DAT]\n"); 106 buffer.append(" .options = ") 107 .append("0x").append(HexDump.toHex( getOptions ())) 108 .append(" (").append( getOptions() ).append(" )"); 109 buffer.append(System.getProperty("line.separator")); 110 buffer.append(" .horizontalBorder = ").append(isHorizontalBorder()).append('\n'); 111 buffer.append(" .verticalBorder = ").append(isVerticalBorder()).append('\n'); 112 buffer.append(" .border = ").append(isBorder()).append('\n'); 113 buffer.append(" .showSeriesKey = ").append(isShowSeriesKey()).append('\n'); 114 115 buffer.append("[/DAT]\n"); 116 return buffer.toString(); 117 } 118 119 public int serialize(int offset, byte[] data) 120 { 121 int pos = 0; 122 123 LittleEndian.putShort(data, 0 + offset, sid); 124 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 125 126 LittleEndian.putShort(data, 4 + offset + pos, field_1_options); 127 128 return getRecordSize(); 129 } 130 131 134 public int getRecordSize() 135 { 136 return 4 + 2; 137 } 138 139 public short getSid() 140 { 141 return this.sid; 142 } 143 144 public Object clone() { 145 DatRecord rec = new DatRecord(); 146 147 rec.field_1_options = field_1_options; 148 return rec; 149 } 150 151 152 153 154 157 public short getOptions() 158 { 159 return field_1_options; 160 } 161 162 165 public void setOptions(short field_1_options) 166 { 167 this.field_1_options = field_1_options; 168 } 169 170 174 public void setHorizontalBorder(boolean value) 175 { 176 field_1_options = horizontalBorder.setShortBoolean(field_1_options, value); 177 } 178 179 183 public boolean isHorizontalBorder() 184 { 185 return horizontalBorder.isSet(field_1_options); 186 } 187 188 192 public void setVerticalBorder(boolean value) 193 { 194 field_1_options = verticalBorder.setShortBoolean(field_1_options, value); 195 } 196 197 201 public boolean isVerticalBorder() 202 { 203 return verticalBorder.isSet(field_1_options); 204 } 205 206 210 public void setBorder(boolean value) 211 { 212 field_1_options = border.setShortBoolean(field_1_options, value); 213 } 214 215 219 public boolean isBorder() 220 { 221 return border.isSet(field_1_options); 222 } 223 224 228 public void setShowSeriesKey(boolean value) 229 { 230 field_1_options = showSeriesKey.setShortBoolean(field_1_options, value); 231 } 232 233 237 public boolean isShowSeriesKey() 238 { 239 return showSeriesKey.isSet(field_1_options); 240 } 241 242 243 } 245 246 247 248 | Popular Tags |