KickJava   Java API By Example, From Geeks To Geeks.

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


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
20 package org.apache.poi.hssf.record;
21
22
23
24 import org.apache.poi.util.*;
25
26 /**
27  * Links text to an object on the chart or identifies it as the title.
28  * NOTE: This source is automatically generated please do not modify this file. Either subclass or
29  * remove the record in src/records/definitions.
30
31  * @author Andrew C. Oliver (acoliver at apache.org)
32  */

33 public class ObjectLinkRecord
34     extends Record
35 {
36     public final static short sid = 0x1027;
37     private short field_1_anchorId;
38     public final static short ANCHOR_ID_CHART_TITLE = 1;
39     public final static short ANCHOR_ID_Y_AXIS = 2;
40     public final static short ANCHOR_ID_X_AXIS = 3;
41     public final static short ANCHOR_ID_SERIES_OR_POINT = 4;
42     public final static short ANCHOR_ID_Z_AXIS = 7;
43     private short field_2_link1;
44     private short field_3_link2;
45
46
47     public ObjectLinkRecord()
48     {
49
50     }
51
52     /**
53      * Constructs a ObjectLink record and sets its fields appropriately.
54      *
55      * @param id id must be 0x1027 or an exception
56      * will be throw upon validation
57      * @param size size the size of the data area of the record
58      * @param data data of the record (should not contain sid/len)
59      */

60
61     public ObjectLinkRecord(short id, short size, byte [] data)
62     {
63         super(id, size, data);
64     
65     }
66
67     /**
68      * Constructs a ObjectLink record and sets its fields appropriately.
69      *
70      * @param id id must be 0x1027 or an exception
71      * will be throw upon validation
72      * @param size size the size of the data area of the record
73      * @param data data of the record (should not contain sid/len)
74      * @param offset of the record's data
75      */

76
77     public ObjectLinkRecord(short id, short size, byte [] data, int offset)
78     {
79         super(id, size, data, offset);
80     
81     }
82
83     /**
84      * Checks the sid matches the expected side for this record
85      *
86      * @param id the expected sid.
87      */

88     protected void validateSid(short id)
89     {
90         if (id != sid)
91         {
92             throw new RecordFormatException("Not a ObjectLink record");
93         }
94     }
95
96     protected void fillFields(byte [] data, short size, int offset)
97     {
98
99         int pos = 0;
100         field_1_anchorId = LittleEndian.getShort(data, pos + 0x0 + offset);
101         field_2_link1 = LittleEndian.getShort(data, pos + 0x2 + offset);
102         field_3_link2 = LittleEndian.getShort(data, pos + 0x4 + offset);
103
104     }
105
106     public String JavaDoc toString()
107     {
108         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
109
110         buffer.append("[OBJECTLINK]\n");
111         buffer.append(" .anchorId = ")
112             .append("0x").append(HexDump.toHex( getAnchorId ()))
113             .append(" (").append( getAnchorId() ).append(" )");
114         buffer.append(System.getProperty("line.separator"));
115         buffer.append(" .link1 = ")
116             .append("0x").append(HexDump.toHex( getLink1 ()))
117             .append(" (").append( getLink1() ).append(" )");
118         buffer.append(System.getProperty("line.separator"));
119         buffer.append(" .link2 = ")
120             .append("0x").append(HexDump.toHex( getLink2 ()))
121             .append(" (").append( getLink2() ).append(" )");
122         buffer.append(System.getProperty("line.separator"));
123
124         buffer.append("[/OBJECTLINK]\n");
125         return buffer.toString();
126     }
127
128     public int serialize(int offset, byte[] data)
129     {
130         int pos = 0;
131
132         LittleEndian.putShort(data, 0 + offset, sid);
133         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
134
135         LittleEndian.putShort(data, 4 + offset + pos, field_1_anchorId);
136         LittleEndian.putShort(data, 6 + offset + pos, field_2_link1);
137         LittleEndian.putShort(data, 8 + offset + pos, field_3_link2);
138
139         return getRecordSize();
140     }
141
142     /**
143      * Size of record (exluding 4 byte header)
144      */

145     public int getRecordSize()
146     {
147         return 4 + 2 + 2 + 2;
148     }
149
150     public short getSid()
151     {
152         return this.sid;
153     }
154
155     public Object JavaDoc clone() {
156         ObjectLinkRecord rec = new ObjectLinkRecord();
157     
158         rec.field_1_anchorId = field_1_anchorId;
159         rec.field_2_link1 = field_2_link1;
160         rec.field_3_link2 = field_3_link2;
161         return rec;
162     }
163
164
165
166
167     /**
168      * Get the anchor id field for the ObjectLink record.
169      *
170      * @return One of
171      * ANCHOR_ID_CHART_TITLE
172      * ANCHOR_ID_Y_AXIS
173      * ANCHOR_ID_X_AXIS
174      * ANCHOR_ID_SERIES_OR_POINT
175      * ANCHOR_ID_Z_AXIS
176      */

177     public short getAnchorId()
178     {
179         return field_1_anchorId;
180     }
181
182     /**
183      * Set the anchor id field for the ObjectLink record.
184      *
185      * @param field_1_anchorId
186      * One of
187      * ANCHOR_ID_CHART_TITLE
188      * ANCHOR_ID_Y_AXIS
189      * ANCHOR_ID_X_AXIS
190      * ANCHOR_ID_SERIES_OR_POINT
191      * ANCHOR_ID_Z_AXIS
192      */

193     public void setAnchorId(short field_1_anchorId)
194     {
195         this.field_1_anchorId = field_1_anchorId;
196     }
197
198     /**
199      * Get the link 1 field for the ObjectLink record.
200      */

201     public short getLink1()
202     {
203         return field_2_link1;
204     }
205
206     /**
207      * Set the link 1 field for the ObjectLink record.
208      */

209     public void setLink1(short field_2_link1)
210     {
211         this.field_2_link1 = field_2_link1;
212     }
213
214     /**
215      * Get the link 2 field for the ObjectLink record.
216      */

217     public short getLink2()
218     {
219         return field_3_link2;
220     }
221
222     /**
223      * Set the link 2 field for the ObjectLink record.
224      */

225     public void setLink2(short field_3_link2)
226     {
227         this.field_3_link2 = field_3_link2;
228     }
229
230
231 } // END OF CLASS
232

233
234
235
236
Popular Tags