KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hssf > record > HideObjRecord


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 ==================================================================== */

17         
18
19 package org.apache.poi.hssf.record;
20
21 import org.apache.poi.util.LittleEndian;
22
23 /**
24  * Title: Hide Object Record<P>
25  * Description: flag defines whether to hide placeholders and object<P>
26  * REFERENCE: PG 321 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
27  * @author Andrew C. Oliver (acoliver at apache dot org)
28  * @version 2.0-pre
29  */

30
31 public class HideObjRecord
32     extends Record
33 {
34     public final static short sid = 0x8d;
35     public final static short HIDE_ALL = 2;
36     public final static short SHOW_PLACEHOLDERS = 1;
37     public final static short SHOW_ALL = 0;
38     private short field_1_hide_obj;
39
40     public HideObjRecord()
41     {
42     }
43
44     /**
45      * Constructs an HideObj record and sets its fields appropriately.
46      *
47      * @param id id must be 0x8d or an exception will be throw upon validation
48      * @param size the size of the data area of the record
49      * @param data data of the record (should not contain sid/len)
50      */

51
52     public HideObjRecord(short id, short size, byte [] data)
53     {
54         super(id, size, data);
55     }
56
57     /**
58      * Constructs an HideObj record and sets its fields appropriately.
59      *
60      * @param id id must be 0x8d or an exception will be throw upon validation
61      * @param size the size of the data area of the record
62      * @param data data of the record (should not contain sid/len)
63      * @param offset of the record's data
64      */

65
66     public HideObjRecord(short id, short size, byte [] data, int offset)
67     {
68         super(id, size, data, offset);
69     }
70
71     protected void validateSid(short id)
72     {
73         if (id != sid)
74         {
75             throw new RecordFormatException("NOT A HIDEOBJ RECORD");
76         }
77     }
78
79     protected void fillFields(byte [] data, short size, int offset)
80     {
81         field_1_hide_obj = LittleEndian.getShort(data, 0 + offset);
82     }
83
84     /**
85      * set hide object options
86      *
87      * @param hide options
88      * @see #HIDE_ALL
89      * @see #SHOW_PLACEHOLDERS
90      * @see #SHOW_ALL
91      */

92
93     public void setHideObj(short hide)
94     {
95         field_1_hide_obj = hide;
96     }
97
98     /**
99      * get hide object options
100      *
101      * @return hide options
102      * @see #HIDE_ALL
103      * @see #SHOW_PLACEHOLDERS
104      * @see #SHOW_ALL
105      */

106
107     public short getHideObj()
108     {
109         return field_1_hide_obj;
110     }
111
112     public String JavaDoc toString()
113     {
114         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
115
116         buffer.append("[HIDEOBJ]\n");
117         buffer.append(" .hideobj = ")
118             .append(Integer.toHexString(getHideObj())).append("\n");
119         buffer.append("[/HIDEOBJ]\n");
120         return buffer.toString();
121     }
122
123     public int serialize(int offset, byte [] data)
124     {
125         LittleEndian.putShort(data, 0 + offset, sid);
126         LittleEndian.putShort(data, 2 + offset,
127                               (( short ) 0x02)); // 2 bytes (6 total)
128
LittleEndian.putShort(data, 4 + offset, getHideObj());
129         return getRecordSize();
130     }
131
132     public int getRecordSize()
133     {
134         return 6;
135     }
136
137     public short getSid()
138     {
139         return this.sid;
140     }
141 }
142
Popular Tags