public abstract class Ptg extends java.lang.Object implements Duplicatable, GenericRecord
Ptg
represents a syntactic token in a formula. 'PTG' is an acronym for
'parse thing'. Originally, the name referred to the single
byte identifier at the start of the token, but in POI, Ptg
encapsulates
the whole formula token (initial byte + value data).
Ptg
s are logically arranged in a tree representing the structure of the
parsed formula. However, in BIFF files Ptg
s are written/read in
Reverse-Polish Notation order. The RPN ordering also simplifies formula
evaluation logic, so POI mostly accesses Ptg
s in the same way.
Modifier and Type | Field and Description |
---|---|
static byte |
CLASS_ARRAY |
static byte |
CLASS_REF |
static byte |
CLASS_VALUE |
static Ptg[] |
EMPTY_PTG_ARRAY |
Modifier | Constructor and Description |
---|---|
protected |
Ptg() |
protected |
Ptg(Ptg other) |
Modifier and Type | Method and Description |
---|---|
abstract Ptg |
copy() |
static Ptg |
createPtg(LittleEndianInput in) |
static boolean |
doesFormulaReferToDeletedCell(Ptg[] ptgs) |
abstract byte |
getDefaultOperandClass() |
static int |
getEncodedSize(Ptg[] ptgs)
This method will return the same result as
getEncodedSizeWithoutArrayData(Ptg[])
if there are no array tokens present. |
static int |
getEncodedSizeWithoutArrayData(Ptg[] ptgs)
Used to calculate value that should be encoded at the start of the encoded Ptg token array;
|
byte |
getPtgClass() |
char |
getRVAType()
Debug / diagnostic method to get this token's 'operand class' type.
|
abstract byte |
getSid() |
abstract int |
getSize() |
abstract boolean |
isBaseToken() |
static Ptg[] |
readTokens(int size,
LittleEndianInput in)
Reads
size bytes of the input stream, to create an array of Ptg s. |
static int |
serializePtgs(Ptg[] ptgs,
byte[] array,
int offset)
Writes the ptgs to the data buffer, starting at the specified offset.
|
void |
setClass(byte thePtgClass) |
abstract java.lang.String |
toFormulaString()
return a string representation of this token alone
|
java.lang.String |
toString() |
abstract void |
write(LittleEndianOutput out) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getGenericChildren, getGenericProperties, getGenericRecordType
public static final Ptg[] EMPTY_PTG_ARRAY
public static final byte CLASS_REF
public static final byte CLASS_VALUE
public static final byte CLASS_ARRAY
protected Ptg()
protected Ptg(Ptg other)
public static Ptg[] readTokens(int size, LittleEndianInput in)
size
bytes of the input stream, to create an array of Ptg
s.
Extra data (beyond size
) may be read if and ArrayPtg
s are present.public static Ptg createPtg(LittleEndianInput in)
public static int getEncodedSize(Ptg[] ptgs)
getEncodedSizeWithoutArrayData(Ptg[])
if there are no array tokens present.Ptg
spublic static int getEncodedSizeWithoutArrayData(Ptg[] ptgs)
public static int serializePtgs(Ptg[] ptgs, byte[] array, int offset)
public abstract int getSize()
public abstract void write(LittleEndianOutput out)
public abstract java.lang.String toFormulaString()
public final java.lang.String toString()
toString
in class java.lang.Object
public final void setClass(byte thePtgClass)
public final byte getPtgClass()
public final char getRVAType()
public abstract byte getDefaultOperandClass()
public abstract boolean isBaseToken()
false
if this token is classified as 'reference', 'value', or 'array'public static boolean doesFormulaReferToDeletedCell(Ptg[] ptgs)
public abstract Ptg copy()
copy
in interface Duplicatable
public abstract byte getSid()
-1
if the record has no sidCopyright 2022 The Apache Software Foundation or its licensors, as applicable.