Simplify the ValueEval.toString() implementations and include more information on unexpected types of ValueEval
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1794956 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d9df038f4a
commit
e77156d9f4
@ -34,7 +34,7 @@ public final class BoolEval implements NumericValueEval, StringValueEval {
|
|||||||
*
|
*
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,10 +55,8 @@ public final class BoolEval implements NumericValueEval, StringValueEval {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder(64);
|
return getClass().getName() + " [" +
|
||||||
sb.append(getClass().getName()).append(" [");
|
getStringValue() +
|
||||||
sb.append(getStringValue());
|
"]";
|
||||||
sb.append("]");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,8 @@ public final class ErrorEval implements ValueEval {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 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);
|
||||||
@ -89,10 +90,8 @@ public final class ErrorEval implements ValueEval {
|
|||||||
return _error.getString();
|
return _error.getString();
|
||||||
}
|
}
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer(64);
|
return getClass().getName() + " [" +
|
||||||
sb.append(getClass().getName()).append(" [");
|
_error.getString() +
|
||||||
sb.append(_error.getString());
|
"]";
|
||||||
sb.append("]");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,8 @@ public final class ExternalNameEval implements ValueEval {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer(64);
|
return getClass().getName() + " [" +
|
||||||
sb.append(getClass().getName()).append(" [");
|
_name.getNameText() +
|
||||||
sb.append(_name.getNameText());
|
"]";
|
||||||
sb.append("]");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,8 @@ public final class FunctionNameEval implements ValueEval {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer(64);
|
return getClass().getName() + " [" +
|
||||||
sb.append(getClass().getName()).append(" [");
|
_functionName +
|
||||||
sb.append(_functionName);
|
"]";
|
||||||
sb.append("]");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,8 @@ public final class StringEval implements StringValueEval {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder(64);
|
return getClass().getName() + " [" +
|
||||||
sb.append(getClass().getName()).append(" [");
|
_value +
|
||||||
sb.append(_value);
|
"]";
|
||||||
sb.append("]");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ final class LookupUtils {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ final class LookupUtils {
|
|||||||
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 ;
|
||||||
}
|
}
|
||||||
@ -215,11 +215,9 @@ final class LookupUtils {
|
|||||||
return _isGreaterThan;
|
return _isGreaterThan;
|
||||||
}
|
}
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer(64);
|
return getClass().getName() + " [" +
|
||||||
sb.append(getClass().getName()).append(" [");
|
formatAsString() +
|
||||||
sb.append(formatAsString());
|
"]";
|
||||||
sb.append("]");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatAsString() {
|
private String formatAsString() {
|
||||||
@ -267,11 +265,9 @@ final class LookupUtils {
|
|||||||
return compareSameType(other);
|
return compareSameType(other);
|
||||||
}
|
}
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer(64);
|
return getClass().getName() + " [" +
|
||||||
sb.append(getClass().getName()).append(" [");
|
getValueAsString() +
|
||||||
sb.append(getValueAsString());
|
"]";
|
||||||
sb.append("]");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
protected abstract CompareResult compareSameType(ValueEval other);
|
protected abstract CompareResult compareSameType(ValueEval other);
|
||||||
/** used only for debug purposes */
|
/** used only for debug purposes */
|
||||||
@ -475,7 +471,7 @@ final class LookupUtils {
|
|||||||
// 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 {
|
||||||
|
@ -153,7 +153,7 @@ public final class Match extends Var2or3ArgFunction {
|
|||||||
// 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 + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user