You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DatRecord.java 8.3KB

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