org.apache.poi.hssf.record.formula
Class AbstractFunctionPtg

java.lang.Object
  extended by org.apache.poi.hssf.record.formula.Ptg
      extended by org.apache.poi.hssf.record.formula.OperationPtg
          extended by org.apache.poi.hssf.record.formula.AbstractFunctionPtg
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
FuncPtg, FuncVarPtg

public abstract class AbstractFunctionPtg
extends OperationPtg

This class provides the base functionality for Excel sheet functions There are two kinds of function Ptgs - tFunc and tFuncVar Therefore, this class will have ONLY two subclasses

Author:
Avik Sengupta, Andrew C. Oliver (acoliver at apache dot org)

Field Summary
protected  byte field_1_num_args
           
protected  short field_2_fnc_index
           
static java.lang.String FUNCTION_NAME_IF
          The name of the IF function (i.e.
protected  byte[] paramClass
           
protected  byte returnClass
           
 
Fields inherited from class org.apache.poi.hssf.record.formula.OperationPtg
TYPE_BINARY, TYPE_FUNCTION, TYPE_UNARY
 
Fields inherited from class org.apache.poi.hssf.record.formula.Ptg
CLASS_ARRAY, CLASS_REF, CLASS_VALUE, EMPTY_PTG_ARRAY
 
Constructor Summary
AbstractFunctionPtg()
           
 
Method Summary
 byte getDefaultOperandClass()
           
 short getFunctionIndex()
           
 java.lang.String getName()
           
 byte getParameterClass(int index)
           
abstract  int getSize()
           
 boolean isBaseToken()
           
static boolean isBuiltInFunctionName(java.lang.String name)
          Used to detect whether a function name found in a formula is one of the standard excel functions
 boolean isExternalFunction()
          external functions get some special processing
protected static short lookupIndex(java.lang.String name)
          Resolves internal function names into function indexes.
protected  java.lang.String lookupName(short index)
           
 java.lang.String toFormulaString()
          return a string representation of this token alone
 java.lang.String toFormulaString(java.lang.String[] operands)
          returns a string representation of the operations the length of the input array should equal the number returned by
 java.lang.String toString()
          Overridden toString method to ensure object hash is not printed.
abstract  void writeBytes(byte[] array, int offset)
          write this Ptg to a byte array
 
Methods inherited from class org.apache.poi.hssf.record.formula.OperationPtg
getNumberOfOperands, getType
 
Methods inherited from class org.apache.poi.hssf.record.formula.Ptg
clone, copy, createPtg, getBytes, getEncodedSize, getEncodedSizeWithoutArrayData, getPtgClass, getRVAType, readTokens, serializePtgs, setClass, toDebugString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FUNCTION_NAME_IF

public static final java.lang.String FUNCTION_NAME_IF
The name of the IF function (i.e. "IF"). Extracted as a constant for clarity.

See Also:
Constant Field Values

returnClass

protected byte returnClass

paramClass

protected byte[] paramClass

field_1_num_args

protected byte field_1_num_args

field_2_fnc_index

protected short field_2_fnc_index
Constructor Detail

AbstractFunctionPtg

public AbstractFunctionPtg()
Method Detail

isBaseToken

public final boolean isBaseToken()
Specified by:
isBaseToken in class Ptg
Returns:
false if this token is classified as 'reference', 'value', or 'array'

toString

public java.lang.String toString()
Description copied from class: Ptg
Overridden toString method to ensure object hash is not printed. This helps get rid of gratuitous diffs when comparing two dumps Subclasses may output more relevant information by overriding this method

Overrides:
toString in class Ptg

getFunctionIndex

public short getFunctionIndex()

getName

public java.lang.String getName()

isExternalFunction

public boolean isExternalFunction()
external functions get some special processing

Returns:
true if this is an external function

toFormulaString

public java.lang.String toFormulaString()
Description copied from class: Ptg
return a string representation of this token alone

Specified by:
toFormulaString in class Ptg

toFormulaString

public java.lang.String toFormulaString(java.lang.String[] operands)
Description copied from class: OperationPtg
returns a string representation of the operations the length of the input array should equal the number returned by

Specified by:
toFormulaString in class OperationPtg
See Also:
OperationPtg.getNumberOfOperands()

writeBytes

public abstract void writeBytes(byte[] array,
                                int offset)
Description copied from class: Ptg
write this Ptg to a byte array

Specified by:
writeBytes in class Ptg

getSize

public abstract int getSize()
Specified by:
getSize in class Ptg
Returns:
the encoded length of this Ptg, including the initial Ptg type identifier byte.

isBuiltInFunctionName

public static final boolean isBuiltInFunctionName(java.lang.String name)
Used to detect whether a function name found in a formula is one of the standard excel functions

The name matching is case insensitive.

Returns:
true if the name specifies a standard worksheet function, false if the name should be assumed to be an external function.

lookupName

protected java.lang.String lookupName(short index)

lookupIndex

protected static short lookupIndex(java.lang.String name)
Resolves internal function names into function indexes.

The name matching is case insensitive.

Returns:
the standard worksheet function index if found, otherwise FUNCTION_INDEX_EXTERNAL

getDefaultOperandClass

public byte getDefaultOperandClass()
Overrides:
getDefaultOperandClass in class OperationPtg

getParameterClass

public byte getParameterClass(int index)


Copyright 2008 The Apache Software Foundation or its licensors, as applicable.