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: /*
019: * ExtSSTInfoSubRecord.java
020: *
021: * Created on September 8, 2001, 8:37 PM
022: */
023: package org.apache.poi.hssf.record;
024:
025: import org.apache.poi.util.LittleEndian;
026:
027: /**
028: * Extended SST table info subrecord<P>
029: * contains the elements of "info" in the SST's array field<P>
030: * @author Andrew C. Oliver (acoliver at apache dot org)
031: * @version 2.0-pre
032: * @see org.apache.poi.hssf.record.ExtSSTRecord
033: */
034:
035: public class ExtSSTInfoSubRecord extends Record {
036: public static final int INFO_SIZE = 8;
037: public final static short sid = 0xFFF; // only here for conformance, doesn't really have an sid
038: private int field_1_stream_pos; // stream pointer to the SST record
039: private short field_2_bucket_sst_offset; // don't really understand this yet.
040: private short field_3_zero; // must be 0;
041:
042: /** Creates new ExtSSTInfoSubRecord */
043:
044: public ExtSSTInfoSubRecord() {
045: }
046:
047: public ExtSSTInfoSubRecord(RecordInputStream in) {
048: super (in);
049: }
050:
051: protected void validateSid(short id) {
052:
053: // do nothing
054: }
055:
056: protected void fillFields(RecordInputStream in) {
057: field_1_stream_pos = in.readInt();
058: field_2_bucket_sst_offset = in.readShort();
059: field_3_zero = in.readShort();
060: }
061:
062: public void setStreamPos(int pos) {
063: field_1_stream_pos = pos;
064: }
065:
066: public void setBucketRecordOffset(short offset) {
067: field_2_bucket_sst_offset = offset;
068: }
069:
070: public int getStreamPos() {
071: return field_1_stream_pos;
072: }
073:
074: public short getBucketSSTOffset() {
075: return field_2_bucket_sst_offset;
076: }
077:
078: public String toString() {
079: StringBuffer buffer = new StringBuffer();
080:
081: buffer.append("[EXTSST]\n");
082: buffer.append(" .streampos = ").append(
083: Integer.toHexString(getStreamPos())).append("\n");
084: buffer.append(" .bucketsstoffset= ").append(
085: Integer.toHexString(getBucketSSTOffset())).append("\n");
086: buffer.append(" .zero = ").append(
087: Integer.toHexString(field_3_zero)).append("\n");
088: buffer.append("[/EXTSST]\n");
089: return buffer.toString();
090: }
091:
092: public int serialize(int offset, byte[] data) {
093: LittleEndian.putInt(data, 0 + offset, getStreamPos());
094: LittleEndian.putShort(data, 4 + offset, getBucketSSTOffset());
095: LittleEndian.putShort(data, 6 + offset, (short) 0);
096: return getRecordSize();
097: }
098:
099: public int getRecordSize() {
100: return 8;
101: }
102:
103: public short getSid() {
104: return sid;
105: }
106: }
|