mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
#64036 - Replace reflection calls in factories for Java 9+
removed some unnecessary reflection calls OperationEvaluatorFactory git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1880903 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
99d53d932f
commit
d6a97ce38d
@ -17,12 +17,24 @@
|
||||
|
||||
package org.apache.poi.ss.formula;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.ss.formula.eval.ConcatEval;
|
||||
import org.apache.poi.ss.formula.eval.FunctionEval;
|
||||
import org.apache.poi.ss.formula.eval.IntersectionEval;
|
||||
import org.apache.poi.ss.formula.eval.PercentEval;
|
||||
import org.apache.poi.ss.formula.eval.RangeEval;
|
||||
import org.apache.poi.ss.formula.eval.RelationalOperationEval;
|
||||
import org.apache.poi.ss.formula.eval.TwoOperandNumericOperation;
|
||||
import org.apache.poi.ss.formula.eval.UnaryMinusEval;
|
||||
import org.apache.poi.ss.formula.eval.UnaryPlusEval;
|
||||
import org.apache.poi.ss.formula.eval.ValueEval;
|
||||
import org.apache.poi.ss.formula.function.FunctionMetadataRegistry;
|
||||
import org.apache.poi.ss.formula.functions.ArrayFunction;
|
||||
import org.apache.poi.ss.formula.functions.FreeRefFunction;
|
||||
import org.apache.poi.ss.formula.functions.Function;
|
||||
import org.apache.poi.ss.formula.functions.Indirect;
|
||||
import org.apache.poi.ss.formula.ptg.AbstractFunctionPtg;
|
||||
import org.apache.poi.ss.formula.ptg.AddPtg;
|
||||
import org.apache.poi.ss.formula.ptg.ConcatPtg;
|
||||
@ -42,20 +54,6 @@ import org.apache.poi.ss.formula.ptg.RangePtg;
|
||||
import org.apache.poi.ss.formula.ptg.SubtractPtg;
|
||||
import org.apache.poi.ss.formula.ptg.UnaryMinusPtg;
|
||||
import org.apache.poi.ss.formula.ptg.UnaryPlusPtg;
|
||||
import org.apache.poi.ss.formula.eval.ConcatEval;
|
||||
import org.apache.poi.ss.formula.eval.FunctionEval;
|
||||
import org.apache.poi.ss.formula.eval.IntersectionEval;
|
||||
import org.apache.poi.ss.formula.eval.PercentEval;
|
||||
import org.apache.poi.ss.formula.eval.RangeEval;
|
||||
import org.apache.poi.ss.formula.eval.RelationalOperationEval;
|
||||
import org.apache.poi.ss.formula.eval.TwoOperandNumericOperation;
|
||||
import org.apache.poi.ss.formula.eval.UnaryMinusEval;
|
||||
import org.apache.poi.ss.formula.eval.UnaryPlusEval;
|
||||
import org.apache.poi.ss.formula.eval.ValueEval;
|
||||
import org.apache.poi.ss.formula.function.FunctionMetadataRegistry;
|
||||
import org.apache.poi.ss.formula.functions.ArrayFunction;
|
||||
import org.apache.poi.ss.formula.functions.Function;
|
||||
import org.apache.poi.ss.formula.functions.Indirect;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
|
||||
/**
|
||||
@ -66,47 +64,36 @@ import org.apache.poi.ss.util.CellRangeAddress;
|
||||
*/
|
||||
final class OperationEvaluatorFactory {
|
||||
|
||||
private static final Map<OperationPtg, Function> _instancesByPtgClass = initialiseInstancesMap();
|
||||
private static final Map<Byte, Function> _instancesByPtgClass = initialiseInstancesMap();
|
||||
|
||||
private OperationEvaluatorFactory() {
|
||||
// no instances of this class
|
||||
}
|
||||
|
||||
private static Map<OperationPtg, Function> initialiseInstancesMap() {
|
||||
Map<OperationPtg, Function> m = new HashMap<>(32);
|
||||
private static Map<Byte, Function> initialiseInstancesMap() {
|
||||
Map<Byte, Function> m = new HashMap<>(32);
|
||||
|
||||
put(m, EqualPtg.instance, RelationalOperationEval.EqualEval);
|
||||
put(m, GreaterEqualPtg.instance, RelationalOperationEval.GreaterEqualEval);
|
||||
put(m, GreaterThanPtg.instance, RelationalOperationEval.GreaterThanEval);
|
||||
put(m, LessEqualPtg.instance, RelationalOperationEval.LessEqualEval);
|
||||
put(m, LessThanPtg.instance, RelationalOperationEval.LessThanEval);
|
||||
put(m, NotEqualPtg.instance, RelationalOperationEval.NotEqualEval);
|
||||
m.put(AddPtg.instance.getSid(), TwoOperandNumericOperation.AddEval); // 0x03
|
||||
m.put(SubtractPtg.instance.getSid(), TwoOperandNumericOperation.SubtractEval); // 0x04
|
||||
m.put(MultiplyPtg.instance.getSid(), TwoOperandNumericOperation.MultiplyEval); // 0x05
|
||||
m.put(DividePtg.instance.getSid(), TwoOperandNumericOperation.DivideEval); // 0x06
|
||||
m.put(PowerPtg.instance.getSid(), TwoOperandNumericOperation.PowerEval); // 0x07
|
||||
m.put(ConcatPtg.instance.getSid(), ConcatEval.instance); // 0x08
|
||||
m.put(LessThanPtg.instance.getSid(), RelationalOperationEval.LessThanEval); // 0x09
|
||||
m.put(LessEqualPtg.instance.getSid(), RelationalOperationEval.LessEqualEval); // 0x0a
|
||||
m.put(EqualPtg.instance.getSid(), RelationalOperationEval.EqualEval); // 0x0b
|
||||
m.put(GreaterEqualPtg.instance.getSid(), RelationalOperationEval.GreaterEqualEval); // 0x0c
|
||||
m.put(GreaterThanPtg.instance.getSid(), RelationalOperationEval.GreaterThanEval); // 0x0D
|
||||
m.put(NotEqualPtg.instance.getSid(), RelationalOperationEval.NotEqualEval); // 0x0e
|
||||
m.put(IntersectionPtg.instance.getSid(), IntersectionEval.instance); // 0x0f
|
||||
m.put(RangePtg.instance.getSid(), RangeEval.instance); // 0x11
|
||||
m.put(UnaryPlusPtg.instance.getSid(), UnaryPlusEval.instance); // 0x12
|
||||
m.put(UnaryMinusPtg.instance.getSid(), UnaryMinusEval.instance); // 0x13
|
||||
m.put(PercentPtg.instance.getSid(), PercentEval.instance); // 0x14
|
||||
|
||||
put(m, ConcatPtg.instance, ConcatEval.instance);
|
||||
put(m, AddPtg.instance, TwoOperandNumericOperation.AddEval);
|
||||
put(m, DividePtg.instance, TwoOperandNumericOperation.DivideEval);
|
||||
put(m, MultiplyPtg.instance, TwoOperandNumericOperation.MultiplyEval);
|
||||
put(m, PercentPtg.instance, PercentEval.instance);
|
||||
put(m, PowerPtg.instance, TwoOperandNumericOperation.PowerEval);
|
||||
put(m, SubtractPtg.instance, TwoOperandNumericOperation.SubtractEval);
|
||||
put(m, UnaryMinusPtg.instance, UnaryMinusEval.instance);
|
||||
put(m, UnaryPlusPtg.instance, UnaryPlusEval.instance);
|
||||
put(m, RangePtg.instance, RangeEval.instance);
|
||||
put(m, IntersectionPtg.instance, IntersectionEval.instance);
|
||||
return m;
|
||||
}
|
||||
|
||||
private static void put(Map<OperationPtg, Function> m, OperationPtg ptgKey,
|
||||
Function instance) {
|
||||
// make sure ptg has single private constructor because map lookups assume singleton keys
|
||||
Constructor<?>[] cc = ptgKey.getClass().getDeclaredConstructors();
|
||||
if (cc.length > 1 || !Modifier.isPrivate(cc[0].getModifiers())) {
|
||||
throw new RuntimeException("Failed to verify instance ("
|
||||
+ ptgKey.getClass().getName() + ") is a singleton.");
|
||||
}
|
||||
m.put(ptgKey, instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the OperationEval concrete impl instance corresponding
|
||||
* to the supplied operationPtg
|
||||
@ -116,7 +103,7 @@ final class OperationEvaluatorFactory {
|
||||
if(ptg == null) {
|
||||
throw new IllegalArgumentException("ptg must not be null");
|
||||
}
|
||||
Function result = _instancesByPtgClass.get(ptg);
|
||||
Function result = _instancesByPtgClass.get(ptg.getSid());
|
||||
FreeRefFunction udfFunc = null;
|
||||
if (result == null) {
|
||||
if (ptg instanceof AbstractFunctionPtg) {
|
||||
@ -149,7 +136,7 @@ final class OperationEvaluatorFactory {
|
||||
return func.evaluateArray(args, ec.getRowIndex(), ec.getColumnIndex());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result.evaluate(args, ec.getRowIndex(), ec.getColumnIndex());
|
||||
} else if (udfFunc != null){
|
||||
return udfFunc.evaluate(args, ec);
|
||||
|
||||
@ -31,8 +31,9 @@ public final class AddPtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getNumberOfOperands() {
|
||||
@ -41,12 +42,7 @@ public final class AddPtg extends ValueOperatorPtg {
|
||||
|
||||
/** implementation of method from OperationsPtg*/
|
||||
public String toFormulaString(String[] operands) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append(operands[ 0 ]);
|
||||
buffer.append(ADD);
|
||||
buffer.append(operands[ 1 ]);
|
||||
return buffer.toString();
|
||||
return operands[0] + ADD + operands[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -43,8 +43,6 @@ public abstract class Area2DPtgBase extends AreaPtgBase {
|
||||
readCoordinates(in);
|
||||
}
|
||||
|
||||
protected abstract byte getSid();
|
||||
|
||||
public final void write(LittleEndianOutput out) {
|
||||
out.writeByte(getSid() + getPtgClass());
|
||||
writeCoordinates(out);
|
||||
|
||||
@ -77,6 +77,11 @@ public final class Area3DPtg extends AreaPtgBase implements WorkbookDependentFor
|
||||
writeCoordinates(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
|
||||
@ -99,6 +99,11 @@ public final class Area3DPxg extends AreaPtgBase implements Pxg3D {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -58,6 +58,11 @@ public final class AreaErrPtg extends OperandPtg {
|
||||
return Ptg.CLASS_REF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
@ -34,7 +34,8 @@ public final class AreaNPtg extends Area2DPtgBase {
|
||||
super(in);
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ public final class AreaPtg extends Area2DPtgBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte getSid() {
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
|
||||
@ -95,4 +95,9 @@ final class ArrayInitialPtg extends Ptg {
|
||||
"reserved2", () -> _reserved2
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,6 +164,11 @@ public final class ArrayPtg extends Ptg {
|
||||
+ ConstantValueParser.getEncodedSize(_arrayValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public String toFormulaString() {
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append("{");
|
||||
|
||||
@ -186,6 +186,11 @@ public final class AttrPtg extends ControlPtg {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
if (_jumpTable != null) {
|
||||
return SIZE + (_jumpTable.length + 1) * LittleEndianConsts.SHORT_SIZE;
|
||||
|
||||
@ -56,6 +56,11 @@ public final class BoolPtg extends ScalarConstantPtg {
|
||||
out.writeByte(_value ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@ -28,8 +28,9 @@ public final class ConcatPtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getNumberOfOperands() {
|
||||
@ -37,12 +38,7 @@ public final class ConcatPtg extends ValueOperatorPtg {
|
||||
}
|
||||
|
||||
public String toFormulaString(String[] operands) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append(operands[ 0 ]);
|
||||
buffer.append(CONCAT);
|
||||
buffer.append(operands[ 1 ]);
|
||||
return buffer.toString();
|
||||
return operands[0] + CONCAT + operands[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -78,9 +78,15 @@ public final class Deleted3DPxg extends OperandPtg implements Pxg {
|
||||
return Ptg.CLASS_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void write(LittleEndianOutput out) {
|
||||
throw new IllegalStateException("XSSF-only Ptg, should not be serialised");
|
||||
}
|
||||
|
||||
@ -59,6 +59,12 @@ public final class DeletedArea3DPtg extends OperandPtg implements WorkbookDepend
|
||||
public byte getDefaultOperandClass() {
|
||||
return Ptg.CLASS_REF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return 11;
|
||||
}
|
||||
|
||||
@ -59,6 +59,12 @@ public final class DeletedRef3DPtg extends OperandPtg implements WorkbookDepende
|
||||
public byte getDefaultOperandClass() {
|
||||
return Ptg.CLASS_REF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return 7;
|
||||
}
|
||||
|
||||
@ -29,8 +29,9 @@ public final class DividePtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getNumberOfOperands() {
|
||||
@ -38,12 +39,7 @@ public final class DividePtg extends ValueOperatorPtg {
|
||||
}
|
||||
|
||||
public String toFormulaString(String[] operands) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append(operands[ 0 ]);
|
||||
buffer.append("/");
|
||||
buffer.append(operands[ 1 ]);
|
||||
return buffer.toString();
|
||||
return operands[0] + "/" + operands[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -30,8 +30,9 @@ public final class EqualPtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getNumberOfOperands() {
|
||||
@ -39,13 +40,7 @@ public final class EqualPtg extends ValueOperatorPtg {
|
||||
}
|
||||
|
||||
public String toFormulaString(String[] operands) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
|
||||
buffer.append(operands[ 0 ]);
|
||||
buffer.append("=");
|
||||
buffer.append(operands[ 1 ]);
|
||||
return buffer.toString();
|
||||
return operands[0] + "=" + operands[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -69,6 +69,11 @@ public final class ErrPtg extends ScalarConstantPtg {
|
||||
return FormulaError.forInt(field_1_error_code).getString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@ -48,6 +48,11 @@ public final class ExpPtg extends ControlPtg {
|
||||
out.writeShort(field_2_first_col);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
|
||||
@ -49,6 +49,11 @@ public final class FuncPtg extends AbstractFunctionPtg {
|
||||
out.writeShort(getFunctionIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@ -88,6 +88,11 @@ public final class FuncVarPtg extends AbstractFunctionPtg {
|
||||
out.writeShort(getFunctionIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@ -31,8 +31,9 @@ public final class GreaterEqualPtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getNumberOfOperands() {
|
||||
@ -40,14 +41,7 @@ public final class GreaterEqualPtg extends ValueOperatorPtg {
|
||||
}
|
||||
|
||||
public String toFormulaString(String[] operands) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append(operands[ 0 ]);
|
||||
|
||||
buffer.append(">=");
|
||||
buffer.append(operands[ 1 ]);
|
||||
|
||||
return buffer.toString();
|
||||
return operands[0] + ">=" + operands[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -31,8 +31,9 @@ public final class GreaterThanPtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,14 +49,8 @@ public final class GreaterThanPtg extends ValueOperatorPtg {
|
||||
* @param operands a String array of operands
|
||||
* @return String the Formula as a String
|
||||
*/
|
||||
public String toFormulaString(String[] operands)
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append(operands[ 0 ]);
|
||||
buffer.append(GREATERTHAN);
|
||||
buffer.append(operands[ 1 ]);
|
||||
return buffer.toString();
|
||||
public String toFormulaString(String[] operands) {
|
||||
return operands[0] + GREATERTHAN + operands[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -66,6 +66,11 @@ public final class IntPtg extends ScalarConstantPtg {
|
||||
out.writeShort(getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@ -32,6 +32,11 @@ public final class IntersectionPtg extends OperationPtg {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return 1;
|
||||
}
|
||||
@ -45,12 +50,7 @@ public final class IntersectionPtg extends OperationPtg {
|
||||
}
|
||||
|
||||
public String toFormulaString(String[] operands) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append(operands[0]);
|
||||
buffer.append(" ");
|
||||
buffer.append(operands[1]);
|
||||
return buffer.toString();
|
||||
return operands[0] + " " + operands[1];
|
||||
}
|
||||
|
||||
public int getNumberOfOperands() {
|
||||
|
||||
@ -33,8 +33,9 @@ public final class LessEqualPtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getNumberOfOperands() {
|
||||
@ -42,11 +43,7 @@ public final class LessEqualPtg extends ValueOperatorPtg {
|
||||
}
|
||||
|
||||
public String toFormulaString(String[] operands) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append( operands[0] );
|
||||
buffer.append("<=");
|
||||
buffer.append( operands[1] );
|
||||
return buffer.toString();
|
||||
return operands[0] + "<=" + operands[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -35,8 +35,9 @@ public final class LessThanPtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,13 +53,8 @@ public final class LessThanPtg extends ValueOperatorPtg {
|
||||
* @param operands a String array of operands
|
||||
* @return String the Formula as a String
|
||||
*/
|
||||
public String toFormulaString(String[] operands)
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append(operands[ 0 ]);
|
||||
buffer.append(LESSTHAN);
|
||||
buffer.append(operands[ 1 ]);
|
||||
return buffer.toString();
|
||||
public String toFormulaString(String[] operands) {
|
||||
return operands[0] + LESSTHAN + operands[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -52,6 +52,11 @@ public final class MemAreaPtg extends OperandPtg {
|
||||
out.writeShort(field_2_subex_len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@ -47,6 +47,11 @@ public final class MemErrPtg extends OperandPtg {
|
||||
out.writeShort(field_2_subex_len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@ -41,6 +41,11 @@ public final class MemFuncPtg extends OperandPtg {
|
||||
field_1_len_ref_subexpression = subExprLen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@ -40,6 +40,11 @@ public final class MissingArgPtg extends ScalarConstantPtg {
|
||||
out.writeByte(sid + getPtgClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@ -29,8 +29,9 @@ public final class MultiplyPtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getNumberOfOperands() {
|
||||
@ -38,12 +39,7 @@ public final class MultiplyPtg extends ValueOperatorPtg {
|
||||
}
|
||||
|
||||
public String toFormulaString(String[] operands) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append(operands[ 0 ]);
|
||||
buffer.append("*");
|
||||
buffer.append(operands[ 1 ]);
|
||||
return buffer.toString();
|
||||
return operands[0] + "*" + operands[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -70,6 +70,11 @@ public final class NamePtg extends OperandPtg implements WorkbookDependentFormul
|
||||
out.writeShort(field_2_zero);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
|
||||
@ -70,6 +70,11 @@ public final class NameXPtg extends OperandPtg implements WorkbookDependentFormu
|
||||
out.writeShort(_reserved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@ -94,6 +94,11 @@ public final class NameXPxg extends OperandPtg implements Pxg {
|
||||
return Ptg.CLASS_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -29,8 +29,9 @@ public final class NotEqualPtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getNumberOfOperands() {
|
||||
@ -38,14 +39,7 @@ public final class NotEqualPtg extends ValueOperatorPtg {
|
||||
}
|
||||
|
||||
public String toFormulaString(String[] operands) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append( operands[0] );
|
||||
|
||||
buffer.append("<>");
|
||||
buffer.append( operands[1] );
|
||||
|
||||
return buffer.toString();
|
||||
return operands[0] + "<>" + operands[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -62,6 +62,11 @@ public final class NumberPtg extends ScalarConstantPtg {
|
||||
out.writeDouble(getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@ -42,6 +42,11 @@ public final class ParenthesisPtg extends ControlPtg {
|
||||
out.writeByte(sid + getPtgClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@ -32,8 +32,9 @@ public final class PercentPtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getNumberOfOperands() {
|
||||
@ -41,11 +42,7 @@ public final class PercentPtg extends ValueOperatorPtg {
|
||||
}
|
||||
|
||||
public String toFormulaString(String[] operands) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append(operands[ 0 ]);
|
||||
buffer.append(PERCENT);
|
||||
return buffer.toString();
|
||||
return operands[0] + PERCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -26,8 +26,9 @@ public final class PowerPtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getNumberOfOperands() {
|
||||
@ -35,13 +36,7 @@ public final class PowerPtg extends ValueOperatorPtg {
|
||||
}
|
||||
|
||||
public String toFormulaString(String[] operands) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
|
||||
buffer.append(operands[ 0 ]);
|
||||
buffer.append("^");
|
||||
buffer.append(operands[ 1 ]);
|
||||
return buffer.toString();
|
||||
return operands[0] + "^" + operands[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -319,4 +319,9 @@ public abstract class Ptg implements Duplicatable, GenericRecord {
|
||||
|
||||
@Override
|
||||
public abstract Ptg copy();
|
||||
|
||||
/**
|
||||
* @return structure id of the parsed thing, or {@code -1} if the record has no sid
|
||||
*/
|
||||
public abstract byte getSid();
|
||||
}
|
||||
|
||||
@ -34,8 +34,12 @@ public final class RangePtg extends OperationPtg {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@ -50,14 +54,8 @@ public final class RangePtg extends OperationPtg {
|
||||
|
||||
|
||||
/** implementation of method from OperationsPtg*/
|
||||
public String toFormulaString(String[] operands)
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append(operands[ 0 ]);
|
||||
buffer.append(":");
|
||||
buffer.append(operands[ 1 ]);
|
||||
return buffer.toString();
|
||||
public String toFormulaString(String[] operands) {
|
||||
return operands[0] + ":" + operands[1];
|
||||
}
|
||||
|
||||
public int getNumberOfOperands()
|
||||
|
||||
@ -55,8 +55,6 @@ abstract class Ref2DPtgBase extends RefPtgBase {
|
||||
return formatReferenceAsString();
|
||||
}
|
||||
|
||||
protected abstract byte getSid();
|
||||
|
||||
@Override
|
||||
public final int getSize() {
|
||||
return SIZE;
|
||||
|
||||
@ -67,6 +67,11 @@ public final class Ref3DPtg extends RefPtgBase implements WorkbookDependentFormu
|
||||
writeCoordinates(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@ -98,6 +98,11 @@ public final class Ref3DPxg extends RefPtgBase implements Pxg3D {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -52,8 +52,12 @@ public final class RefErrorPtg extends OperandPtg {
|
||||
out.writeInt(field_1_reserved);
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
|
||||
@ -31,9 +31,10 @@ public final class RefNPtg extends Ref2DPtgBase {
|
||||
super(other);
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
protected final String formatReferenceAsString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
@ -50,7 +50,8 @@ public final class RefPtg extends Ref2DPtgBase {
|
||||
super(cr);
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
|
||||
@ -84,6 +84,11 @@ public final class StringPtg extends ScalarConstantPtg {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return 3 + field_3_string.length() * (_is16bitUnicode ? 2 : 1);
|
||||
}
|
||||
|
||||
@ -26,8 +26,9 @@ public final class SubtractPtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getNumberOfOperands() {
|
||||
@ -35,12 +36,7 @@ public final class SubtractPtg extends ValueOperatorPtg {
|
||||
}
|
||||
|
||||
public String toFormulaString(String[] operands) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append(operands[ 0 ]);
|
||||
buffer.append("-");
|
||||
buffer.append(operands[ 1 ]);
|
||||
return buffer.toString();
|
||||
return operands[0] + "-" + operands[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -58,6 +58,11 @@ public final class TblPtg extends ControlPtg {
|
||||
out.writeShort(field_2_first_col);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@ -31,8 +31,9 @@ public final class UnaryMinusPtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getNumberOfOperands() {
|
||||
@ -41,10 +42,7 @@ public final class UnaryMinusPtg extends ValueOperatorPtg {
|
||||
|
||||
/** implementation of method from OperationsPtg*/
|
||||
public String toFormulaString(String[] operands) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append(MINUS);
|
||||
buffer.append(operands[ 0]);
|
||||
return buffer.toString();
|
||||
return MINUS + operands[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -31,8 +31,9 @@ public final class UnaryPlusPtg extends ValueOperatorPtg {
|
||||
// enforce singleton
|
||||
}
|
||||
|
||||
protected byte getSid() {
|
||||
return sid;
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getNumberOfOperands() {
|
||||
@ -41,10 +42,7 @@ public final class UnaryPlusPtg extends ValueOperatorPtg {
|
||||
|
||||
/** implementation of method from OperationsPtg*/
|
||||
public String toFormulaString(String[] operands) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append(ADD);
|
||||
buffer.append(operands[ 0]);
|
||||
return buffer.toString();
|
||||
return ADD + operands[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -36,8 +36,12 @@ public final class UnionPtg extends OperationPtg {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -52,14 +56,8 @@ public final class UnionPtg extends OperationPtg {
|
||||
|
||||
|
||||
/** implementation of method from OperationsPtg*/
|
||||
public String toFormulaString(String[] operands)
|
||||
{
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
buffer.append(operands[ 0 ]);
|
||||
buffer.append(",");
|
||||
buffer.append(operands[ 1 ]);
|
||||
return buffer.toString();
|
||||
public String toFormulaString(String[] operands) {
|
||||
return operands[0] + "," + operands[1];
|
||||
}
|
||||
|
||||
public int getNumberOfOperands()
|
||||
|
||||
@ -22,7 +22,7 @@ import java.util.function.Supplier;
|
||||
import org.apache.poi.util.LittleEndianOutput;
|
||||
|
||||
public class UnknownPtg extends Ptg {
|
||||
private short size = 1;
|
||||
private final short size = 1;
|
||||
private final int _sid;
|
||||
|
||||
public UnknownPtg(int sid) {
|
||||
@ -36,6 +36,11 @@ public class UnknownPtg extends Ptg {
|
||||
out.writeByte(_sid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return (byte)_sid;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@ -43,8 +43,6 @@ public abstract class ValueOperatorPtg extends OperationPtg {
|
||||
out.writeByte(getSid());
|
||||
}
|
||||
|
||||
protected abstract byte getSid();
|
||||
|
||||
public final int getSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -49,6 +49,11 @@ public class TestAbstractFunctionPtg {
|
||||
super(functionIndex, pReturnClass, paramTypes, nParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getSid() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user