001: /* ====================================================================
002: Licensed to the Apache Software Foundation (ASF) under one or more
003: contributor license agreements. See the NOTICE file distributed with
004: this work for additional information regarding copyright ownership.
005: The ASF licenses this file to You under the Apache License, Version 2.0
006: (the "License"); you may not use this file except in compliance with
007: the License. You may obtain a copy of the License at
008:
009: http://www.apache.org/licenses/LICENSE-2.0
010:
011: Unless required by applicable law or agreed to in writing, software
012: distributed under the License is distributed on an "AS IS" BASIS,
013: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: See the License for the specific language governing permissions and
015: limitations under the License.
016: ==================================================================== */
017:
018: package org.apache.poi.hssf.record;
019:
020: import org.apache.poi.util.*;
021:
022: /**
023: * The group marker record is used as a position holder for groups.
024:
025: * @author Glen Stampoultzis (glens at apache.org)
026: */
027: public class GroupMarkerSubRecord extends SubRecord {
028: public final static short sid = 0x06;
029:
030: private byte[] reserved = new byte[0]; // would really love to know what goes in here.
031:
032: public GroupMarkerSubRecord() {
033:
034: }
035:
036: /**
037: * Constructs a group marker record and sets its fields appropriately.
038: *
039: * @param in the RecordInputstream to read the record from
040: */
041:
042: public GroupMarkerSubRecord(RecordInputStream in) {
043: super (in);
044:
045: }
046:
047: /**
048: * Checks the sid matches the expected side for this record
049: *
050: * @param id the expected sid.
051: */
052: protected void validateSid(short id) {
053: if (id != sid) {
054: throw new RecordFormatException("Not a Group Marker record");
055: }
056: }
057:
058: protected void fillFields(RecordInputStream in) {
059: // int pos = 0;
060: reserved = in.readRemainder();
061: }
062:
063: public String toString() {
064: StringBuffer buffer = new StringBuffer();
065:
066: String nl = System.getProperty("line.separator");
067: buffer.append("[ftGmo]" + nl);
068: buffer.append(" reserved = ").append(HexDump.toHex(reserved))
069: .append(nl);
070: buffer.append("[/ftGmo]" + nl);
071: return buffer.toString();
072: }
073:
074: public int serialize(int offset, byte[] data) {
075: LittleEndian.putShort(data, 0 + offset, sid);
076: LittleEndian.putShort(data, 2 + offset,
077: (short) (getRecordSize() - 4));
078: System.arraycopy(reserved, 0, data, offset + 4,
079: getRecordSize() - 4);
080:
081: return getRecordSize();
082: }
083:
084: /**
085: * Size of record (exluding 4 byte header)
086: */
087: public int getRecordSize() {
088: return 4 + reserved.length;
089: }
090:
091: public short getSid() {
092: return sid;
093: }
094:
095: public Object clone() {
096: GroupMarkerSubRecord rec = new GroupMarkerSubRecord();
097: rec.reserved = new byte[reserved.length];
098: for (int i = 0; i < reserved.length; i++)
099: rec.reserved[i] = reserved[i];
100: return rec;
101: }
102:
103: } // END OF CLASS
|