KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hssf > record > ExtSSTInfoSubRecord


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 ==================================================================== */

17         
18
19 /*
20  * ExtSSTInfoSubRecord.java
21  *
22  * Created on September 8, 2001, 8:37 PM
23  */

24 package org.apache.poi.hssf.record;
25
26 import org.apache.poi.util.LittleEndian;
27
28 /**
29  * Extended SST table info subrecord<P>
30  * contains the elements of "info" in the SST's array field<P>
31  * @author Andrew C. Oliver (acoliver at apache dot org)
32  * @version 2.0-pre
33  * @see org.apache.poi.hssf.record.ExtSSTRecord
34  */

35
36 public class ExtSSTInfoSubRecord
37     extends Record
38 {
39    public static final int INFO_SIZE = 8;
40     public final static short sid =
41         0xFFF; // only here for conformance, doesn't really have an sid
42
private int field_1_stream_pos; // stream pointer to the SST record
43
private short field_2_bucket_sst_offset; // don't really understand this yet.
44
private short field_3_zero; // must be 0;
45

46     /** Creates new ExtSSTInfoSubRecord */
47
48     public ExtSSTInfoSubRecord()
49     {
50     }
51
52     public ExtSSTInfoSubRecord(short id, short size, byte [] data)
53     {
54         super(id, size, data);
55     }
56
57     public ExtSSTInfoSubRecord(short id, short size, byte [] data, int offset)
58     {
59         super(id, size, data, offset);
60     }
61
62     protected void validateSid(short id)
63     {
64
65         // do nothing
66
}
67
68     protected void fillFields(byte [] data, short size, int offset)
69     {
70         field_1_stream_pos = LittleEndian.getInt(data, 0 + offset);
71         field_2_bucket_sst_offset = LittleEndian.getShort(data, 4 + offset);
72         field_3_zero = LittleEndian.getShort(data, 6 + offset);
73     }
74
75     public void setStreamPos(int pos)
76     {
77         field_1_stream_pos = pos;
78     }
79
80     public void setBucketRecordOffset(short offset)
81     {
82         field_2_bucket_sst_offset = offset;
83     }
84
85     public int getStreamPos()
86     {
87         return field_1_stream_pos;
88     }
89
90     public short getBucketSSTOffset()
91     {
92         return field_2_bucket_sst_offset;
93     }
94
95     public String JavaDoc toString()
96     {
97         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
98
99         buffer.append("[EXTSST]\n");
100         buffer.append(" .streampos = ")
101             .append(Integer.toHexString(getStreamPos())).append("\n");
102         buffer.append(" .bucketsstoffset= ")
103             .append(Integer.toHexString(getBucketSSTOffset())).append("\n");
104         buffer.append(" .zero = ")
105             .append(Integer.toHexString(field_3_zero)).append("\n");
106         buffer.append("[/EXTSST]\n");
107         return buffer.toString();
108     }
109
110     public int serialize(int offset, byte [] data)
111     {
112         LittleEndian.putInt(data, 0 + offset, getStreamPos());
113         LittleEndian.putShort(data, 4 + offset, getBucketSSTOffset());
114         LittleEndian.putShort(data, 6 + offset, ( short ) 0);
115         return getRecordSize();
116     }
117
118     public int getRecordSize()
119     {
120         return 8;
121     }
122
123     public short getSid()
124     {
125         return sid;
126     }
127 }
128
Popular Tags