KickJava   Java API By Example, From Geeks To Geeks.

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


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 left margin.
23  * NOTE: This source was automatically generated.
24  * @author Shawn Laubach (slaubach at apache dot org)
25  */

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

41     public LeftMarginRecord( short id, short size, byte[] data )
42     { super( id, size, data ); }
43
44     /**
45      * Constructs a LeftMargin record and sets its fields appropriately.
46      * @param id id must be 0x26 or an exception
47      * will be throw upon validation
48      * @param size size the size of the data area of the record
49      * @param data data of the record (should not contain sid/len)
50      * @param offset of the record's data
51      */

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

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

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

104     public double getMargin() {
105         return field_1_margin;
106     }
107
108     /**
109      * Set the margin field for the LeftMargin record.
110      */

111     public void setMargin( double field_1_margin )
112     {
113         this.field_1_margin = field_1_margin;
114     }
115
116     public Object JavaDoc clone()
117     {
118         LeftMarginRecord rec = new LeftMarginRecord();
119         rec.field_1_margin = this.field_1_margin;
120         return rec;
121     }
122 } // END OF CLASS
Popular Tags