KickJava   Java API By Example, From Geeks To Geeks.

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


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  * The end record defines the end of a block of records for a (Graphing)
25  * data object. This record is matched with a corresponding BeginRecord.
26  *
27  * @see BeginRecord
28  *
29  * @author Glen Stampoultzis (glens at apache.org)
30  */

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

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

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