KickJava   Java API By Example, From Geeks To Geeks.

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


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 /*
19  * LessThanPtg.java
20  *
21  * Created on January 23, 2003, 9:47 AM
22  */

23 package org.apache.poi.hssf.record.formula;
24
25 //JDK
26
import java.util.List JavaDoc;
27
28 //POI
29
import org.apache.poi.hssf.model.Workbook;
30
31 /**
32  * Less than operator PTG "<". The SID is taken from the
33  * Openoffice.orgs Documentation of the Excel File Format,
34  * Table 3.5.7
35  * @author Cameron Riley (criley at ekmail.com)
36  */

37 public class LessThanPtg
38     extends OperationPtg
39 {
40     /** the size of the Ptg */
41     public final static int SIZE = 1;
42
43     /** the sid for the less than operator as hex */
44     public final static byte sid = 0x09;
45
46     /** identifier for LESS THAN char */
47     private final static String JavaDoc LESSTHAN = "<";
48
49     /**
50      * Constructor. Creates new LessThanPtg
51      */

52     public LessThanPtg()
53     {
54         //deliberately empty
55
}
56
57     /**
58      * Constructor. Create a new LessThanPtg.
59      * @param data the byte array to have the PTG added to
60      * @param offset the offset to the PTG to.
61      */

62     public LessThanPtg(byte [] data, int offset)
63     {
64         //deliberately empty
65
}
66     
67     /**
68      * Write the sid to an array
69      * @param array the array of bytes to write the sid to
70      * @param offset the offset to add the sid to
71      */

72     public void writeBytes(byte[] array, int offset)
73     {
74         array[ offset + 0 ] = sid;
75     }
76
77     /**
78      * Get the size of the sid
79      * @return int the size of the sid in terms of byte additions to an array
80      */

81     public int getSize()
82     {
83         return SIZE;
84     }
85
86     /**
87      * Get the type of PTG for Less Than
88      * @return int the identifier for the type
89      */

90     public int getType()
91     {
92         return TYPE_BINARY;
93     }
94
95     /**
96      * Get the number of operands for the Less than operator
97      * @return int the number of operands
98      */

99     public int getNumberOfOperands()
100     {
101         return 2;
102     }
103     
104     /**
105      * Implementation of method from Ptg
106      * @param book the Sheet References
107      */

108     public String JavaDoc toFormulaString(Workbook book)
109     {
110         return this.LESSTHAN;
111     }
112        
113     /**
114      * Implementation of method from OperationsPtg
115      * @param operands a String array of operands
116      * @return String the Formula as a String
117      */

118     public String JavaDoc toFormulaString(String JavaDoc[] operands)
119     {
120         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
121         buffer.append(operands[ 0 ]);
122         buffer.append(this.LESSTHAN);
123         buffer.append(operands[ 1 ]);
124         return buffer.toString();
125     }
126     
127     /**
128      * Get the default operands class value
129      * @return byte the Ptg Class Value as a byte from the Ptg Parent object
130      */

131     public byte getDefaultOperandClass()
132     {
133         return Ptg.CLASS_VALUE;
134     }
135     
136     /**
137      * Implementation of clone method from Object
138      * @return Object a clone of this class as an Object
139      */

140     public Object JavaDoc clone()
141     {
142         return new LessThanPtg();
143     }
144
145 }
146
Popular Tags