KickJava   Java API By Example, From Geeks To Geeks.

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


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
18 package org.apache.poi.hssf.record.formula;
19
20 import java.util.List JavaDoc;
21
22 import org.apache.poi.hssf.model.Workbook;
23
24 /**
25  * While formula tokens are stored in RPN order and thus do not need parenthesis for
26  * precedence reasons, Parenthesis tokens ARE written to ensure that user entered
27  * parenthesis are displayed as-is on reading back
28  *
29  * Avik Sengupta <lists@aviksengupta.com>
30  * Andrew C. Oliver (acoliver at apache dot org)
31  * @author Jason Height (jheight at chariot dot net dot au)
32  */

33 public class ParenthesisPtg
34     extends OperationPtg
35 {
36    
37     private final static int SIZE = 1;
38     public final static byte sid = 0x15;
39    
40     public ParenthesisPtg()
41     {
42     }
43
44     public ParenthesisPtg(byte [] data, int offset)
45     {
46
47         // doesn't need anything
48
}
49     
50   
51     
52     public void writeBytes(byte [] array, int offset)
53     {
54         array[ offset + 0 ] = sid;
55     }
56
57     public int getSize()
58     {
59         return SIZE;
60     }
61
62     public int getType()
63     {
64         return TYPE_BINARY;
65     }
66
67     public int getNumberOfOperands()
68     {
69         return 1;
70     }
71
72     public String JavaDoc toFormulaString(Workbook book)
73     {
74         return "()";
75     }
76
77           
78     public String JavaDoc toFormulaString(String JavaDoc[] operands) {
79         return "("+operands[0]+")";
80     }
81     
82     public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
83         
84     public Object JavaDoc clone() {
85       return new ParenthesisPtg();
86     }
87
88 }
89
Popular Tags