PageRenderTime 38ms CodeModel.GetById 11ms RepoModel.GetById 1ms app.codeStats 0ms

/components/forks/poi/src/loci/poi/hssf/record/DatRecord.java

http://github.com/openmicroscopy/bioformats
Java | 247 lines | 106 code | 45 blank | 96 comment | 2 complexity | 4b601835353301cde8aa8c47cccf88de MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, Apache-2.0, BSD-2-Clause, MPL-2.0-no-copyleft-exception
  1. /*
  2. * #%L
  3. * Fork of Apache Jakarta POI.
  4. * %%
  5. * Copyright (C) 2008 - 2013 Open Microscopy Environment:
  6. * - Board of Regents of the University of Wisconsin-Madison
  7. * - Glencoe Software, Inc.
  8. * - University of Dundee
  9. * %%
  10. * Licensed under the Apache License, Version 2.0 (the "License");
  11. * you may not use this file except in compliance with the License.
  12. * You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS,
  18. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. * See the License for the specific language governing permissions and
  20. * limitations under the License.
  21. * #L%
  22. */
  23. /* ====================================================================
  24. Licensed to the Apache Software Foundation (ASF) under one or more
  25. contributor license agreements. See the NOTICE file distributed with
  26. this work for additional information regarding copyright ownership.
  27. The ASF licenses this file to You under the Apache License, Version 2.0
  28. (the "License"); you may not use this file except in compliance with
  29. the License. You may obtain a copy of the License at
  30. http://www.apache.org/licenses/LICENSE-2.0
  31. Unless required by applicable law or agreed to in writing, software
  32. distributed under the License is distributed on an "AS IS" BASIS,
  33. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  34. See the License for the specific language governing permissions and
  35. limitations under the License.
  36. ==================================================================== */
  37. package loci.poi.hssf.record;
  38. import loci.poi.util.*;
  39. /**
  40. * The dat record is used to store options for the chart.
  41. * NOTE: This source is automatically generated please do not modify this file. Either subclass or
  42. * remove the record in src/records/definitions.
  43. * @author Glen Stampoultzis (glens at apache.org)
  44. */
  45. public class DatRecord
  46. extends Record
  47. {
  48. public final static short sid = 0x1063;
  49. private short field_1_options;
  50. private BitField horizontalBorder = BitFieldFactory.getInstance(0x1);
  51. private BitField verticalBorder = BitFieldFactory.getInstance(0x2);
  52. private BitField border = BitFieldFactory.getInstance(0x4);
  53. private BitField showSeriesKey = BitFieldFactory.getInstance(0x8);
  54. public DatRecord()
  55. {
  56. }
  57. /**
  58. * Constructs a Dat record and sets its fields appropriately.
  59. *
  60. * @param in the RecordInputstream to read the record from
  61. */
  62. public DatRecord(RecordInputStream in)
  63. {
  64. super(in);
  65. }
  66. /**
  67. * Checks the sid matches the expected side for this record
  68. *
  69. * @param id the expected sid.
  70. */
  71. protected void validateSid(short id)
  72. {
  73. if (id != sid)
  74. {
  75. throw new RecordFormatException("Not a Dat record");
  76. }
  77. }
  78. protected void fillFields(RecordInputStream in)
  79. {
  80. field_1_options = in.readShort();
  81. }
  82. public String toString()
  83. {
  84. StringBuffer buffer = new StringBuffer();
  85. buffer.append("[DAT]\n");
  86. buffer.append(" .options = ")
  87. .append("0x").append(HexDump.toHex( getOptions ()))
  88. .append(" (").append( getOptions() ).append(" )");
  89. buffer.append(System.getProperty("line.separator"));
  90. buffer.append(" .horizontalBorder = ").append(isHorizontalBorder()).append('\n');
  91. buffer.append(" .verticalBorder = ").append(isVerticalBorder()).append('\n');
  92. buffer.append(" .border = ").append(isBorder()).append('\n');
  93. buffer.append(" .showSeriesKey = ").append(isShowSeriesKey()).append('\n');
  94. buffer.append("[/DAT]\n");
  95. return buffer.toString();
  96. }
  97. public int serialize(int offset, byte[] data)
  98. {
  99. int pos = 0;
  100. LittleEndian.putShort(data, 0 + offset, sid);
  101. LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
  102. LittleEndian.putShort(data, 4 + offset + pos, field_1_options);
  103. return getRecordSize();
  104. }
  105. /**
  106. * Size of record (exluding 4 byte header)
  107. */
  108. public int getRecordSize()
  109. {
  110. return 4 + 2;
  111. }
  112. public short getSid()
  113. {
  114. return sid;
  115. }
  116. public Object clone() {
  117. DatRecord rec = new DatRecord();
  118. rec.field_1_options = field_1_options;
  119. return rec;
  120. }
  121. /**
  122. * Get the options field for the Dat record.
  123. */
  124. public short getOptions()
  125. {
  126. return field_1_options;
  127. }
  128. /**
  129. * Set the options field for the Dat record.
  130. */
  131. public void setOptions(short field_1_options)
  132. {
  133. this.field_1_options = field_1_options;
  134. }
  135. /**
  136. * Sets the horizontal border field value.
  137. * has a horizontal border
  138. */
  139. public void setHorizontalBorder(boolean value)
  140. {
  141. field_1_options = horizontalBorder.setShortBoolean(field_1_options, value);
  142. }
  143. /**
  144. * has a horizontal border
  145. * @return the horizontal border field value.
  146. */
  147. public boolean isHorizontalBorder()
  148. {
  149. return horizontalBorder.isSet(field_1_options);
  150. }
  151. /**
  152. * Sets the vertical border field value.
  153. * has vertical border
  154. */
  155. public void setVerticalBorder(boolean value)
  156. {
  157. field_1_options = verticalBorder.setShortBoolean(field_1_options, value);
  158. }
  159. /**
  160. * has vertical border
  161. * @return the vertical border field value.
  162. */
  163. public boolean isVerticalBorder()
  164. {
  165. return verticalBorder.isSet(field_1_options);
  166. }
  167. /**
  168. * Sets the border field value.
  169. * data table has a border
  170. */
  171. public void setBorder(boolean value)
  172. {
  173. field_1_options = border.setShortBoolean(field_1_options, value);
  174. }
  175. /**
  176. * data table has a border
  177. * @return the border field value.
  178. */
  179. public boolean isBorder()
  180. {
  181. return border.isSet(field_1_options);
  182. }
  183. /**
  184. * Sets the show series key field value.
  185. * shows the series key
  186. */
  187. public void setShowSeriesKey(boolean value)
  188. {
  189. field_1_options = showSeriesKey.setShortBoolean(field_1_options, value);
  190. }
  191. /**
  192. * shows the series key
  193. * @return the show series key field value.
  194. */
  195. public boolean isShowSeriesKey()
  196. {
  197. return showSeriesKey.isSet(field_1_options);
  198. }
  199. } // END OF CLASS