1 2 /* ==================================================================== 3 * The Apache Software License, Version 1.1 4 * 5 * Copyright (c) 2002 The Apache Software Foundation. All rights 6 * reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in 17 * the documentation and/or other materials provided with the 18 * distribution. 19 * 20 * 3. The end-user documentation included with the redistribution, 21 * if any, must include the following acknowledgment: 22 * "This product includes software developed by the 23 * Apache Software Foundation (http://www.apache.org/)." 24 * Alternately, this acknowledgment may appear in the software itself, 25 * if and wherever such third-party acknowledgments normally appear. 26 * 27 * 4. The names "Apache" and "Apache Software Foundation" and 28 * "Apache POI" must not be used to endorse or promote products 29 * derived from this software without prior written permission. For 30 * written permission, please contact apache@apache.org. 31 * 32 * 5. Products derived from this software may not be called "Apache", 33 * "Apache POI", nor may "Apache" appear in their name, without 34 * prior written permission of the Apache Software Foundation. 35 * 36 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 37 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 38 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 39 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 42 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 43 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 44 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 45 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 46 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 47 * SUCH DAMAGE. 48 * ==================================================================== 49 * 50 * This software consists of voluntary contributions made by many 51 * individuals on behalf of the Apache Software Foundation. For more 52 * information on the Apache Software Foundation, please see 53 * <http://www.apache.org/>. 54 */ 55 56 57 package org.apache.poi.hssf.record; 58 59 60 61 import org.apache.poi.util.BitField; 62 import org.apache.poi.util.LittleEndian; 63 import org.apache.poi.util.StringUtil; 64 import org.apache.poi.util.HexDump; 65 66 /** 67 * The dat record is used to store options for the chart. 68 * NOTE: This source is automatically generated please do not modify this file. Either subclass or 69 * remove the record in src/records/definitions. 70 71 * @author Glen Stampoultzis (glens at apache.org) 72 */ 73 public class DatRecord 74 extends Record 75 { 76 public final static short sid = 0x1063; 77 private short field_1_options; 78 private BitField horizontalBorder = new BitField(0x1); 79 private BitField verticalBorder = new BitField(0x2); 80 private BitField border = new BitField(0x4); 81 private BitField showSeriesKey = new BitField(0x8); 82 83 84 public DatRecord() 85 { 86 87 } 88 89 /** 90 * Constructs a Dat record and sets its fields appropriately. 91 * 92 * @param id id must be 0x1063 or an exception 93 * will be throw upon validation 94 * @param size size the size of the data area of the record 95 * @param data data of the record (should not contain sid/len) 96 */ 97 98 public DatRecord(short id, short size, byte [] data) 99 { 100 super(id, size, data); 101 } 102 103 /** 104 * Constructs a Dat record and sets its fields appropriately. 105 * 106 * @param id id must be 0x1063 or an exception 107 * will be throw upon validation 108 * @param size size the size of the data area of the record 109 * @param data data of the record (should not contain sid/len) 110 * @param offset of the record's data 111 */ 112 113 public DatRecord(short id, short size, byte [] data, int offset) 114 { 115 super(id, size, data, offset); 116 } 117 118 /** 119 * Checks the sid matches the expected side for this record 120 * 121 * @param id the expected sid. 122 */ 123 protected void validateSid(short id) 124 { 125 if (id != sid) 126 { 127 throw new RecordFormatException("Not a Dat record"); 128 } 129 } 130 131 protected void fillFields(byte [] data, short size, int offset) 132 { 133 field_1_options = LittleEndian.getShort(data, 0x0 + offset); 134 135 } 136 137 public String toString() 138 { 139 StringBuffer buffer = new StringBuffer(); 140 141 buffer.append("[Dat]\n"); 142 143 buffer.append(" .options = ") 144 .append("0x") 145 .append(HexDump.toHex((short)getOptions())) 146 .append(" (").append(getOptions()).append(" )\n"); 147 buffer.append(" .horizontalBorder = ").append(isHorizontalBorder ()).append('\n'); 148 buffer.append(" .verticalBorder = ").append(isVerticalBorder ()).append('\n'); 149 buffer.append(" .border = ").append(isBorder ()).append('\n'); 150 buffer.append(" .showSeriesKey = ").append(isShowSeriesKey ()).append('\n'); 151 152 buffer.append("[/Dat]\n"); 153 return buffer.toString(); 154 } 155 156 public int serialize(int offset, byte[] data) 157 { 158 LittleEndian.putShort(data, 0 + offset, sid); 159 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 160 161 LittleEndian.putShort(data, 4 + offset, field_1_options); 162 163 return getRecordSize(); 164 } 165 166 /** 167 * Size of record (exluding 4 byte header) 168 */ 169 public int getRecordSize() 170 { 171 return 4 + 2; 172 } 173 174 public short getSid() 175 { 176 return this.sid; 177 } 178 179 180 /** 181 * Get the options field for the Dat record. 182 */ 183 public short getOptions() 184 { 185 return field_1_options; 186 } 187 188 /** 189 * Set the options field for the Dat record. 190 */ 191 public void setOptions(short field_1_options) 192 { 193 this.field_1_options = field_1_options; 194 } 195 196 /** 197 * Sets the horizontal border field value. 198 * has a horizontal border 199 */ 200 public void setHorizontalBorder(boolean value) 201 { 202 field_1_options = horizontalBorder.setShortBoolean(field_1_options, value); 203 } 204 205 /** 206 * has a horizontal border 207 * @return the horizontal border field value. 208 */ 209 public boolean isHorizontalBorder() 210 { 211 return horizontalBorder.isSet(field_1_options); 212 } 213 214 /** 215 * Sets the vertical border field value. 216 * has vertical border 217 */ 218 public void setVerticalBorder(boolean value) 219 { 220 field_1_options = verticalBorder.setShortBoolean(field_1_options, value); 221 } 222 223 /** 224 * has vertical border 225 * @return the vertical border field value. 226 */ 227 public boolean isVerticalBorder() 228 { 229 return verticalBorder.isSet(field_1_options); 230 } 231 232 /** 233 * Sets the border field value. 234 * data table has a border 235 */ 236 public void setBorder(boolean value) 237 { 238 field_1_options = border.setShortBoolean(field_1_options, value); 239 } 240 241 /** 242 * data table has a border 243 * @return the border field value. 244 */ 245 public boolean isBorder() 246 { 247 return border.isSet(field_1_options); 248 } 249 250 /** 251 * Sets the show series key field value. 252 * shows the series key 253 */ 254 public void setShowSeriesKey(boolean value) 255 { 256 field_1_options = showSeriesKey.setShortBoolean(field_1_options, value); 257 } 258 259 /** 260 * shows the series key 261 * @return the show series key field value. 262 */ 263 public boolean isShowSeriesKey() 264 { 265 return showSeriesKey.isSet(field_1_options); 266 } 267 268 269 } // END OF CLASS 270 271 272 273 274