001: /* ====================================================================
002: Licensed to the Apache Software Foundation (ASF) under one or more
003: contributor license agreements. See the NOTICE file distributed with
004: this work for additional information regarding copyright ownership.
005: The ASF licenses this file to You under the Apache License, Version 2.0
006: (the "License"); you may not use this file except in compliance with
007: the License. You may obtain a copy of the License at
008:
009: http://www.apache.org/licenses/LICENSE-2.0
010:
011: Unless required by applicable law or agreed to in writing, software
012: distributed under the License is distributed on an "AS IS" BASIS,
013: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: See the License for the specific language governing permissions and
015: limitations under the License.
016: ==================================================================== */
017:
018: package org.apache.poi.hssf.record;
019:
020: import org.apache.poi.util.*;
021:
022: /**
023: * Record for the left margin.
024: * NOTE: This source was automatically generated.
025: * @author Shawn Laubach (slaubach at apache dot org)
026: */
027: public class LeftMarginRecord extends Record implements Margin {
028: public final static short sid = 0x26;
029: private double field_1_margin;
030:
031: public LeftMarginRecord() {
032: }
033:
034: /**
035: * Constructs a LeftMargin record and sets its fields appropriately.
036: *
037: * @param in the RecordInputstream to read the record from
038: */
039: public LeftMarginRecord(RecordInputStream in) {
040: super (in);
041: }
042:
043: /**
044: * Checks the sid matches the expected side for this record
045: *
046: * @param id the expected sid.
047: */
048: protected void validateSid(short id) {
049: if (id != sid) {
050: throw new RecordFormatException("Not a LeftMargin record");
051: }
052: }
053:
054: protected void fillFields(RecordInputStream in) {
055: field_1_margin = in.readDouble();
056: }
057:
058: public String toString() {
059: StringBuffer buffer = new StringBuffer();
060: buffer.append("[LeftMargin]\n");
061: buffer.append(" .margin = ").append(" (")
062: .append(getMargin()).append(" )\n");
063: buffer.append("[/LeftMargin]\n");
064: return buffer.toString();
065: }
066:
067: public int serialize(int offset, byte[] data) {
068: LittleEndian.putShort(data, 0 + offset, sid);
069: LittleEndian.putShort(data, 2 + offset,
070: (short) (getRecordSize() - 4));
071: LittleEndian.putDouble(data, 4 + offset, field_1_margin);
072: return getRecordSize();
073: }
074:
075: /**
076: * Size of record (exluding 4 byte header)
077: */
078: public int getRecordSize() {
079: return 4 + 8;
080: }
081:
082: public short getSid() {
083: return sid;
084: }
085:
086: /**
087: * Get the margin field for the LeftMargin record.
088: */
089: public double getMargin() {
090: return field_1_margin;
091: }
092:
093: /**
094: * Set the margin field for the LeftMargin record.
095: */
096: public void setMargin(double field_1_margin) {
097: this .field_1_margin = field_1_margin;
098: }
099:
100: public Object clone() {
101: LeftMarginRecord rec = new LeftMarginRecord();
102: rec.field_1_margin = this .field_1_margin;
103: return rec;
104: }
105: } // END OF CLASS
|