A special attribute control token - typically either a SUM function
or an IF function
| Method from jxl.biff.formula.Attribute Detail: |
public void adjustRelativeCellReferences(int colAdjust,
int rowAdjust) {
ParseItem[] operands = null;
if (isIf())
{
operands = ifConditions.getOperands();
}
else
{
operands = getOperands();
}
for (int i = 0; i < operands.length; i++)
{
operands[i].adjustRelativeCellReferences(colAdjust, rowAdjust);
}
}
Default behaviour is to do nothing |
void columnInserted(int sheetIndex,
int col,
boolean currentSheet) {
ParseItem[] operands = null;
if (isIf())
{
operands = ifConditions.getOperands();
}
else
{
operands = getOperands();
}
for (int i = 0; i < operands.length; i++)
{
operands[i].columnInserted(sheetIndex, col, currentSheet);
}
}
Called when a column is inserted on the specified sheet. Tells
the formula parser to update all of its cell references beyond this
column |
void columnRemoved(int sheetIndex,
int col,
boolean currentSheet) {
ParseItem[] operands = null;
if (isIf())
{
operands = ifConditions.getOperands();
}
else
{
operands = getOperands();
}
for (int i = 0; i < operands.length; i++)
{
operands[i].columnRemoved(sheetIndex, col, currentSheet);
}
}
Called when a column is inserted on the specified sheet. Tells
the formula parser to update all of its cell references beyond this
column |
byte[] getBytes() {
byte[] data = new byte[0];
if (isSum())
{
// Get the data for the operands
ParseItem[] operands = getOperands();
// Get the operands in reverse order to get the RPN
for (int i = operands.length - 1; i >= 0; i--)
{
byte[] opdata = operands[i].getBytes();
// Grow the array
byte[] newdata = new byte[data.length + opdata.length];
System.arraycopy(data, 0, newdata, 0, data.length);
System.arraycopy(opdata, 0, newdata, data.length, opdata.length);
data = newdata;
}
// Add on the operator byte
byte[] newdata = new byte[data.length + 4];
System.arraycopy(data, 0, newdata, 0, data.length);
newdata[data.length] = Token.ATTRIBUTE.getCode();
newdata[data.length + 1] = SUM_MASK;
data = newdata;
}
else if (isIf())
{
return getIf();
}
return data;
}
Gets the token representation of this item in RPN. The Attribute
token is a special case, which overrides anything useful we could do
in the base class |
public void getOperands(Stack s) {
if ((options & SUM_MASK) != 0)
{
ParseItem o1 = (ParseItem) s.pop();
add(o1);
}
else if ((options & IF_MASK) != 0)
{
ParseItem o1 = (ParseItem) s.pop();
add(o1);
}
}
Gets the operands for this operator from the stack |
int getPrecedence() {
return 3;
}
Gets the precedence for this operator. Operator precedents run from
1 to 5, one being the highest, 5 being the lowest |
public void getString(StringBuffer buf) {
if ((options & SUM_MASK) != 0)
{
ParseItem[] operands = getOperands();
buf.append(Function.SUM.getName(settings));
buf.append('(");
operands[0].getString(buf);
buf.append(')");
}
else if ((options & IF_MASK) != 0)
{
buf.append(Function.IF.getName(settings));
buf.append('(");
ParseItem[] operands = ifConditions.getOperands();
// Operands are in the correct order for IFs
for (int i = 0; i < operands.length - 1; i++)
{
operands[i].getString(buf);
buf.append(',");
}
operands[operands.length - 1].getString(buf);
buf.append(')");
}
}
Gets the string version of the attribute |
void handleImportedCellReferences() {
ParseItem[] operands = null;
if (isIf())
{
operands = ifConditions.getOperands();
}
else
{
operands = getOperands();
}
for (int i = 0; i < operands.length; i++)
{
operands[i].handleImportedCellReferences();
}
}
If this formula was on an imported sheet, check that
cell references to another sheet are warned appropriately
Does nothing, as operators don't have cell references |
public boolean isChoose() {
return (options & CHOOSE_MASK) != 0;
}
Queries whether this attribute is a CHOOSE |
public boolean isFunction() {
return (options & (SUM_MASK | IF_MASK)) != 0;
}
Queries whether this attribute is a function |
public boolean isGoto() {
return (options & GOTO_MASK) != 0;
}
Queries whether this attribute is a goto |
public boolean isIf() {
return (options & IF_MASK) != 0;
}
Queries whether this attribute is an IF |
public boolean isSum() {
return (options & SUM_MASK) != 0;
}
Queries whether this attribute is a sum |
public int read(byte[] data,
int pos) {
options = data[pos];
word = IntegerHelper.getInt(data[pos + 1], data[pos + 2]);
if (!isChoose())
{
return 3;
}
// word contains the number of jumps by index.
// and there is an additional final jump to the choose function itself.
return 3 + (word + 1) * 2;
}
Reads the ptg data from the array starting at the specified position |
void rowInserted(int sheetIndex,
int row,
boolean currentSheet) {
ParseItem[] operands = null;
if (isIf())
{
operands = ifConditions.getOperands();
}
else
{
operands = getOperands();
}
for (int i = 0; i < operands.length; i++)
{
operands[i].rowInserted(sheetIndex, row, currentSheet);
}
}
Called when a column is inserted on the specified sheet. Tells
the formula parser to update all of its cell references beyond this
column |
void rowRemoved(int sheetIndex,
int row,
boolean currentSheet) {
ParseItem[] operands = null;
if (isIf())
{
operands = ifConditions.getOperands();
}
else
{
operands = getOperands();
}
for (int i = 0; i < operands.length; i++)
{
operands[i].rowRemoved(sheetIndex, row, currentSheet);
}
}
Called when a column is inserted on the specified sheet. Tells
the formula parser to update all of its cell references beyond this
column |
void setIfConditions(VariableArgFunction vaf) {
ifConditions = vaf;
// Sometimes there is not Attribute token, so we need to create
// an attribute out of thin air. In that case, make sure the if mask
options |= IF_MASK;
}
Sets the if conditions for this attribute, if it represents an IF function |