KickJava   Java API By Example, From Geeks To Geeks.

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


1
2 /* ====================================================================
3    Copyright 2003-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  * AddPtg.java
20  *
21  * Created on October 29, 2001, 7:48 PM
22  */

23 package org.apache.poi.hssf.record.formula;
24
25 import java.util.List JavaDoc;
26
27 import org.apache.poi.hssf.model.Workbook;
28
29 /**
30  * Addition operator PTG the "+" binomial operator. If you need more
31  * explanation than that then well...We really can't help you here.
32  * @author Andrew C. Oliver (acoliver@apache.org)
33  * @author Jason Height (jheight at chariot dot net dot au)
34  */

35
36 public class AddPtg
37     extends OperationPtg
38 {
39     public final static int SIZE = 1;
40     public final static byte sid = 0x03;
41     
42     private final static String JavaDoc ADD = "+";
43
44     /** Creates new AddPtg */
45
46     public AddPtg()
47     {
48     }
49
50     public AddPtg(byte [] data, int offset)
51     {
52
53         // doesn't need anything
54
}
55     
56    
57     public void writeBytes(byte [] array, int offset)
58     {
59         array[ offset + 0 ] = sid;
60     }
61
62     public int getSize()
63     {
64         return SIZE;
65     }
66
67     public int getType()
68     {
69         return TYPE_BINARY;
70     }
71
72     public int getNumberOfOperands()
73     {
74         return 2;
75     }
76     
77     /** Implementation of method from Ptg */
78     public String JavaDoc toFormulaString(Workbook book)
79     {
80         return "+";
81     }
82        
83    /** implementation of method from OperationsPtg*/
84     public String JavaDoc toFormulaString(String JavaDoc[] operands) {
85         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
86
87         buffer.append(operands[ 0 ]);
88         buffer.append(ADD);
89         buffer.append(operands[ 1 ]);
90         return buffer.toString();
91     }
92     
93     public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;}
94            
95     public Object JavaDoc clone() {
96       return new AddPtg();
97     }
98
99 }
100
Popular Tags