KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.List JavaDoc;
20
21 import org.apache.poi.hssf.model.Workbook;
22
23 /**
24  * Unary Plus operator
25  * does not have any effect on the operand
26  * @author Avik Sengupta
27  */

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