KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* ====================================================================
2    Copyright 2003-2004 Apache Software Foundation
3
4    Licensed under the Apache License, Version 2.0 (the "License");
5    you may not use this file except in compliance with the License.
6    You may obtain a copy of the License at
7
8        http://www.apache.org/licenses/LICENSE-2.0
9
10    Unless required by applicable law or agreed to in writing, software
11    distributed under the License is distributed on an "AS IS" BASIS,
12    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    See the License for the specific language governing permissions and
14    limitations under the License.
15 ==================================================================== */

16
17 package org.apache.poi.hssf.record;
18
19 import org.apache.poi.util.*;
20
21 /**
22  * Record for the top margin.
23  * NOTE: This source was automatically generated.
24  *
25  * @author Shawn Laubach (slaubach at apache dot org)
26  */

27 public class TopMarginRecord extends Record implements Margin
28 {
29     public final static short sid = 0x28;
30     private double field_1_margin;
31
32     public TopMarginRecord() { }
33
34     /**
35      * Constructs a TopMargin record and sets its fields appropriately.
36      *
37      * @param id id must be 0x28 or an exception
38      * will be throw upon validation
39      * @param size size the size of the data area of the record
40      * @param data data of the record (should not contain sid/len)
41      */

42     public TopMarginRecord( short id, short size, byte[] data )
43     { super( id, size, data ); }
44
45     /**
46      * Constructs a TopMargin record and sets its fields appropriately.
47      *
48      * @param id id must be 0x28 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      * @param offset of the record's data
53      */

54     public TopMarginRecord( short id, short size, byte[] data, int offset )
55     { super( id, size, data, offset ); }
56
57     /**
58      * Checks the sid matches the expected side for this record
59      *
60      * @param id the expected sid.
61      */

62     protected void validateSid( short id )
63     {
64         if ( id != sid )
65         {
66             throw new RecordFormatException( "Not a TopMargin record" );
67         }
68     }
69
70     protected void fillFields( byte[] data, short size, int offset )
71     {
72         field_1_margin = LittleEndian.getDouble( data, 0x0 + offset );
73     }
74
75     public String JavaDoc toString()
76     {
77         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
78         buffer.append( "[TopMargin]\n" );
79         buffer.append( " .margin = " ).append( " (" ).append( getMargin() ).append( " )\n" );
80         buffer.append( "[/TopMargin]\n" );
81         return buffer.toString();
82     }
83
84     public int serialize( int offset, byte[] data )
85     {
86         LittleEndian.putShort( data, 0 + offset, sid );
87         LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) );
88         LittleEndian.putDouble( data, 4 + offset, field_1_margin );
89         return getRecordSize();
90     }
91
92     /**
93      * Size of record (exluding 4 byte header)
94      */

95     public int getRecordSize() { return 4 + 8; }
96
97     public short getSid() { return this.sid; }
98
99     /**
100      * Get the margin field for the TopMargin record.
101      */

102     public double getMargin() { return field_1_margin; }
103
104     /**
105      * Set the margin field for the TopMargin record.
106      */

107     public void setMargin( double field_1_margin )
108     { this.field_1_margin = field_1_margin; }
109
110     public Object JavaDoc clone()
111     {
112         TopMarginRecord rec = new TopMarginRecord();
113         rec.field_1_margin = this.field_1_margin;
114         return rec;
115     }
116 } // END OF CLASS
Popular Tags