KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.apache.poi.hssf.record.formula;
17
18 import java.util.List JavaDoc;
19 import org.apache.poi.hssf.model.Workbook;
20
21 /**
22  * Implements the standard mathmatical multiplication - *
23  * @author Andrew C. Oliver (acoliver at apache dot org)
24  * @author Jason Height (jheight at chariot dot net dot au)
25  */

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