KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Describes a linked data record. This record referes to the series data or text.
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 Glen Stampoultzis (glens at apache.org)
32  */

33 public class LinkedDataRecord
34     extends Record
35 {
36     public final static short sid = 0x1051;
37     private byte field_1_linkType;
38     public final static byte LINK_TYPE_TITLE_OR_TEXT = 0;
39     public final static byte LINK_TYPE_VALUES = 1;
40     public final static byte LINK_TYPE_CATEGORIES = 2;
41     private byte field_2_referenceType;
42     public final static byte REFERENCE_TYPE_DEFAULT_CATEGORIES = 0;
43     public final static byte REFERENCE_TYPE_DIRECT = 1;
44     public final static byte REFERENCE_TYPE_WORKSHEET = 2;
45     public final static byte REFERENCE_TYPE_NOT_USED = 3;
46     public final static byte REFERENCE_TYPE_ERROR_REPORTED = 4;
47     private short field_3_options;
48     private BitField customNumberFormat = new BitField(0x1);
49     private short field_4_indexNumberFmtRecord;
50     private LinkedDataFormulaField field_5_formulaOfLink;
51
52
53     public LinkedDataRecord()
54     {
55
56     }
57
58     /**
59      * Constructs a LinkedData record and sets its fields appropriately.
60      *
61      * @param id id must be 0x1051 or an exception
62      * will be throw upon validation
63      * @param size size the size of the data area of the record
64      * @param data data of the record (should not contain sid/len)
65      */

66
67     public LinkedDataRecord(short id, short size, byte [] data)
68     {
69         super(id, size, data);
70     
71     }
72
73     /**
74      * Constructs a LinkedData record and sets its fields appropriately.
75      *
76      * @param id id must be 0x1051 or an exception
77      * will be throw upon validation
78      * @param size size the size of the data area of the record
79      * @param data data of the record (should not contain sid/len)
80      * @param offset of the record's data
81      */

82
83     public LinkedDataRecord(short id, short size, byte [] data, int offset)
84     {
85         super(id, size, data, offset);
86     
87     }
88
89     /**
90      * Checks the sid matches the expected side for this record
91      *
92      * @param id the expected sid.
93      */

94     protected void validateSid(short id)
95     {
96         if (id != sid)
97         {
98             throw new RecordFormatException("Not a LinkedData record");
99         }
100     }
101
102     protected void fillFields(byte [] data, short size, int offset)
103     {
104
105         int pos = 0;
106         field_1_linkType = data[ pos + 0x0 + offset ];
107         field_2_referenceType = data[ pos + 0x1 + offset ];
108         field_3_options = LittleEndian.getShort(data, pos + 0x2 + offset);
109         field_4_indexNumberFmtRecord = LittleEndian.getShort(data, pos + 0x4 + offset);
110         field_5_formulaOfLink = new org.apache.poi.hssf.record.LinkedDataFormulaField();
111         pos += field_5_formulaOfLink.fillField(data,size,pos + offset + 6);
112
113     }
114
115     public String JavaDoc toString()
116     {
117         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
118
119         buffer.append("[AI]\n");
120         buffer.append(" .linkType = ")
121             .append("0x").append(HexDump.toHex( getLinkType ()))
122             .append(" (").append( getLinkType() ).append(" )");
123         buffer.append(System.getProperty("line.separator"));
124         buffer.append(" .referenceType = ")
125             .append("0x").append(HexDump.toHex( getReferenceType ()))
126             .append(" (").append( getReferenceType() ).append(" )");
127         buffer.append(System.getProperty("line.separator"));
128         buffer.append(" .options = ")
129             .append("0x").append(HexDump.toHex( getOptions ()))
130             .append(" (").append( getOptions() ).append(" )");
131         buffer.append(System.getProperty("line.separator"));
132         buffer.append(" .customNumberFormat = ").append(isCustomNumberFormat()).append('\n');
133         buffer.append(" .indexNumberFmtRecord = ")
134             .append("0x").append(HexDump.toHex( getIndexNumberFmtRecord ()))
135             .append(" (").append( getIndexNumberFmtRecord() ).append(" )");
136         buffer.append(System.getProperty("line.separator"));
137         buffer.append(" .formulaOfLink = ")
138             .append(" (").append( getFormulaOfLink() ).append(" )");
139         buffer.append(System.getProperty("line.separator"));
140
141         buffer.append("[/AI]\n");
142         return buffer.toString();
143     }
144
145     public int serialize(int offset, byte[] data)
146     {
147         int pos = 0;
148
149         LittleEndian.putShort(data, 0 + offset, sid);
150         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
151
152         data[ 4 + offset + pos ] = field_1_linkType;
153         data[ 5 + offset + pos ] = field_2_referenceType;
154         LittleEndian.putShort(data, 6 + offset + pos, field_3_options);
155         LittleEndian.putShort(data, 8 + offset + pos, field_4_indexNumberFmtRecord);
156         pos += field_5_formulaOfLink.serializeField( pos + 10 + offset, data );
157
158         return getRecordSize();
159     }
160
161     /**
162      * Size of record (exluding 4 byte header)
163      */

164     public int getRecordSize()
165     {
166         return 4 + 1 + 1 + 2 + 2 + field_5_formulaOfLink.getSize();
167     }
168
169     public short getSid()
170     {
171         return this.sid;
172     }
173
174     public Object JavaDoc clone() {
175         LinkedDataRecord rec = new LinkedDataRecord();
176     
177         rec.field_1_linkType = field_1_linkType;
178         rec.field_2_referenceType = field_2_referenceType;
179         rec.field_3_options = field_3_options;
180         rec.field_4_indexNumberFmtRecord = field_4_indexNumberFmtRecord;
181         rec.field_5_formulaOfLink = ((org.apache.poi.hssf.record.LinkedDataFormulaField)field_5_formulaOfLink.clone());;
182         return rec;
183     }
184
185
186
187
188     /**
189      * Get the link type field for the LinkedData record.
190      *
191      * @return One of
192      * LINK_TYPE_TITLE_OR_TEXT
193      * LINK_TYPE_VALUES
194      * LINK_TYPE_CATEGORIES
195      */

196     public byte getLinkType()
197     {
198         return field_1_linkType;
199     }
200
201     /**
202      * Set the link type field for the LinkedData record.
203      *
204      * @param field_1_linkType
205      * One of
206      * LINK_TYPE_TITLE_OR_TEXT
207      * LINK_TYPE_VALUES
208      * LINK_TYPE_CATEGORIES
209      */

210     public void setLinkType(byte field_1_linkType)
211     {
212         this.field_1_linkType = field_1_linkType;
213     }
214
215     /**
216      * Get the reference type field for the LinkedData record.
217      *
218      * @return One of
219      * REFERENCE_TYPE_DEFAULT_CATEGORIES
220      * REFERENCE_TYPE_DIRECT
221      * REFERENCE_TYPE_WORKSHEET
222      * REFERENCE_TYPE_NOT_USED
223      * REFERENCE_TYPE_ERROR_REPORTED
224      */

225     public byte getReferenceType()
226     {
227         return field_2_referenceType;
228     }
229
230     /**
231      * Set the reference type field for the LinkedData record.
232      *
233      * @param field_2_referenceType
234      * One of
235      * REFERENCE_TYPE_DEFAULT_CATEGORIES
236      * REFERENCE_TYPE_DIRECT
237      * REFERENCE_TYPE_WORKSHEET
238      * REFERENCE_TYPE_NOT_USED
239      * REFERENCE_TYPE_ERROR_REPORTED
240      */

241     public void setReferenceType(byte field_2_referenceType)
242     {
243         this.field_2_referenceType = field_2_referenceType;
244     }
245
246     /**
247      * Get the options field for the LinkedData record.
248      */

249     public short getOptions()
250     {
251         return field_3_options;
252     }
253
254     /**
255      * Set the options field for the LinkedData record.
256      */

257     public void setOptions(short field_3_options)
258     {
259         this.field_3_options = field_3_options;
260     }
261
262     /**
263      * Get the index number fmt record field for the LinkedData record.
264      */

265     public short getIndexNumberFmtRecord()
266     {
267         return field_4_indexNumberFmtRecord;
268     }
269
270     /**
271      * Set the index number fmt record field for the LinkedData record.
272      */

273     public void setIndexNumberFmtRecord(short field_4_indexNumberFmtRecord)
274     {
275         this.field_4_indexNumberFmtRecord = field_4_indexNumberFmtRecord;
276     }
277
278     /**
279      * Get the formula of link field for the LinkedData record.
280      */

281     public LinkedDataFormulaField getFormulaOfLink()
282     {
283         return field_5_formulaOfLink;
284     }
285
286     /**
287      * Set the formula of link field for the LinkedData record.
288      */

289     public void setFormulaOfLink(LinkedDataFormulaField field_5_formulaOfLink)
290     {
291         this.field_5_formulaOfLink = field_5_formulaOfLink;
292     }
293
294     /**
295      * Sets the custom number format field value.
296      * true if this object has a custom number format
297      */

298     public void setCustomNumberFormat(boolean value)
299     {
300         field_3_options = customNumberFormat.setShortBoolean(field_3_options, value);
301     }
302
303     /**
304      * true if this object has a custom number format
305      * @return the custom number format field value.
306      */

307     public boolean isCustomNumberFormat()
308     {
309         return customNumberFormat.isSet(field_3_options);
310     }
311
312
313 } // END OF CLASS
314

315
316
317
318
Popular Tags