⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 variableargfunction.java

📁 实现JAVA界面的代码GWT
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   VariableArgFunction.java

package jxl.biff.formula;

import common.Logger;
import java.util.Stack;
import jxl.WorkbookSettings;
import jxl.biff.IntegerHelper;

// Referenced classes of package jxl.biff.formula:
//            Operator, FormulaException, ParseItem, Area, 
//            ParsedThing, Function, Token

class VariableArgFunction extends Operator
    implements ParsedThing
{

    private static Logger logger;
    private Function function;
    private int arguments;
    private boolean readFromSheet;
    private WorkbookSettings settings;
    static Class class$jxl$biff$formula$VariableArgFunction; /* synthetic field */

    public VariableArgFunction(WorkbookSettings ws)
    {
        readFromSheet = true;
        settings = ws;
    }

    public VariableArgFunction(Function f, int a, WorkbookSettings ws)
    {
        function = f;
        arguments = a;
        readFromSheet = false;
        settings = ws;
    }

    public int read(byte data[], int pos)
        throws FormulaException
    {
        arguments = data[pos];
        int index = IntegerHelper.getInt(data[pos + 1], data[pos + 2]);
        function = Function.getFunction(index);
        if(function == Function.UNKNOWN)
            throw new FormulaException(FormulaException.UNRECOGNIZED_FUNCTION, index);
        else
            return 3;
    }

    public void getOperands(Stack s)
    {
        ParseItem items[] = new ParseItem[arguments];
        for(int i = arguments - 1; i >= 0; i--)
        {
            ParseItem pi = (ParseItem)s.pop();
            items[i] = pi;
        }

        for(int i = 0; i < arguments; i++)
            add(items[i]);

    }

    public void getString(StringBuffer buf)
    {
        buf.append(function.getName(settings));
        buf.append('(');
        if(arguments > 0)
        {
            ParseItem operands[] = getOperands();
            if(readFromSheet)
            {
                operands[0].getString(buf);
                for(int i = 1; i < arguments; i++)
                {
                    buf.append(',');
                    operands[i].getString(buf);
                }

            } else
            {
                operands[arguments - 1].getString(buf);
                for(int i = arguments - 2; i >= 0; i--)
                {
                    buf.append(',');
                    operands[i].getString(buf);
                }

            }
        }
        buf.append(')');
    }

    public void adjustRelativeCellReferences(int colAdjust, int rowAdjust)
    {
        ParseItem operands[] = getOperands();
        for(int i = 0; i < operands.length; i++)
            operands[i].adjustRelativeCellReferences(colAdjust, rowAdjust);

    }

    void columnInserted(int sheetIndex, int col, boolean currentSheet)
    {
        ParseItem operands[] = getOperands();
        for(int i = 0; i < operands.length; i++)
            operands[i].columnInserted(sheetIndex, col, currentSheet);

    }

    void columnRemoved(int sheetIndex, int col, boolean currentSheet)
    {
        ParseItem operands[] = getOperands();
        for(int i = 0; i < operands.length; i++)
            operands[i].columnRemoved(sheetIndex, col, currentSheet);

    }

    void rowInserted(int sheetIndex, int row, boolean currentSheet)
    {
        ParseItem operands[] = getOperands();
        for(int i = 0; i < operands.length; i++)
            operands[i].rowInserted(sheetIndex, row, currentSheet);

    }

    void rowRemoved(int sheetIndex, int row, boolean currentSheet)
    {
        ParseItem operands[] = getOperands();
        for(int i = 0; i < operands.length; i++)
            operands[i].rowRemoved(sheetIndex, row, currentSheet);

    }

    Function getFunction()
    {
        return function;
    }

    byte[] getBytes()
    {
        handleSpecialCases();
        ParseItem operands[] = getOperands();
        byte data[] = new byte[0];
        for(int i = 0; i < operands.length; i++)
        {
            byte opdata[] = operands[i].getBytes();
            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;
        }

        byte newdata[] = new byte[data.length + 4];
        System.arraycopy(data, 0, newdata, 0, data.length);
        newdata[data.length] = useAlternateCode() ? Token.FUNCTIONVARARG.getCode2() : Token.FUNCTIONVARARG.getCode();
        newdata[data.length + 1] = (byte)arguments;
        IntegerHelper.getTwoBytes(function.getCode(), newdata, data.length + 2);
        return newdata;
    }

    int getPrecedence()
    {
        return 3;
    }

    private void handleSpecialCases()
    {
        if(function == Function.SUMPRODUCT)
        {
            ParseItem operands[] = getOperands();
            for(int i = operands.length - 1; i >= 0; i--)
                if(operands[i] instanceof Area)
                    operands[i].setAlternateCode();

        }
    }

    static Class class$(String x0)
    {
        return Class.forName(x0);
        ClassNotFoundException x1;
        x1;
        throw new NoClassDefFoundError(x1.getMessage());
    }

    static 
    {
        logger = Logger.getLogger(class$jxl$biff$formula$VariableArgFunction != null ? class$jxl$biff$formula$VariableArgFunction : (class$jxl$biff$formula$VariableArgFunction = class$("jxl.biff.formula.VariableArgFunction")));
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -