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.LittleEndian;
021:
022: /**
023: * Title: Function Group Count Record<P>
024: * Description: Number of built in function groups in the current version of the
025: * Spreadsheet (probably only used on Windoze)<P>
026: * REFERENCE: PG 315 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
027: * @author Andrew C. Oliver (acoliver at apache dot org)
028: * @version 2.0-pre
029: */
030:
031: public class FnGroupCountRecord extends Record {
032: public final static short sid = 0x9c;
033:
034: /**
035: * suggested default (14 dec)
036: */
037:
038: public final static short COUNT = 14;
039: private short field_1_count;
040:
041: public FnGroupCountRecord() {
042: }
043:
044: /**
045: * Constructs a FnGroupCount record and sets its fields appropriately.
046: * @param in the RecordInputstream to read the record from
047: */
048:
049: public FnGroupCountRecord(RecordInputStream in) {
050: super (in);
051: }
052:
053: protected void validateSid(short id) {
054: if (id != sid) {
055: throw new RecordFormatException("NOT A FNGROUPCOUNT RECORD");
056: }
057: }
058:
059: protected void fillFields(RecordInputStream in) {
060: field_1_count = in.readShort();
061: }
062:
063: /**
064: * set the number of built-in functions
065: *
066: * @param count - number of functions
067: */
068:
069: public void setCount(short count) {
070: field_1_count = count;
071: }
072:
073: /**
074: * get the number of built-in functions
075: *
076: * @return number of built-in functions
077: */
078:
079: public short getCount() {
080: return field_1_count;
081: }
082:
083: public String toString() {
084: StringBuffer buffer = new StringBuffer();
085:
086: buffer.append("[FNGROUPCOUNT]\n");
087: buffer.append(" .count = ").append(getCount())
088: .append("\n");
089: buffer.append("[/FNGROUPCOUNT]\n");
090: return buffer.toString();
091: }
092:
093: public int serialize(int offset, byte[] data) {
094: LittleEndian.putShort(data, 0 + offset, sid);
095: LittleEndian.putShort(data, 2 + offset, ((short) 0x02)); // 2 bytes (6 total)
096: LittleEndian.putShort(data, 4 + offset, getCount());
097: return getRecordSize();
098: }
099:
100: public int getRecordSize() {
101: return 6;
102: }
103:
104: public short getSid() {
105: return sid;
106: }
107: }
|