KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Specifies the window's zoom magnification. If this record isn't present then the windows zoom is 100%. see p384 Excel Dev Kit
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 SCLRecord
34     extends Record
35 {
36     public final static short sid = 0xa0;
37     private short field_1_numerator;
38     private short field_2_denominator;
39
40
41     public SCLRecord()
42     {
43
44     }
45
46     /**
47      * Constructs a SCL record and sets its fields appropriately.
48      *
49      * @param id id must be 0xa0 or an exception
50      * will be throw upon validation
51      * @param size size the size of the data area of the record
52      * @param data data of the record (should not contain sid/len)
53      */

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

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

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

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

157     public short getNumerator()
158     {
159         return field_1_numerator;
160     }
161
162     /**
163      * Set the numerator field for the SCL record.
164      */

165     public void setNumerator(short field_1_numerator)
166     {
167         this.field_1_numerator = field_1_numerator;
168     }
169
170     /**
171      * Get the denominator field for the SCL record.
172      */

173     public short getDenominator()
174     {
175         return field_2_denominator;
176     }
177
178     /**
179      * Set the denominator field for the SCL record.
180      */

181     public void setDenominator(short field_2_denominator)
182     {
183         this.field_2_denominator = field_2_denominator;
184     }
185
186
187 } // END OF CLASS
188

189
190
191
192
Popular Tags