KickJava   Java API By Example, From Geeks To Geeks.

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


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 font index record indexes into the font table for the text record.
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 FontIndexRecord
34     extends Record
35 {
36     public final static short sid = 0x1026;
37     private short field_1_fontIndex;
38
39
40     public FontIndexRecord()
41     {
42
43     }
44
45     /**
46      * Constructs a FontIndex record and sets its fields appropriately.
47      *
48      * @param id id must be 0x1026 or an exception
49      * will be throw upon validation
50      * @param size size the size of the data area of the record
51      * @param data data of the record (should not contain sid/len)
52      */

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

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

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

126     public int getRecordSize()
127     {
128         return 4 + 2;
129     }
130
131     public short getSid()
132     {
133         return this.sid;
134     }
135
136     public Object JavaDoc clone() {
137         FontIndexRecord rec = new FontIndexRecord();
138     
139         rec.field_1_fontIndex = field_1_fontIndex;
140         return rec;
141     }
142
143
144
145
146     /**
147      * Get the font index field for the FontIndex record.
148      */

149     public short getFontIndex()
150     {
151         return field_1_fontIndex;
152     }
153
154     /**
155      * Set the font index field for the FontIndex record.
156      */

157     public void setFontIndex(short field_1_fontIndex)
158     {
159         this.field_1_fontIndex = field_1_fontIndex;
160     }
161
162
163 } // END OF CLASS
164

165
166
167
168
Popular Tags