display TRUE/FALSE for booleans

This commit is contained in:
Denis Molony 2017-03-18 11:24:05 +11:00
parent 3cde604877
commit 914199601e
8 changed files with 66 additions and 1 deletions

View File

@ -65,6 +65,12 @@ public abstract class AbstractValue implements Value
{ {
} }
@Override
public boolean isBoolean ()
{
return false;
}
// for debugging // for debugging
String getValueText (int depth) String getValueText (int depth)
{ {

View File

@ -39,4 +39,16 @@ class And extends Function
} }
value = 1; value = 1;
} }
@Override
public boolean isBoolean ()
{
return true;
}
@Override
public String getText ()
{
return value == 0 ? "FALSE" : "TRUE";
}
} }

View File

@ -182,6 +182,13 @@ class Cell extends AbstractValue implements Comparable<Cell>
return " " + Format.justify (value.getText (), colWidth - 1, fmtChar); return " " + Format.justify (value.getText (), colWidth - 1, fmtChar);
} }
if (value.isBoolean ()) // consider ValueType of BOOLEAN
{
if (fmtChar != 'L')
fmtChar = 'R';
return Format.justify (value.getText (), colWidth, fmtChar);
}
if (colWidth == 1) if (colWidth == 1)
return "."; return ".";
return " " + Format.format (value, fmtChar, colWidth - 1); return " " + Format.format (value, fmtChar, colWidth - 1);

View File

@ -7,5 +7,18 @@ public class False extends Function
super (parent, cell, text); super (parent, cell, text);
value = 0; value = 0;
valueType = ValueType.VALUE;
}
@Override
public boolean isBoolean ()
{
return true;
}
@Override
public String getText ()
{
return value == 0 ? "FALSE" : "TRUE";
} }
} }

View File

@ -7,7 +7,7 @@ abstract class Function extends AbstractValue implements Iterable<Value>
static final String[] functionList = static final String[] functionList =
{ "@ABS(", "@ACOS(", "@AND(", "@ASIN(", "@ATAN(", "@AVERAGE(", "@COUNT(", { "@ABS(", "@ACOS(", "@AND(", "@ASIN(", "@ATAN(", "@AVERAGE(", "@COUNT(",
"@CHOOSE(", "@COS(", "@ERROR", "@EXP(", "@FALSE", "@IF(", "@INT(", "@ISERROR(", "@CHOOSE(", "@COS(", "@ERROR", "@EXP(", "@FALSE", "@IF(", "@INT(", "@ISERROR(",
"@ISNA(", "@LOG10(", "@LOOKUP(", "@LN(", "@MIN(", "@MAX(", "@NA", "@NPV", "@OR(", "@ISNA(", "@LOG10(", "@LOOKUP(", "@LN(", "@MIN(", "@MAX(", "@NA", "@NPV(", "@OR(",
"@PI", "@SIN(", "@SUM(", "@SQRT(", "@TAN(", "@TRUE" }; "@PI", "@SIN(", "@SUM(", "@SQRT(", "@TAN(", "@TRUE" };
protected final Sheet parent; protected final Sheet parent;

View File

@ -39,4 +39,16 @@ class Or extends Function
} }
value = 0; value = 0;
} }
@Override
public boolean isBoolean ()
{
return true;
}
@Override
public String getText ()
{
return value == 0 ? "FALSE" : "TRUE";
}
} }

View File

@ -7,5 +7,18 @@ public class True extends Function
super (parent, cell, text); super (parent, cell, text);
value = 1; value = 1;
valueType = ValueType.VALUE;
}
@Override
public boolean isBoolean ()
{
return true;
}
@Override
public String getText ()
{
return value == 0 ? "FALSE" : "TRUE";
} }
} }

View File

@ -20,4 +20,6 @@ interface Value
public String getTypeText (); // Number/Function/Expression etc public String getTypeText (); // Number/Function/Expression etc
public boolean isVolatile (); public boolean isVolatile ();
public boolean isBoolean ();
} }