KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > biff > formula > MemFunc


1 /*********************************************************************
2  *
3  * Copyright (C) 2002 Andrew Khan
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  ***************************************************************************/

19
20 package jxl.biff.formula;
21
22 import java.util.Stack JavaDoc;
23
24 import common.Assert;
25 import jxl.WorkbookSettings;
26 import jxl.Sheet;
27 import jxl.biff.IntegerHelper;
28
29 /**
30  * Indicates that the function doesn't evaluate to a constant reference
31  */

32 class MemFunc extends Operand implements ParsedThing
33 {
34   /**
35    * The number of bytes in the subexpression
36    */

37   private int length;
38
39   /**
40    * The sub expression
41    */

42   private ParseItem[] subExpression;
43
44   /**
45    * Constructor
46    */

47   public MemFunc()
48   {
49   }
50
51   /**
52    * Reads the ptg data from the array starting at the specified position
53    *
54    * @param data the RPN array
55    * @param pos the current position in the array, excluding the ptg identifier
56    * @return the number of bytes read
57    */

58   public int read(byte[] data, int pos)
59   {
60     length = IntegerHelper.getInt(data[pos], data[pos+1]);
61     return 2;
62   }
63
64   /**
65    * Gets the operands for this operator from the stack
66    */

67   public void getOperands(Stack JavaDoc s)
68   {
69   }
70
71   public void getString(StringBuffer JavaDoc buf)
72   {
73     if (subExpression.length == 1)
74     {
75       subExpression[0].getString(buf);
76     }
77     else if (subExpression.length == 2)
78     {
79       subExpression[1].getString(buf);
80       buf.append(':');
81       subExpression[0].getString(buf);
82     }
83   }
84
85   /**
86    * Gets the token representation of this item in RPN. The Attribute
87    * token is a special case, which overrides anything useful we could do
88    * in the base class
89    *
90    * @return the bytes applicable to this formula
91    */

92   byte[] getBytes()
93   {
94     return null;
95   }
96
97
98   /**
99    * Gets the precedence for this operator. Operator precedents run from
100    * 1 to 5, one being the highest, 5 being the lowest
101    *
102    * @return the operator precedence
103    */

104   int getPrecedence()
105   {
106     return 5;
107   }
108
109   /**
110    * Accessor for the length
111    *
112    * @return the length of the subexpression
113    */

114   public int getLength()
115   {
116     return length;
117   }
118
119   public void setSubExpression(ParseItem[] pi)
120   {
121     subExpression = pi;
122   }
123 }
124
125
126
127
128
Popular Tags