KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.apache.poi.hssf.record;
21
22
23
24 import org.apache.poi.util.*;
25
26 /**
27  * links a series to its position in the series list.
28  * NOTE: This source is automatically generated please do not modify this file. Either subclass or
29  * remove the record in src/records/definitions.
30
31  * @author Andrew C. Oliver (acoliver at apache.org)
32  */

33 public class SeriesIndexRecord
34     extends Record
35 {
36     public final static short sid = 0x1065;
37     private short field_1_index;
38
39
40     public SeriesIndexRecord()
41     {
42
43     }
44
45     /**
46      * Constructs a SeriesIndex record and sets its fields appropriately.
47      *
48      * @param id id must be 0x1065 or an exception
49      * will be throw upon validation
50      * @param size size the size of the data area of the record
51      * @param data data of the record (should not contain sid/len)
52      */

53
54     public SeriesIndexRecord(short id, short size, byte [] data)
55     {
56         super(id, size, data);
57     
58     }
59
60     /**
61      * Constructs a SeriesIndex record and sets its fields appropriately.
62      *
63      * @param id id must be 0x1065 or an exception
64      * will be throw upon validation
65      * @param size size the size of the data area of the record
66      * @param data data of the record (should not contain sid/len)
67      * @param offset of the record's data
68      */

69
70     public SeriesIndexRecord(short id, short size, byte [] data, int offset)
71     {
72         super(id, size, data, offset);
73     
74     }
75
76     /**
77      * Checks the sid matches the expected side for this record
78      *
79      * @param id the expected sid.
80      */

81     protected void validateSid(short id)
82     {
83         if (id != sid)
84         {
85             throw new RecordFormatException("Not a SeriesIndex record");
86         }
87     }
88
89     protected void fillFields(byte [] data, short size, int offset)
90     {
91
92         int pos = 0;
93         field_1_index = LittleEndian.getShort(data, pos + 0x0 + offset);
94
95     }
96
97     public String JavaDoc toString()
98     {
99         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
100
101         buffer.append("[SINDEX]\n");
102         buffer.append(" .index = ")
103             .append("0x").append(HexDump.toHex( getIndex ()))
104             .append(" (").append( getIndex() ).append(" )");
105         buffer.append(System.getProperty("line.separator"));
106
107         buffer.append("[/SINDEX]\n");
108         return buffer.toString();
109     }
110
111     public int serialize(int offset, byte[] data)
112     {
113         int pos = 0;
114
115         LittleEndian.putShort(data, 0 + offset, sid);
116         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
117
118         LittleEndian.putShort(data, 4 + offset + pos, field_1_index);
119
120         return getRecordSize();
121     }
122
123     /**
124      * Size of record (exluding 4 byte header)
125      */

126     public int getRecordSize()
127     {
128         return 4 + 2;
129     }
130
131     public short getSid()
132     {
133         return this.sid;
134     }
135
136     public Object JavaDoc clone() {
137         SeriesIndexRecord rec = new SeriesIndexRecord();
138     
139         rec.field_1_index = field_1_index;
140         return rec;
141     }
142
143
144
145
146     /**
147      * Get the index field for the SeriesIndex record.
148      */

149     public short getIndex()
150     {
151         return field_1_index;
152     }
153
154     /**
155      * Set the index field for the SeriesIndex record.
156      */

157     public void setIndex(short field_1_index)
158     {
159         this.field_1_index = field_1_index;
160     }
161
162
163 } // END OF CLASS
164

165
166
167
168
Popular Tags