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: * Describes a linked data record. This record referes to the series data or text.
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 LinkedDataRecord extends Record {
030: public final static short sid = 0x1051;
031: private byte field_1_linkType;
032: public final static byte LINK_TYPE_TITLE_OR_TEXT = 0;
033: public final static byte LINK_TYPE_VALUES = 1;
034: public final static byte LINK_TYPE_CATEGORIES = 2;
035: private byte field_2_referenceType;
036: public final static byte REFERENCE_TYPE_DEFAULT_CATEGORIES = 0;
037: public final static byte REFERENCE_TYPE_DIRECT = 1;
038: public final static byte REFERENCE_TYPE_WORKSHEET = 2;
039: public final static byte REFERENCE_TYPE_NOT_USED = 3;
040: public final static byte REFERENCE_TYPE_ERROR_REPORTED = 4;
041: private short field_3_options;
042: private BitField customNumberFormat = BitFieldFactory
043: .getInstance(0x1);
044: private short field_4_indexNumberFmtRecord;
045: private LinkedDataFormulaField field_5_formulaOfLink;
046:
047: public LinkedDataRecord() {
048:
049: }
050:
051: /**
052: * Constructs a LinkedData record and sets its fields appropriately.
053: *
054: * @param in the RecordInputstream to read the record from
055: */
056:
057: public LinkedDataRecord(RecordInputStream in) {
058: super (in);
059:
060: }
061:
062: /**
063: * Checks the sid matches the expected side for this record
064: *
065: * @param id the expected sid.
066: */
067: protected void validateSid(short id) {
068: if (id != sid) {
069: throw new RecordFormatException("Not a LinkedData record");
070: }
071: }
072:
073: protected void fillFields(RecordInputStream in) {
074: field_1_linkType = in.readByte();
075: field_2_referenceType = in.readByte();
076: field_3_options = in.readShort();
077: field_4_indexNumberFmtRecord = in.readShort();
078: field_5_formulaOfLink = new org.apache.poi.hssf.record.LinkedDataFormulaField();
079: field_5_formulaOfLink.fillField(in);
080: }
081:
082: public String toString() {
083: StringBuffer buffer = new StringBuffer();
084:
085: buffer.append("[AI]\n");
086: buffer.append(" .linkType = ").append("0x")
087: .append(HexDump.toHex(getLinkType())).append(" (")
088: .append(getLinkType()).append(" )");
089: buffer.append(System.getProperty("line.separator"));
090: buffer.append(" .referenceType = ").append("0x")
091: .append(HexDump.toHex(getReferenceType())).append(" (")
092: .append(getReferenceType()).append(" )");
093: buffer.append(System.getProperty("line.separator"));
094: buffer.append(" .options = ").append("0x")
095: .append(HexDump.toHex(getOptions())).append(" (")
096: .append(getOptions()).append(" )");
097: buffer.append(System.getProperty("line.separator"));
098: buffer.append(" .customNumberFormat = ").append(
099: isCustomNumberFormat()).append('\n');
100: buffer.append(" .indexNumberFmtRecord = ").append("0x")
101: .append(HexDump.toHex(getIndexNumberFmtRecord()))
102: .append(" (").append(getIndexNumberFmtRecord()).append(
103: " )");
104: buffer.append(System.getProperty("line.separator"));
105: buffer.append(" .formulaOfLink = ").append(" (")
106: .append(getFormulaOfLink()).append(" )");
107: buffer.append(System.getProperty("line.separator"));
108:
109: buffer.append("[/AI]\n");
110: return buffer.toString();
111: }
112:
113: public int serialize(int offset, byte[] data) {
114: int pos = 0;
115:
116: LittleEndian.putShort(data, 0 + offset, sid);
117: LittleEndian.putShort(data, 2 + offset,
118: (short) (getRecordSize() - 4));
119:
120: data[4 + offset + pos] = field_1_linkType;
121: data[5 + offset + pos] = field_2_referenceType;
122: LittleEndian.putShort(data, 6 + offset + pos, field_3_options);
123: LittleEndian.putShort(data, 8 + offset + pos,
124: field_4_indexNumberFmtRecord);
125: pos += field_5_formulaOfLink.serializeField(pos + 10 + offset,
126: data);
127:
128: return getRecordSize();
129: }
130:
131: /**
132: * Size of record (exluding 4 byte header)
133: */
134: public int getRecordSize() {
135: return 4 + 1 + 1 + 2 + 2 + field_5_formulaOfLink.getSize();
136: }
137:
138: public short getSid() {
139: return sid;
140: }
141:
142: public Object clone() {
143: LinkedDataRecord rec = new LinkedDataRecord();
144:
145: rec.field_1_linkType = field_1_linkType;
146: rec.field_2_referenceType = field_2_referenceType;
147: rec.field_3_options = field_3_options;
148: rec.field_4_indexNumberFmtRecord = field_4_indexNumberFmtRecord;
149: rec.field_5_formulaOfLink = ((org.apache.poi.hssf.record.LinkedDataFormulaField) field_5_formulaOfLink
150: .clone());
151: ;
152: return rec;
153: }
154:
155: /**
156: * Get the link type field for the LinkedData record.
157: *
158: * @return One of
159: * LINK_TYPE_TITLE_OR_TEXT
160: * LINK_TYPE_VALUES
161: * LINK_TYPE_CATEGORIES
162: */
163: public byte getLinkType() {
164: return field_1_linkType;
165: }
166:
167: /**
168: * Set the link type field for the LinkedData record.
169: *
170: * @param field_1_linkType
171: * One of
172: * LINK_TYPE_TITLE_OR_TEXT
173: * LINK_TYPE_VALUES
174: * LINK_TYPE_CATEGORIES
175: */
176: public void setLinkType(byte field_1_linkType) {
177: this .field_1_linkType = field_1_linkType;
178: }
179:
180: /**
181: * Get the reference type field for the LinkedData record.
182: *
183: * @return One of
184: * REFERENCE_TYPE_DEFAULT_CATEGORIES
185: * REFERENCE_TYPE_DIRECT
186: * REFERENCE_TYPE_WORKSHEET
187: * REFERENCE_TYPE_NOT_USED
188: * REFERENCE_TYPE_ERROR_REPORTED
189: */
190: public byte getReferenceType() {
191: return field_2_referenceType;
192: }
193:
194: /**
195: * Set the reference type field for the LinkedData record.
196: *
197: * @param field_2_referenceType
198: * One of
199: * REFERENCE_TYPE_DEFAULT_CATEGORIES
200: * REFERENCE_TYPE_DIRECT
201: * REFERENCE_TYPE_WORKSHEET
202: * REFERENCE_TYPE_NOT_USED
203: * REFERENCE_TYPE_ERROR_REPORTED
204: */
205: public void setReferenceType(byte field_2_referenceType) {
206: this .field_2_referenceType = field_2_referenceType;
207: }
208:
209: /**
210: * Get the options field for the LinkedData record.
211: */
212: public short getOptions() {
213: return field_3_options;
214: }
215:
216: /**
217: * Set the options field for the LinkedData record.
218: */
219: public void setOptions(short field_3_options) {
220: this .field_3_options = field_3_options;
221: }
222:
223: /**
224: * Get the index number fmt record field for the LinkedData record.
225: */
226: public short getIndexNumberFmtRecord() {
227: return field_4_indexNumberFmtRecord;
228: }
229:
230: /**
231: * Set the index number fmt record field for the LinkedData record.
232: */
233: public void setIndexNumberFmtRecord(
234: short field_4_indexNumberFmtRecord) {
235: this .field_4_indexNumberFmtRecord = field_4_indexNumberFmtRecord;
236: }
237:
238: /**
239: * Get the formula of link field for the LinkedData record.
240: */
241: public LinkedDataFormulaField getFormulaOfLink() {
242: return field_5_formulaOfLink;
243: }
244:
245: /**
246: * Set the formula of link field for the LinkedData record.
247: */
248: public void setFormulaOfLink(
249: LinkedDataFormulaField field_5_formulaOfLink) {
250: this .field_5_formulaOfLink = field_5_formulaOfLink;
251: }
252:
253: /**
254: * Sets the custom number format field value.
255: * true if this object has a custom number format
256: */
257: public void setCustomNumberFormat(boolean value) {
258: field_3_options = customNumberFormat.setShortBoolean(
259: field_3_options, value);
260: }
261:
262: /**
263: * true if this object has a custom number format
264: * @return the custom number format field value.
265: */
266: public boolean isCustomNumberFormat() {
267: return customNumberFormat.isSet(field_3_options);
268: }
269:
270: } // END OF CLASS
|