01: /* ====================================================================
02: Licensed to the Apache Software Foundation (ASF) under one or more
03: contributor license agreements. See the NOTICE file distributed with
04: this work for additional information regarding copyright ownership.
05: The ASF licenses this file to You under the Apache License, Version 2.0
06: (the "License"); you may not use this file except in compliance with
07: the License. You may obtain a copy of the License at
08:
09: 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: 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: public final static short sid = 0x27;
27: private double field_1_margin;
28:
29: public RightMarginRecord() {
30: }
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(RecordInputStream in) {
36: super (in);
37: }
38:
39: /**
40: * Checks the sid matches the expected side for this record * * @param id the expected sid.
41: */
42: protected void validateSid(short id) {
43: if (id != sid) {
44: throw new RecordFormatException("Not a RightMargin record");
45: }
46: }
47:
48: protected void fillFields(RecordInputStream in) {
49: field_1_margin = in.readDouble();
50: }
51:
52: public String toString() {
53: StringBuffer buffer = new StringBuffer();
54: buffer.append("[RightMargin]\n");
55: buffer.append(" .margin = ").append(" (")
56: .append(getMargin()).append(" )\n");
57: buffer.append("[/RightMargin]\n");
58: return buffer.toString();
59: }
60:
61: public int serialize(int offset, byte[] data) {
62: LittleEndian.putShort(data, 0 + offset, sid);
63: LittleEndian.putShort(data, 2 + offset,
64: (short) (getRecordSize() - 4));
65: LittleEndian.putDouble(data, 4 + offset, field_1_margin);
66: return getRecordSize();
67: }
68:
69: /**
70: * Size of record (exluding 4 byte header)
71: */
72: public int getRecordSize() {
73: return 4 + 8;
74: }
75:
76: public short getSid() {
77: return sid;
78: }
79:
80: /**
81: * Get the margin field for the RightMargin record.
82: */
83: public double getMargin() {
84: return field_1_margin;
85: }
86:
87: /**
88: * Set the margin field for the RightMargin record.
89: */
90: public void setMargin(double field_1_margin) {
91: this .field_1_margin = field_1_margin;
92: }
93:
94: public Object clone() {
95: RightMarginRecord rec = new RightMarginRecord();
96: rec.field_1_margin = this .field_1_margin;
97: return rec;
98: }
99: } // END OF CLASS
|