KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Defines a series name
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 SeriesTextRecord
34     extends Record
35 {
36     public final static short sid = 0x100d;
37     private short field_1_id;
38     private byte field_2_textLength;
39     private byte field_3_undocumented;
40     private String JavaDoc field_4_text;
41
42
43     public SeriesTextRecord()
44     {
45
46     }
47
48     /**
49      * Constructs a SeriesText record and sets its fields appropriately.
50      *
51      * @param id id must be 0x100d or an exception
52      * will be throw upon validation
53      * @param size size the size of the data area of the record
54      * @param data data of the record (should not contain sid/len)
55      */

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

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

84     protected void validateSid(short id)
85     {
86         if (id != sid)
87         {
88             throw new RecordFormatException("Not a SeriesText record");
89         }
90     }
91
92     protected void fillFields(byte [] data, short size, int offset)
93     {
94
95         int pos = 0;
96         field_1_id = LittleEndian.getShort(data, pos + 0x0 + offset);
97         field_2_textLength = data[ pos + 0x2 + offset ];
98         field_3_undocumented = data[ pos + 0x3 + offset ];
99         field_4_text = StringUtil.getFromUnicodeLE(data, pos + 0x4 + offset, ((field_2_textLength *2)/2));
100
101     }
102
103     public String JavaDoc toString()
104     {
105         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
106
107         buffer.append("[SERIESTEXT]\n");
108         buffer.append(" .id = ")
109             .append("0x").append(HexDump.toHex( getId ()))
110             .append(" (").append( getId() ).append(" )");
111         buffer.append(System.getProperty("line.separator"));
112         buffer.append(" .textLength = ")
113             .append("0x").append(HexDump.toHex( getTextLength ()))
114             .append(" (").append( getTextLength() ).append(" )");
115         buffer.append(System.getProperty("line.separator"));
116         buffer.append(" .undocumented = ")
117             .append("0x").append(HexDump.toHex( getUndocumented ()))
118             .append(" (").append( getUndocumented() ).append(" )");
119         buffer.append(System.getProperty("line.separator"));
120         buffer.append(" .text = ")
121             .append(" (").append( getText() ).append(" )");
122         buffer.append(System.getProperty("line.separator"));
123
124         buffer.append("[/SERIESTEXT]\n");
125         return buffer.toString();
126     }
127
128     public int serialize(int offset, byte[] data)
129     {
130         int pos = 0;
131
132         LittleEndian.putShort(data, 0 + offset, sid);
133         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
134
135         LittleEndian.putShort(data, 4 + offset + pos, field_1_id);
136         data[ 6 + offset + pos ] = field_2_textLength;
137         data[ 7 + offset + pos ] = field_3_undocumented;
138         StringUtil.putUnicodeLE(field_4_text, data, 8 + offset + pos);
139
140         return getRecordSize();
141     }
142
143     /**
144      * Size of record (exluding 4 byte header)
145      */

146     public int getRecordSize()
147     {
148         return 4 + 2 + 1 + 1 + (field_2_textLength *2);
149     }
150
151     public short getSid()
152     {
153         return this.sid;
154     }
155
156     public Object JavaDoc clone() {
157         SeriesTextRecord rec = new SeriesTextRecord();
158     
159         rec.field_1_id = field_1_id;
160         rec.field_2_textLength = field_2_textLength;
161         rec.field_3_undocumented = field_3_undocumented;
162         rec.field_4_text = field_4_text;
163         return rec;
164     }
165
166
167
168
169     /**
170      * Get the id field for the SeriesText record.
171      */

172     public short getId()
173     {
174         return field_1_id;
175     }
176
177     /**
178      * Set the id field for the SeriesText record.
179      */

180     public void setId(short field_1_id)
181     {
182         this.field_1_id = field_1_id;
183     }
184
185     /**
186      * Get the text length field for the SeriesText record.
187      */

188     public byte getTextLength()
189     {
190         return field_2_textLength;
191     }
192
193     /**
194      * Set the text length field for the SeriesText record.
195      */

196     public void setTextLength(byte field_2_textLength)
197     {
198         this.field_2_textLength = field_2_textLength;
199     }
200
201     /**
202      * Get the undocumented field for the SeriesText record.
203      */

204     public byte getUndocumented()
205     {
206         return field_3_undocumented;
207     }
208
209     /**
210      * Set the undocumented field for the SeriesText record.
211      */

212     public void setUndocumented(byte field_3_undocumented)
213     {
214         this.field_3_undocumented = field_3_undocumented;
215     }
216
217     /**
218      * Get the text field for the SeriesText record.
219      */

220     public String JavaDoc getText()
221     {
222         return field_4_text;
223     }
224
225     /**
226      * Set the text field for the SeriesText record.
227      */

228     public void setText(String JavaDoc field_4_text)
229     {
230         this.field_4_text = field_4_text;
231     }
232
233
234 } // END OF CLASS
235

236
237
238
239
Popular Tags