KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hssf > record > formula > NameXPtg


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

16
17 package org.apache.poi.hssf.record.formula;
18
19 import org.apache.poi.util.LittleEndian;
20 import org.apache.poi.hssf.model.Workbook;
21
22 /**
23  *
24  * @author aviks
25  */

26
27 public class NameXPtg extends Ptg
28 {
29     public final static short sid = 0x39;
30     private final static int SIZE = 7;
31     private short field_1_ixals; // index to externsheet record
32
private short field_2_ilbl; //index to name or externname table(1 based)
33
private short field_3_reserved; // reserved must be 0
34

35
36     private NameXPtg() {
37       //Required for clone methods
38
}
39
40     /** Creates new NamePtg */
41
42     public NameXPtg(String JavaDoc name)
43     {
44         //TODO
45
}
46
47     /** Creates new NamePtg */
48
49     public NameXPtg(byte[] data, int offset)
50     {
51         offset++;
52         field_1_ixals = LittleEndian.getShort(data, offset);
53         field_2_ilbl = LittleEndian.getShort(data, offset + 2);
54         field_3_reserved = LittleEndian.getShort(data, offset +4);
55         
56         //field_2_reserved = LittleEndian.getByteArray(data, offset + 12,12);
57
}
58
59     public void writeBytes(byte [] array, int offset)
60     {
61         array[ offset + 0 ] = (byte)(sid + ptgClass);
62         LittleEndian.putShort(array, offset + 1, field_1_ixals);
63         LittleEndian.putShort(array,offset+3, field_2_ilbl);
64         LittleEndian.putShort(array, offset + 5, field_3_reserved);
65     }
66
67     public int getSize()
68     {
69         return SIZE;
70     }
71
72     public String JavaDoc toFormulaString(Workbook book)
73     {
74         return "NO IDEA - NAME";
75     }
76     
77     public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
78
79     public Object JavaDoc clone() {
80       NameXPtg ptg = new NameXPtg();
81       ptg.field_1_ixals = field_1_ixals;
82       ptg.field_3_reserved = field_3_reserved;
83       ptg.field_2_ilbl = field_2_ilbl;
84       ptg.setClass(ptgClass);
85       return ptg;
86     }
87 }
88
Popular Tags