KickJava   Java API By Example, From Geeks To Geeks.

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


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
18 package org.apache.poi.hssf.record;
19
20
21 import org.apache.poi.util.*;
22
23
24 /**
25  * Record for the bottom margin.
26  * NOTE: This source was automatically generated.
27  *
28  * @author Shawn Laubach (slaubach at apache dot org)
29  */

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

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

63     public BottomMarginRecord( short id, short size, byte[] data, int offset )
64     {
65         super( id, size, data, offset );
66     }
67
68     /**
69      * Checks the sid matches the expected side for this record
70      *
71      * @param id the expected sid.
72      */

73     protected void validateSid( short id )
74     {
75         if ( id != sid )
76         {
77             throw new RecordFormatException( "Not a BottomMargin record" );
78         }
79     }
80
81     protected void fillFields( byte[] data, short size, int offset )
82     {
83         field_1_margin = LittleEndian.getDouble( data, 0x0 + offset );
84     }
85
86     public String JavaDoc toString()
87     {
88         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
89         buffer.append( "[BottomMargin]\n" );
90         buffer.append( " .margin = " )
91                 .append( " (" ).append( getMargin() ).append( " )\n" );
92         buffer.append( "[/BottomMargin]\n" );
93         return buffer.toString();
94     }
95
96     public int serialize( int offset, byte[] data )
97     {
98         LittleEndian.putShort( data, 0 + offset, sid );
99         LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) );
100         LittleEndian.putDouble( data, 4 + offset, field_1_margin );
101         return getRecordSize();
102     }
103
104     /**
105      * Size of record (exluding 4 byte header)
106      */

107     public int getRecordSize()
108     {
109         return 4 + 8;
110     }
111
112     public short getSid()
113     {
114         return this.sid;
115     }
116
117     /**
118      * Get the margin field for the BottomMargin record.
119      */

120     public double getMargin()
121     {
122         return field_1_margin;
123     }
124
125     /**
126      * Set the margin field for the BottomMargin record.
127      */

128     public void setMargin( double field_1_margin )
129     {
130         this.field_1_margin = field_1_margin;
131     }
132
133     public Object JavaDoc clone()
134     {
135         BottomMarginRecord rec = new BottomMarginRecord();
136         rec.field_1_margin = this.field_1_margin;
137         return rec;
138     }
139
140 } // END OF CLASS
141
Popular Tags