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: * Defines a series name
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 Andrew C. Oliver (acoliver at apache.org)
028: */
029: public class SeriesTextRecord extends Record {
030: public final static short sid = 0x100d;
031: private short field_1_id;
032: private byte field_2_textLength;
033: private byte field_3_undocumented;
034: private String field_4_text;
035:
036: public SeriesTextRecord() {
037:
038: }
039:
040: /**
041: * Constructs a SeriesText record and sets its fields appropriately.
042: *
043: * @param in the RecordInputstream to read the record from
044: */
045:
046: public SeriesTextRecord(RecordInputStream in) {
047: super (in);
048:
049: }
050:
051: /**
052: * Checks the sid matches the expected side for this record
053: *
054: * @param id the expected sid.
055: */
056: protected void validateSid(short id) {
057: if (id != sid) {
058: throw new RecordFormatException("Not a SeriesText record");
059: }
060: }
061:
062: protected void fillFields(RecordInputStream in) {
063: field_1_id = in.readShort();
064: field_2_textLength = in.readByte();
065: field_3_undocumented = in.readByte();
066: field_4_text = in.readUnicodeLEString(field_2_textLength);
067: }
068:
069: public String toString() {
070: StringBuffer buffer = new StringBuffer();
071:
072: buffer.append("[SERIESTEXT]\n");
073: buffer.append(" .id = ").append("0x")
074: .append(HexDump.toHex(getId())).append(" (").append(
075: getId()).append(" )");
076: buffer.append(System.getProperty("line.separator"));
077: buffer.append(" .textLength = ").append("0x")
078: .append(HexDump.toHex(getTextLength())).append(" (")
079: .append(getTextLength()).append(" )");
080: buffer.append(System.getProperty("line.separator"));
081: buffer.append(" .undocumented = ").append("0x")
082: .append(HexDump.toHex(getUndocumented())).append(" (")
083: .append(getUndocumented()).append(" )");
084: buffer.append(System.getProperty("line.separator"));
085: buffer.append(" .text = ").append(" (")
086: .append(getText()).append(" )");
087: buffer.append(System.getProperty("line.separator"));
088:
089: buffer.append("[/SERIESTEXT]\n");
090: return buffer.toString();
091: }
092:
093: public int serialize(int offset, byte[] data) {
094: int pos = 0;
095:
096: LittleEndian.putShort(data, 0 + offset, sid);
097: LittleEndian.putShort(data, 2 + offset,
098: (short) (getRecordSize() - 4));
099:
100: LittleEndian.putShort(data, 4 + offset + pos, field_1_id);
101: data[6 + offset + pos] = field_2_textLength;
102: data[7 + offset + pos] = field_3_undocumented;
103: StringUtil.putUnicodeLE(field_4_text, data, 8 + offset + pos);
104:
105: return getRecordSize();
106: }
107:
108: /**
109: * Size of record (exluding 4 byte header)
110: */
111: public int getRecordSize() {
112: return 4 + 2 + 1 + 1 + (field_2_textLength * 2);
113: }
114:
115: public short getSid() {
116: return sid;
117: }
118:
119: public Object clone() {
120: SeriesTextRecord rec = new SeriesTextRecord();
121:
122: rec.field_1_id = field_1_id;
123: rec.field_2_textLength = field_2_textLength;
124: rec.field_3_undocumented = field_3_undocumented;
125: rec.field_4_text = field_4_text;
126: return rec;
127: }
128:
129: /**
130: * Get the id field for the SeriesText record.
131: */
132: public short getId() {
133: return field_1_id;
134: }
135:
136: /**
137: * Set the id field for the SeriesText record.
138: */
139: public void setId(short field_1_id) {
140: this .field_1_id = field_1_id;
141: }
142:
143: /**
144: * Get the text length field for the SeriesText record.
145: */
146: public byte getTextLength() {
147: return field_2_textLength;
148: }
149:
150: /**
151: * Set the text length field for the SeriesText record.
152: */
153: public void setTextLength(byte field_2_textLength) {
154: this .field_2_textLength = field_2_textLength;
155: }
156:
157: /**
158: * Get the undocumented field for the SeriesText record.
159: */
160: public byte getUndocumented() {
161: return field_3_undocumented;
162: }
163:
164: /**
165: * Set the undocumented field for the SeriesText record.
166: */
167: public void setUndocumented(byte field_3_undocumented) {
168: this .field_3_undocumented = field_3_undocumented;
169: }
170:
171: /**
172: * Get the text field for the SeriesText record.
173: */
174: public String getText() {
175: return field_4_text;
176: }
177:
178: /**
179: * Set the text field for the SeriesText record.
180: */
181: public void setText(String field_4_text) {
182: this .field_4_text = field_4_text;
183: }
184:
185: } // END OF CLASS
|