KickJava   Java API By Example, From Geeks To Geeks.

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


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  * The data format record is used to index into a series.
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 DataFormatRecord
34     extends Record
35 {
36     public final static short sid = 0x1006;
37     private short field_1_pointNumber;
38     private short field_2_seriesIndex;
39     private short field_3_seriesNumber;
40     private short field_4_formatFlags;
41     private BitField useExcel4Colors = new BitField(0x1);
42
43
44     public DataFormatRecord()
45     {
46
47     }
48
49     /**
50      * Constructs a DataFormat record and sets its fields appropriately.
51      *
52      * @param id id must be 0x1006 or an exception
53      * will be throw upon validation
54      * @param size size the size of the data area of the record
55      * @param data data of the record (should not contain sid/len)
56      */

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

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

85     protected void validateSid(short id)
86     {
87         if (id != sid)
88         {
89             throw new RecordFormatException("Not a DataFormat record");
90         }
91     }
92
93     protected void fillFields(byte [] data, short size, int offset)
94     {
95
96         int pos = 0;
97         field_1_pointNumber = LittleEndian.getShort(data, pos + 0x0 + offset);
98         field_2_seriesIndex = LittleEndian.getShort(data, pos + 0x2 + offset);
99         field_3_seriesNumber = LittleEndian.getShort(data, pos + 0x4 + offset);
100         field_4_formatFlags = LittleEndian.getShort(data, pos + 0x6 + offset);
101
102     }
103
104     public String JavaDoc toString()
105     {
106         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
107
108         buffer.append("[DATAFORMAT]\n");
109         buffer.append(" .pointNumber = ")
110             .append("0x").append(HexDump.toHex( getPointNumber ()))
111             .append(" (").append( getPointNumber() ).append(" )");
112         buffer.append(System.getProperty("line.separator"));
113         buffer.append(" .seriesIndex = ")
114             .append("0x").append(HexDump.toHex( getSeriesIndex ()))
115             .append(" (").append( getSeriesIndex() ).append(" )");
116         buffer.append(System.getProperty("line.separator"));
117         buffer.append(" .seriesNumber = ")
118             .append("0x").append(HexDump.toHex( getSeriesNumber ()))
119             .append(" (").append( getSeriesNumber() ).append(" )");
120         buffer.append(System.getProperty("line.separator"));
121         buffer.append(" .formatFlags = ")
122             .append("0x").append(HexDump.toHex( getFormatFlags ()))
123             .append(" (").append( getFormatFlags() ).append(" )");
124         buffer.append(System.getProperty("line.separator"));
125         buffer.append(" .useExcel4Colors = ").append(isUseExcel4Colors()).append('\n');
126
127         buffer.append("[/DATAFORMAT]\n");
128         return buffer.toString();
129     }
130
131     public int serialize(int offset, byte[] data)
132     {
133         int pos = 0;
134
135         LittleEndian.putShort(data, 0 + offset, sid);
136         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
137
138         LittleEndian.putShort(data, 4 + offset + pos, field_1_pointNumber);
139         LittleEndian.putShort(data, 6 + offset + pos, field_2_seriesIndex);
140         LittleEndian.putShort(data, 8 + offset + pos, field_3_seriesNumber);
141         LittleEndian.putShort(data, 10 + offset + pos, field_4_formatFlags);
142
143         return getRecordSize();
144     }
145
146     /**
147      * Size of record (exluding 4 byte header)
148      */

149     public int getRecordSize()
150     {
151         return 4 + 2 + 2 + 2 + 2;
152     }
153
154     public short getSid()
155     {
156         return this.sid;
157     }
158
159     public Object JavaDoc clone() {
160         DataFormatRecord rec = new DataFormatRecord();
161     
162         rec.field_1_pointNumber = field_1_pointNumber;
163         rec.field_2_seriesIndex = field_2_seriesIndex;
164         rec.field_3_seriesNumber = field_3_seriesNumber;
165         rec.field_4_formatFlags = field_4_formatFlags;
166         return rec;
167     }
168
169
170
171
172     /**
173      * Get the point number field for the DataFormat record.
174      */

175     public short getPointNumber()
176     {
177         return field_1_pointNumber;
178     }
179
180     /**
181      * Set the point number field for the DataFormat record.
182      */

183     public void setPointNumber(short field_1_pointNumber)
184     {
185         this.field_1_pointNumber = field_1_pointNumber;
186     }
187
188     /**
189      * Get the series index field for the DataFormat record.
190      */

191     public short getSeriesIndex()
192     {
193         return field_2_seriesIndex;
194     }
195
196     /**
197      * Set the series index field for the DataFormat record.
198      */

199     public void setSeriesIndex(short field_2_seriesIndex)
200     {
201         this.field_2_seriesIndex = field_2_seriesIndex;
202     }
203
204     /**
205      * Get the series number field for the DataFormat record.
206      */

207     public short getSeriesNumber()
208     {
209         return field_3_seriesNumber;
210     }
211
212     /**
213      * Set the series number field for the DataFormat record.
214      */

215     public void setSeriesNumber(short field_3_seriesNumber)
216     {
217         this.field_3_seriesNumber = field_3_seriesNumber;
218     }
219
220     /**
221      * Get the format flags field for the DataFormat record.
222      */

223     public short getFormatFlags()
224     {
225         return field_4_formatFlags;
226     }
227
228     /**
229      * Set the format flags field for the DataFormat record.
230      */

231     public void setFormatFlags(short field_4_formatFlags)
232     {
233         this.field_4_formatFlags = field_4_formatFlags;
234     }
235
236     /**
237      * Sets the use excel 4 colors field value.
238      * set true to use excel 4 colors.
239      */

240     public void setUseExcel4Colors(boolean value)
241     {
242         field_4_formatFlags = useExcel4Colors.setShortBoolean(field_4_formatFlags, value);
243     }
244
245     /**
246      * set true to use excel 4 colors.
247      * @return the use excel 4 colors field value.
248      */

249     public boolean isUseExcel4Colors()
250     {
251         return useExcel4Colors.isSet(field_4_formatFlags);
252     }
253
254
255 } // END OF CLASS
256

257
258
259
260
Popular Tags