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 top margin.
024: * NOTE: This source was automatically generated.
025: *
026: * @author Shawn Laubach (slaubach at apache dot org)
027: */
028: public class TopMarginRecord extends Record implements Margin {
029: public final static short sid = 0x28;
030: private double field_1_margin;
031:
032: public TopMarginRecord() {
033: }
034:
035: /**
036: * Constructs a TopMargin record and sets its fields appropriately.
037: *
038: * @param in the RecordInputstream to read the record from
039: */
040: public TopMarginRecord(RecordInputStream in) {
041: super (in);
042: }
043:
044: /**
045: * Checks the sid matches the expected side for this record
046: *
047: * @param id the expected sid.
048: */
049: protected void validateSid(short id) {
050: if (id != sid) {
051: throw new RecordFormatException("Not a TopMargin record");
052: }
053: }
054:
055: /**
056: * @param in the RecordInputstream to read the record from
057: */
058: protected void fillFields(RecordInputStream in) {
059: field_1_margin = in.readDouble();
060: }
061:
062: public String toString() {
063: StringBuffer buffer = new StringBuffer();
064: buffer.append("[TopMargin]\n");
065: buffer.append(" .margin = ").append(" (")
066: .append(getMargin()).append(" )\n");
067: buffer.append("[/TopMargin]\n");
068: return buffer.toString();
069: }
070:
071: public int serialize(int offset, byte[] data) {
072: LittleEndian.putShort(data, 0 + offset, sid);
073: LittleEndian.putShort(data, 2 + offset,
074: (short) (getRecordSize() - 4));
075: LittleEndian.putDouble(data, 4 + offset, field_1_margin);
076: return getRecordSize();
077: }
078:
079: /**
080: * Size of record (exluding 4 byte header)
081: */
082: public int getRecordSize() {
083: return 4 + 8;
084: }
085:
086: public short getSid() {
087: return sid;
088: }
089:
090: /**
091: * Get the margin field for the TopMargin record.
092: */
093: public double getMargin() {
094: return field_1_margin;
095: }
096:
097: /**
098: * Set the margin field for the TopMargin record.
099: */
100: public void setMargin(double field_1_margin) {
101: this .field_1_margin = field_1_margin;
102: }
103:
104: public Object clone() {
105: TopMarginRecord rec = new TopMarginRecord();
106: rec.field_1_margin = this .field_1_margin;
107: return rec;
108: }
109: } // END OF CLASS
|