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 font index record indexes into the font table for the text record.
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 FontIndexRecord extends Record {
030: public final static short sid = 0x1026;
031: private short field_1_fontIndex;
032:
033: public FontIndexRecord() {
034:
035: }
036:
037: /**
038: * Constructs a FontIndex record and sets its fields appropriately.
039: *
040: * @param in the RecordInputstream to read the record from
041: */
042:
043: public FontIndexRecord(RecordInputStream in) {
044: super (in);
045:
046: }
047:
048: /**
049: * Checks the sid matches the expected side for this record
050: *
051: * @param id the expected sid.
052: */
053: protected void validateSid(short id) {
054: if (id != sid) {
055: throw new RecordFormatException("Not a FontIndex record");
056: }
057: }
058:
059: protected void fillFields(RecordInputStream in) {
060: field_1_fontIndex = in.readShort();
061: }
062:
063: public String toString() {
064: StringBuffer buffer = new StringBuffer();
065:
066: buffer.append("[FONTX]\n");
067: buffer.append(" .fontIndex = ").append("0x")
068: .append(HexDump.toHex(getFontIndex())).append(" (")
069: .append(getFontIndex()).append(" )");
070: buffer.append(System.getProperty("line.separator"));
071:
072: buffer.append("[/FONTX]\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
084: .putShort(data, 4 + offset + pos, field_1_fontIndex);
085:
086: return getRecordSize();
087: }
088:
089: /**
090: * Size of record (exluding 4 byte header)
091: */
092: public int getRecordSize() {
093: return 4 + 2;
094: }
095:
096: public short getSid() {
097: return sid;
098: }
099:
100: public Object clone() {
101: FontIndexRecord rec = new FontIndexRecord();
102:
103: rec.field_1_fontIndex = field_1_fontIndex;
104: return rec;
105: }
106:
107: /**
108: * Get the font index field for the FontIndex record.
109: */
110: public short getFontIndex() {
111: return field_1_fontIndex;
112: }
113:
114: /**
115: * Set the font index field for the FontIndex record.
116: */
117: public void setFontIndex(short field_1_fontIndex) {
118: this .field_1_fontIndex = field_1_fontIndex;
119: }
120:
121: } // END OF CLASS
|