KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* ====================================================================
2    Copyright 2002-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 /*
19  * GreaterThanPtg.java
20  *
21  * Created on January 23, 2003, 9:47 AM
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  * Greater than operator PTG ">"
31  * @author Cameron Riley (criley at ekmail.com)
32  */

33 public class GreaterThanPtg
34     extends OperationPtg
35 {
36     public final static int SIZE = 1;
37     public final static byte sid = 0x0D;
38     private final static String JavaDoc GREATERTHAN = ">";
39
40     /**
41      * Constructor. Creates new GreaterThanPtg
42      */

43     public GreaterThanPtg()
44     {
45         //deliberately empty
46
}
47
48     /**
49      * Constructor. Create a new GreaterThanPtg.
50      * @param data the byte array to have the PTG added to
51      * @param offset the offset to the PTG to.
52      */

53     public GreaterThanPtg(byte [] data, int offset)
54     {
55         //deliberately empty
56
}
57     
58     /**
59      * Write the sid to an array
60      * @param array the array of bytes to write the sid to
61      * @param offset the offset to add the sid to
62      */

63     public void writeBytes(byte [] array, int offset)
64     {
65         array[ offset + 0 ] = sid;
66     }
67
68     /**
69      * Get the size of the sid
70      * @return int the size of the sid in terms of byte additions to an array
71      */

72     public int getSize()
73     {
74         return SIZE;
75     }
76
77     /**
78      * Get the type of PTG for Greater Than
79      * @return int the identifier for the type
80      */

81     public int getType()
82     {
83         return TYPE_BINARY;
84     }
85
86     /**
87      * Get the number of operands for the Less than operator
88      * @return int the number of operands
89      */

90     public int getNumberOfOperands()
91     {
92         return 2;
93     }
94     
95     /**
96      * Implementation of method from Ptg
97      * @param book the Sheet References
98      */

99     public String JavaDoc toFormulaString(Workbook book)
100     {
101         return this.GREATERTHAN;
102     }
103       
104     /**
105      * Implementation of method from OperationsPtg
106      * @param operands a String array of operands
107      * @return String the Formula as a String
108      */

109     public String JavaDoc toFormulaString(String JavaDoc[] operands)
110     {
111         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
112
113         buffer.append(operands[ 0 ]);
114         buffer.append(this.GREATERTHAN);
115         buffer.append(operands[ 1 ]);
116         return buffer.toString();
117     }
118     
119     /**
120      * Get the default operands class value
121      * @return byte the Ptg Class Value as a byte from the Ptg Parent object
122      */

123     public byte getDefaultOperandClass()
124     {
125         return Ptg.CLASS_VALUE;
126     }
127            
128     /**
129      * Implementation of clone method from Object
130      * @return Object a clone of this class as an Object
131      */

132     public Object JavaDoc clone()
133     {
134         return new GreaterThanPtg();
135     }
136 }
137
Popular Tags