KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.apache.poi.hssf.record;
20
21 import org.apache.poi.util.LittleEndian;
22
23 /**
24  * End Of File record.
25  * <P>
26  * Description: Marks the end of records belonging to a particular object in the
27  * HSSF File<P>
28  * REFERENCE: PG 307 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
29  * @author Andrew C. Oliver (acoliver at apache dot org)
30  * @author Jason Height (jheight at chariot dot net dot au)
31  * @version 2.0-pre
32  */

33
34 public class EOFRecord
35     extends Record
36 {
37     public final static short sid = 0x0A;
38
39     public EOFRecord()
40     {
41     }
42
43     /**
44      * Constructs a EOFRecord record and sets its fields appropriately.
45      *
46      * @param id id must be 0x0A or an exception will be throw upon validation
47      * @param size the size of the data area of the record
48      * @param data data of the record (should not contain sid/len)
49      */

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

64
65     public EOFRecord(short id, short size, byte [] data, int offset)
66     {
67         super(id, size, data, offset);
68     }
69
70     protected void validateSid(short id)
71     {
72         if (id != sid)
73         {
74             throw new RecordFormatException("NOT An EOF RECORD");
75         }
76     }
77
78     protected void fillFields(byte [] data, short size, int offset)
79     {
80     }
81
82     public String JavaDoc toString()
83     {
84         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
85
86         buffer.append("[EOF]\n");
87         buffer.append("[/EOF]\n");
88         return buffer.toString();
89     }
90
91     public int serialize(int offset, byte [] data)
92     {
93         LittleEndian.putShort(data, 0 + offset, sid);
94         LittleEndian.putShort(data, 2 + offset,
95                               (( short ) 0)); // no record info
96
return getRecordSize();
97     }
98
99     public int getRecordSize()
100     {
101         return 4;
102     }
103
104     public short getSid()
105     {
106         return this.sid;
107     }
108
109     public Object JavaDoc clone() {
110       EOFRecord rec = new EOFRecord();
111       return rec;
112     }
113 }
114
Popular Tags