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: * The units record describes units.
024: * NOTE: This source is automatically generated please do not modify this file. Either subclass or
025: * remove the record in src/records/definitions.
026:
027: * @author Glen Stampoultzis (glens at apache.org)
028: */
029: public class UnitsRecord extends Record {
030: public final static short sid = 0x1001;
031: private short field_1_units;
032:
033: public UnitsRecord() {
034:
035: }
036:
037: /**
038: * Constructs a Units record and sets its fields appropriately.
039: *
040: * @param in the RecordInputstream to read the record from
041: */
042: public UnitsRecord(RecordInputStream in) {
043: super (in);
044:
045: }
046:
047: /**
048: * Checks the sid matches the expected side for this record
049: *
050: * @param id the expected sid.
051: */
052: protected void validateSid(short id) {
053: if (id != sid) {
054: throw new RecordFormatException("Not a Units record");
055: }
056: }
057:
058: protected void fillFields(RecordInputStream in) {
059: field_1_units = in.readShort();
060:
061: }
062:
063: public String toString() {
064: StringBuffer buffer = new StringBuffer();
065:
066: buffer.append("[UNITS]\n");
067: buffer.append(" .units = ").append("0x")
068: .append(HexDump.toHex(getUnits())).append(" (").append(
069: getUnits()).append(" )");
070: buffer.append(System.getProperty("line.separator"));
071:
072: buffer.append("[/UNITS]\n");
073: return buffer.toString();
074: }
075:
076: public int serialize(int offset, byte[] data) {
077: int pos = 0;
078:
079: LittleEndian.putShort(data, 0 + offset, sid);
080: LittleEndian.putShort(data, 2 + offset,
081: (short) (getRecordSize() - 4));
082:
083: LittleEndian.putShort(data, 4 + offset + pos, field_1_units);
084:
085: return getRecordSize();
086: }
087:
088: /**
089: * Size of record (exluding 4 byte header)
090: */
091: public int getRecordSize() {
092: return 4 + 2;
093: }
094:
095: public short getSid() {
096: return sid;
097: }
098:
099: public Object clone() {
100: UnitsRecord rec = new UnitsRecord();
101:
102: rec.field_1_units = field_1_units;
103: return rec;
104: }
105:
106: /**
107: * Get the units field for the Units record.
108: */
109: public short getUnits() {
110: return field_1_units;
111: }
112:
113: /**
114: * Set the units field for the Units record.
115: */
116: public void setUnits(short field_1_units) {
117: this .field_1_units = field_1_units;
118: }
119:
120: } // END OF CLASS
|