git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1794956 13f79535-47bb-0310-9956-ffa450edef68tags/REL_3_17_BETA1
* | * | ||||
* @return the <tt>BoolEval</tt> instance representing <tt>b</tt>. | * @return the <tt>BoolEval</tt> instance representing <tt>b</tt>. | ||||
*/ | */ | ||||
public static final BoolEval valueOf(boolean b) { | |||||
public static BoolEval valueOf(boolean b) { | |||||
return b ? TRUE : FALSE; | return b ? TRUE : FALSE; | ||||
} | } | ||||
} | } | ||||
public String toString() { | public String toString() { | ||||
StringBuilder sb = new StringBuilder(64); | |||||
sb.append(getClass().getName()).append(" ["); | |||||
sb.append(getStringValue()); | |||||
sb.append("]"); | |||||
return sb.toString(); | |||||
return getClass().getName() + " [" + | |||||
getStringValue() + | |||||
"]"; | |||||
} | } | ||||
} | } |
/** | /** | ||||
* Translates an Excel internal error code into the corresponding POI ErrorEval instance | * Translates an Excel internal error code into the corresponding POI ErrorEval instance | ||||
* @param errorCode | |||||
* @param errorCode An error code listed in {@link FormulaError} | |||||
* @throws RuntimeException If an unknown errorCode is specified | |||||
*/ | */ | ||||
public static ErrorEval valueOf(int errorCode) { | public static ErrorEval valueOf(int errorCode) { | ||||
FormulaError error = FormulaError.forInt(errorCode); | FormulaError error = FormulaError.forInt(errorCode); | ||||
return _error.getString(); | return _error.getString(); | ||||
} | } | ||||
public String toString() { | public String toString() { | ||||
StringBuffer sb = new StringBuffer(64); | |||||
sb.append(getClass().getName()).append(" ["); | |||||
sb.append(_error.getString()); | |||||
sb.append("]"); | |||||
return sb.toString(); | |||||
return getClass().getName() + " [" + | |||||
_error.getString() + | |||||
"]"; | |||||
} | } | ||||
} | } |
} | } | ||||
public String toString() { | public String toString() { | ||||
StringBuffer sb = new StringBuffer(64); | |||||
sb.append(getClass().getName()).append(" ["); | |||||
sb.append(_name.getNameText()); | |||||
sb.append("]"); | |||||
return sb.toString(); | |||||
return getClass().getName() + " [" + | |||||
_name.getNameText() + | |||||
"]"; | |||||
} | } | ||||
} | } |
} | } | ||||
public String toString() { | public String toString() { | ||||
StringBuffer sb = new StringBuffer(64); | |||||
sb.append(getClass().getName()).append(" ["); | |||||
sb.append(_functionName); | |||||
sb.append("]"); | |||||
return sb.toString(); | |||||
return getClass().getName() + " [" + | |||||
_functionName + | |||||
"]"; | |||||
} | } | ||||
} | } |
} | } | ||||
public String toString() { | public String toString() { | ||||
StringBuilder sb = new StringBuilder(64); | |||||
sb.append(getClass().getName()).append(" ["); | |||||
sb.append(_value); | |||||
sb.append("]"); | |||||
return sb.toString(); | |||||
return getClass().getName() + " [" + | |||||
_value + | |||||
"]"; | |||||
} | } | ||||
} | } |
public static final CompareResult EQUAL = new CompareResult(false, 0); | public static final CompareResult EQUAL = new CompareResult(false, 0); | ||||
public static final CompareResult GREATER_THAN = new CompareResult(false, +1); | public static final CompareResult GREATER_THAN = new CompareResult(false, +1); | ||||
public static final CompareResult valueOf(int simpleCompareResult) { | |||||
public static CompareResult valueOf(int simpleCompareResult) { | |||||
if(simpleCompareResult < 0) { | if(simpleCompareResult < 0) { | ||||
return LESS_THAN; | return LESS_THAN; | ||||
} | } | ||||
return EQUAL; | return EQUAL; | ||||
} | } | ||||
public static final CompareResult valueOf(boolean matches) { | |||||
public static CompareResult valueOf(boolean matches) { | |||||
if(matches) { | if(matches) { | ||||
return EQUAL ; | return EQUAL ; | ||||
} | } | ||||
return _isGreaterThan; | return _isGreaterThan; | ||||
} | } | ||||
public String toString() { | public String toString() { | ||||
StringBuffer sb = new StringBuffer(64); | |||||
sb.append(getClass().getName()).append(" ["); | |||||
sb.append(formatAsString()); | |||||
sb.append("]"); | |||||
return sb.toString(); | |||||
return getClass().getName() + " [" + | |||||
formatAsString() + | |||||
"]"; | |||||
} | } | ||||
private String formatAsString() { | private String formatAsString() { | ||||
return compareSameType(other); | return compareSameType(other); | ||||
} | } | ||||
public String toString() { | public String toString() { | ||||
StringBuffer sb = new StringBuffer(64); | |||||
sb.append(getClass().getName()).append(" ["); | |||||
sb.append(getValueAsString()); | |||||
sb.append("]"); | |||||
return sb.toString(); | |||||
return getClass().getName() + " [" + | |||||
getValueAsString() + | |||||
"]"; | |||||
} | } | ||||
protected abstract CompareResult compareSameType(ValueEval other); | protected abstract CompareResult compareSameType(ValueEval other); | ||||
/** used only for debug purposes */ | /** used only for debug purposes */ | ||||
// zero is FALSE, everything else is TRUE | // zero is FALSE, everything else is TRUE | ||||
return 0.0 != nve.getNumberValue(); | return 0.0 != nve.getNumberValue(); | ||||
} | } | ||||
throw new RuntimeException("Unexpected eval type (" + valEval.getClass().getName() + ")"); | |||||
throw new RuntimeException("Unexpected eval type (" + valEval + ")"); | |||||
} | } | ||||
public static int lookupIndexOfValue(ValueEval lookupValue, ValueVector vector, boolean isRangeLookup) throws EvaluationException { | public static int lookupIndexOfValue(ValueEval lookupValue, ValueVector vector, boolean isRangeLookup) throws EvaluationException { |
// else looks like a number | // else looks like a number | ||||
throw new EvaluationException(ErrorEval.NA); | throw new EvaluationException(ErrorEval.NA); | ||||
} | } | ||||
throw new RuntimeException("Unexpected eval type (" + eval.getClass().getName() + ")"); | |||||
throw new RuntimeException("Unexpected eval type (" + eval + ")"); | |||||
} | } | ||||