PageRenderTime 60ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/openmicroscopy/bioformats
Java | 142 lines | 57 code | 28 blank | 57 comment | 3 complexity | d5ab8af238dae1673f25974ef2ea6e20 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 group marker record is used as a position holder for groups.
  41. * @author Glen Stampoultzis (glens at apache.org)
  42. */
  43. public class GroupMarkerSubRecord
  44. extends SubRecord
  45. {
  46. public final static short sid = 0x06;
  47. private byte[] reserved = new byte[0]; // would really love to know what goes in here.
  48. public GroupMarkerSubRecord()
  49. {
  50. }
  51. /**
  52. * Constructs a group marker record and sets its fields appropriately.
  53. *
  54. * @param in the RecordInputstream to read the record from
  55. */
  56. public GroupMarkerSubRecord(RecordInputStream in)
  57. {
  58. super(in);
  59. }
  60. /**
  61. * Checks the sid matches the expected side for this record
  62. *
  63. * @param id the expected sid.
  64. */
  65. protected void validateSid(short id)
  66. {
  67. if (id != sid)
  68. {
  69. throw new RecordFormatException("Not a Group Marker record");
  70. }
  71. }
  72. protected void fillFields(RecordInputStream in)
  73. {
  74. // int pos = 0;
  75. reserved = in.readRemainder();
  76. }
  77. public String toString()
  78. {
  79. StringBuffer buffer = new StringBuffer();
  80. String nl = System.getProperty("line.separator");
  81. buffer.append("[ftGmo]" + nl);
  82. buffer.append(" reserved = ").append(HexDump.toHex(reserved)).append(nl);
  83. buffer.append("[/ftGmo]" + nl);
  84. return buffer.toString();
  85. }
  86. public int serialize(int offset, byte[] data)
  87. {
  88. LittleEndian.putShort(data, 0 + offset, sid);
  89. LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
  90. System.arraycopy(reserved, 0, data, offset + 4, getRecordSize() - 4);
  91. return getRecordSize();
  92. }
  93. /**
  94. * Size of record (exluding 4 byte header)
  95. */
  96. public int getRecordSize()
  97. {
  98. return 4 + reserved.length;
  99. }
  100. public short getSid()
  101. {
  102. return sid;
  103. }
  104. public Object clone() {
  105. GroupMarkerSubRecord rec = new GroupMarkerSubRecord();
  106. rec.reserved = new byte[reserved.length];
  107. for ( int i = 0; i < reserved.length; i++ )
  108. rec.reserved[i] = reserved[i];
  109. return rec;
  110. }
  111. } // END OF CLASS