KickJava   Java API By Example, From Geeks To Geeks.

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


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 dat record is used to store options for the chart.
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 DatRecord
34     extends Record
35 {
36     public final static short sid = 0x1063;
37     private short field_1_options;
38     private BitField horizontalBorder = new BitField(0x1);
39     private BitField verticalBorder = new BitField(0x2);
40     private BitField border = new BitField(0x4);
41     private BitField showSeriesKey = new BitField(0x8);
42
43
44     public DatRecord()
45     {
46
47     }
48
49     /**
50      * Constructs a Dat record and sets its fields appropriately.
51      *
52      * @param id id must be 0x1063 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 DatRecord(short id, short size, byte [] data)
59     {
60         super(id, size, data);
61     
62     }
63
64     /**
65      * Constructs a Dat record and sets its fields appropriately.
66      *
67      * @param id id must be 0x1063 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 DatRecord(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 Dat record");
90         }
91     }
92
93     protected void fillFields(byte [] data, short size, int offset)
94     {
95
96         int pos = 0;
97         field_1_options = LittleEndian.getShort(data, pos + 0x0 + offset);
98
99     }
100
101     public String JavaDoc toString()
102     {
103         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
104
105         buffer.append("[DAT]\n");
106         buffer.append(" .options = ")
107             .append("0x").append(HexDump.toHex( getOptions ()))
108             .append(" (").append( getOptions() ).append(" )");
109         buffer.append(System.getProperty("line.separator"));
110         buffer.append(" .horizontalBorder = ").append(isHorizontalBorder()).append('\n');
111         buffer.append(" .verticalBorder = ").append(isVerticalBorder()).append('\n');
112         buffer.append(" .border = ").append(isBorder()).append('\n');
113         buffer.append(" .showSeriesKey = ").append(isShowSeriesKey()).append('\n');
114
115         buffer.append("[/DAT]\n");
116         return buffer.toString();
117     }
118
119     public int serialize(int offset, byte[] data)
120     {
121         int pos = 0;
122
123         LittleEndian.putShort(data, 0 + offset, sid);
124         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
125
126         LittleEndian.putShort(data, 4 + offset + pos, field_1_options);
127
128         return getRecordSize();
129     }
130
131     /**
132      * Size of record (exluding 4 byte header)
133      */

134     public int getRecordSize()
135     {
136         return 4 + 2;
137     }
138
139     public short getSid()
140     {
141         return this.sid;
142     }
143
144     public Object JavaDoc clone() {
145         DatRecord rec = new DatRecord();
146     
147         rec.field_1_options = field_1_options;
148         return rec;
149     }
150
151
152
153
154     /**
155      * Get the options field for the Dat record.
156      */

157     public short getOptions()
158     {
159         return field_1_options;
160     }
161
162     /**
163      * Set the options field for the Dat record.
164      */

165     public void setOptions(short field_1_options)
166     {
167         this.field_1_options = field_1_options;
168     }
169
170     /**
171      * Sets the horizontal border field value.
172      * has a horizontal border
173      */

174     public void setHorizontalBorder(boolean value)
175     {
176         field_1_options = horizontalBorder.setShortBoolean(field_1_options, value);
177     }
178
179     /**
180      * has a horizontal border
181      * @return the horizontal border field value.
182      */

183     public boolean isHorizontalBorder()
184     {
185         return horizontalBorder.isSet(field_1_options);
186     }
187
188     /**
189      * Sets the vertical border field value.
190      * has vertical border
191      */

192     public void setVerticalBorder(boolean value)
193     {
194         field_1_options = verticalBorder.setShortBoolean(field_1_options, value);
195     }
196
197     /**
198      * has vertical border
199      * @return the vertical border field value.
200      */

201     public boolean isVerticalBorder()
202     {
203         return verticalBorder.isSet(field_1_options);
204     }
205
206     /**
207      * Sets the border field value.
208      * data table has a border
209      */

210     public void setBorder(boolean value)
211     {
212         field_1_options = border.setShortBoolean(field_1_options, value);
213     }
214
215     /**
216      * data table has a border
217      * @return the border field value.
218      */

219     public boolean isBorder()
220     {
221         return border.isSet(field_1_options);
222     }
223
224     /**
225      * Sets the show series key field value.
226      * shows the series key
227      */

228     public void setShowSeriesKey(boolean value)
229     {
230         field_1_options = showSeriesKey.setShortBoolean(field_1_options, value);
231     }
232
233     /**
234      * shows the series key
235      * @return the show series key field value.
236      */

237     public boolean isShowSeriesKey()
238     {
239         return showSeriesKey.isSet(field_1_options);
240     }
241
242
243 } // END OF CLASS
244

245
246
247
248
Popular Tags