KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.apache.poi.util.*;
21
22 /**
23  * Record for the right margin. * NOTE: This source was automatically generated. * @author Shawn Laubach (slaubach at apache dot org)
24  */

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

35     public RightMarginRecord( short id, short size, byte[] data )
36     { super( id, size, data ); }
37
38     /**
39      * Constructs a RightMargin record and sets its fields appropriately. * * @param id id must be 0x27 or an exception * will be throw upon validation * @param size size the size of the data area of the record * @param data data of the record (should not contain sid/len) * @param offset of the record's data
40      */

41     public RightMarginRecord( short id, short size, byte[] data, int offset )
42     { super( id, size, data, offset ); }
43
44     /**
45      * Checks the sid matches the expected side for this record * * @param id the expected sid.
46      */

47     protected void validateSid( short id )
48     {
49         if ( id != sid )
50         {
51             throw new RecordFormatException( "Not a RightMargin record" );
52         }
53     }
54
55     protected void fillFields( byte[] data, short size, int offset )
56     {
57         field_1_margin = LittleEndian.getDouble( data, 0x0 + offset );
58     }
59
60     public String JavaDoc toString()
61     {
62         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
63         buffer.append( "[RightMargin]\n" );
64         buffer.append( " .margin = " ).append( " (" ).append( getMargin() ).append( " )\n" );
65         buffer.append( "[/RightMargin]\n" );
66         return buffer.toString();
67     }
68
69     public int serialize( int offset, byte[] data )
70     {
71         LittleEndian.putShort( data, 0 + offset, sid );
72         LittleEndian.putShort( data, 2 + offset, (short) ( getRecordSize() - 4 ) );
73         LittleEndian.putDouble( data, 4 + offset, field_1_margin );
74         return getRecordSize();
75     }
76
77     /**
78      * Size of record (exluding 4 byte header)
79      */

80     public int getRecordSize() { return 4 + 8; }
81
82     public short getSid() { return this.sid; }
83
84     /**
85      * Get the margin field for the RightMargin record.
86      */

87     public double getMargin() { return field_1_margin; }
88
89     /**
90      * Set the margin field for the RightMargin record.
91      */

92     public void setMargin( double field_1_margin )
93     { this.field_1_margin = field_1_margin; }
94
95     public Object JavaDoc clone()
96     {
97         RightMarginRecord rec = new RightMarginRecord();
98         rec.field_1_margin = this.field_1_margin;
99         return rec;
100     }
101 } // END OF CLASS
Popular Tags