mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-01-22 14:31:00 +00:00
debug text
This commit is contained in:
parent
71ce82ce69
commit
5dbdbadf5e
@ -6,8 +6,16 @@ import java.util.List;
|
||||
|
||||
public abstract class AbstractValue implements Value, Iterable<Value>
|
||||
{
|
||||
protected static final String FMT4 = "| %-9.9s : %-50.50s%-8.8s %-10.10s|%n";
|
||||
protected static final String FMT2 = "| %-9.9s : %-69.69s|%n";
|
||||
protected static final String FMT5 = "| %-9.9s : %-3.3s : %-44.44s%-8.8s %-10.10s|%n";
|
||||
protected static final String LINE =
|
||||
"+----------------------------------------------------------"
|
||||
+ "------------------------+";
|
||||
|
||||
protected final Cell cell;
|
||||
protected final String fullText;
|
||||
|
||||
protected double value;
|
||||
protected boolean bool;
|
||||
protected ValueType valueType = ValueType.NUMBER; // could be BOOLEAN
|
||||
@ -44,12 +52,6 @@ public abstract class AbstractValue implements Value, Iterable<Value>
|
||||
return valueResult == ValueResult.VALID;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean isValueType (ValueType type)
|
||||
// {
|
||||
// return valueType == type;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public double getDouble ()
|
||||
{
|
||||
@ -92,64 +94,15 @@ public abstract class AbstractValue implements Value, Iterable<Value>
|
||||
// System.out.println ("calculate not overridden: " + cell);
|
||||
}
|
||||
|
||||
protected String getValueText (Value value)
|
||||
{
|
||||
return "" + (value.getValueType () == ValueType.NUMBER ? value.getDouble ()
|
||||
: value.getBoolean ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Value> iterator ()
|
||||
{
|
||||
return values.iterator ();
|
||||
}
|
||||
|
||||
// for debugging
|
||||
// String getValueText (int depth)
|
||||
// {
|
||||
// StringBuilder text = new StringBuilder ();
|
||||
//
|
||||
// String typeText = " " + getTypeText ();
|
||||
// if (getValueType () == ValueType.NUMBER)
|
||||
// {
|
||||
// String valueText = String.format ("%f", getDouble ());
|
||||
// text.append (String.format ("| %-10s : %-69s |%n", typeText, valueText));
|
||||
// }
|
||||
// else if (getValueType () == ValueType.BOOLEAN)
|
||||
// {
|
||||
// String valueText = String.format ("%s", getBoolean ());
|
||||
// text.append (String.format ("| %-10s : %-69s |%n", typeText, valueText));
|
||||
// }
|
||||
// else
|
||||
// text.append (String.format ("| %-10s : %-69s |%n", typeText, getValueType ()));
|
||||
//
|
||||
// if (this instanceof Expression)
|
||||
// {
|
||||
// text.append (
|
||||
// String.format ("| Expression : %-69s |%n", ((Expression) this).fullText ()));
|
||||
// for (Value v : (Expression) this)
|
||||
// {
|
||||
// if (v instanceof Cell)
|
||||
// {
|
||||
// Cell c = (Cell) v;
|
||||
// ValueType vt = c.getValueType ();
|
||||
// String tx = vt == ValueType.NUMBER ? c.getDouble () + "" : c.getBoolean () + "";
|
||||
// text.append (
|
||||
// String.format ("| Cell %-3s : %-69s |%n", c.getAddressText (), tx));
|
||||
// }
|
||||
// else
|
||||
// text.append (((AbstractValue) v).getValueText (depth + 1));
|
||||
// }
|
||||
// }
|
||||
// else if (this instanceof Function)
|
||||
// {
|
||||
// text.append (
|
||||
// String.format ("| Function : %-69s |%n", ((Function) this).fullText));
|
||||
// for (Value v : (Function) this)
|
||||
// text.append (((AbstractValue) v).getValueText (depth + 1));
|
||||
// }
|
||||
// else if (this instanceof Condition)
|
||||
// {
|
||||
// text.append (
|
||||
// String.format ("| Condition : %-69s |%n", ((Condition) this).getFullText ()));
|
||||
// for (Value v : (Condition) this)
|
||||
// text.append (((AbstractValue) v).getValueText (depth + 1));
|
||||
// }
|
||||
//
|
||||
// return text.toString ();
|
||||
// }
|
||||
}
|
@ -287,9 +287,9 @@ class Cell implements Value, Comparable<Cell>
|
||||
switch (cellType)
|
||||
{
|
||||
case LABEL:
|
||||
return label;
|
||||
return "LBL : " + label;
|
||||
case REPEATING_CHARACTER:
|
||||
return repeatingText;
|
||||
return "RPT : " + repeatingText;
|
||||
case EMPTY:
|
||||
return "Empty Cell";
|
||||
case VALUE:
|
||||
@ -302,7 +302,7 @@ class Cell implements Value, Comparable<Cell>
|
||||
@Override
|
||||
public String getType ()
|
||||
{
|
||||
return "Cell";
|
||||
return "Cell " + getAddressText ();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -320,77 +320,31 @@ class Cell implements Value, Comparable<Cell>
|
||||
return value;
|
||||
}
|
||||
|
||||
// public String getDebugText ()
|
||||
// {
|
||||
// StringBuilder text = new StringBuilder ();
|
||||
// text.append (line);
|
||||
// text.append ("\n");
|
||||
// text.append (String.format ("| %-11s %s Format: %s |%n",
|
||||
// address.getText (), address.getDetails (), cellFormat));
|
||||
// text.append (line);
|
||||
// text.append ("\n");
|
||||
//
|
||||
// switch (cellType)
|
||||
// {
|
||||
// case LABEL:
|
||||
// text.append (String.format ("| LABEL : %-69s |%n", label));
|
||||
// break;
|
||||
//
|
||||
// case REPEATING_CHARACTER:
|
||||
// text.append (String.format ("| REPEAT : %-69s |%n", repeatingText));
|
||||
// break;
|
||||
//
|
||||
// case EMPTY:
|
||||
// text.append (String.format ("| EMPTY : %-69s |%n", ""));
|
||||
// break;
|
||||
//
|
||||
// case VALUE:
|
||||
// text.append (String.format ("| VALUE : %-69s |%n", expressionText));
|
||||
// if (value == null)
|
||||
// text.append (String.format ("| Value : %-69s |%n", "null"));
|
||||
// else
|
||||
// text.append (((AbstractValue) value).getValueText (0));
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// text.append ("Unknown CellType: " + cellType + "\n");
|
||||
// }
|
||||
//
|
||||
// text.append (line);
|
||||
// return text.toString ();
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
String contents = "";
|
||||
String valueText = "";
|
||||
|
||||
switch (cellType)
|
||||
{
|
||||
case LABEL:
|
||||
contents = "Labl: " + label;
|
||||
contents = label;
|
||||
break;
|
||||
case REPEATING_CHARACTER:
|
||||
contents = "Rept: " + repeatingText;
|
||||
contents = repeatingText;
|
||||
break;
|
||||
case EMPTY:
|
||||
contents = "Empty";
|
||||
contents = "";
|
||||
break;
|
||||
case VALUE:
|
||||
switch (value.getValueType ())
|
||||
{
|
||||
case NUMBER:
|
||||
contents = "Num : " + fullText;
|
||||
break;
|
||||
case BOOLEAN:
|
||||
contents = "Bool: " + fullText;
|
||||
break;
|
||||
}
|
||||
// contents = "Exp : " + expressionText;
|
||||
contents = fullText;
|
||||
valueText = ": " + value.getValueType ();
|
||||
break;
|
||||
}
|
||||
|
||||
return String.format ("Cell:%5s %s", address.getText (), contents);
|
||||
return String.format ("%s%n| %-9.9s : %-49.49s %-18.18s |%n", AbstractValue.LINE,
|
||||
address.getText (), contents, cellType + valueText);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -161,20 +161,19 @@ class Condition extends AbstractValue implements Iterable<Value>
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
String line = "+-------------------------------------------------------------+";
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append (line + "\n");
|
||||
text.append (String.format ("| %-10.10s: CND : %-34.34s%-8.8s|%n",
|
||||
cell.getAddressText (), getFullText (), valueType));
|
||||
text.append (String.format ("| %-10.10s: %-40.40s%-8.8s|%n", "Condition",
|
||||
conditionText, conditionExpression.getValueType ()));
|
||||
text.append (LINE + "\n");
|
||||
text.append (String.format (FMT4, "Predicate", getFullText (), valueType,
|
||||
getValueText (this)));
|
||||
text.append (String.format (FMT4, "Left", conditionText,
|
||||
conditionExpression.getValueType (), getValueText (conditionExpression)));
|
||||
if (comparator != null)
|
||||
{
|
||||
text.append (String.format ("| %-10.10s: %-60.60s|%n", "Comparatr", comparator));
|
||||
text.append (String.format ("| %-10.10s: %-40.40s%-8.8s|%n", "Value", valueText,
|
||||
valueExpression.getValueType ()));
|
||||
text.append (String.format (FMT2, "Comparatr", comparator));
|
||||
text.append (String.format (FMT4, "Right", valueText,
|
||||
valueExpression.getValueType (), getValueText (valueExpression)));
|
||||
}
|
||||
text.append (line);
|
||||
// text.append (LINE);
|
||||
return text.toString ();
|
||||
}
|
||||
}
|
@ -21,15 +21,13 @@ public class ConditionListFunction extends Function
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
String line = "+-------------------------------------------------------------+";
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append (line + "\n");
|
||||
text.append (String.format ("| %-10.10s: CFN : %-34.34s%-8.8s|%n",
|
||||
cell.getAddressText (), getFullText (), valueType));
|
||||
text.append (String.format ("%s%n", LINE));
|
||||
text.append (
|
||||
String.format (FMT4, "CFN", getFullText (), valueType, getValueText (this)));
|
||||
for (Value value : conditions)
|
||||
text.append (String.format ("| %-10.10s: %-40.40s%-8.8s|%n", "Value",
|
||||
value.getFullText (), value.getValueType ()));
|
||||
text.append (line);
|
||||
text.append (String.format (FMT4, value.getType (), value.getFullText (),
|
||||
value.getValueType (), getValueText (value)));
|
||||
return text.toString ();
|
||||
}
|
||||
}
|
@ -355,25 +355,22 @@ class Expression extends AbstractValue //implements Iterable<Value>
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
String line = "+-------------------------------------------------------------+";
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append (line + "\n");
|
||||
text.append (String.format ("| %-10.10s: EXP : %-34.34s%-8.8s|%n",
|
||||
cell.getAddressText (), getFullText (), valueType));
|
||||
text.append (String.format ("%s%n", LINE));
|
||||
text.append (
|
||||
String.format (FMT4, "Exprss", getFullText (), valueType, getValueText (this)));
|
||||
int index = 0;
|
||||
for (Value value : values)
|
||||
{
|
||||
String sign = signs.get (index);
|
||||
if (!"(+)".equals (sign))
|
||||
text.append (String.format ("| %-10.10s: %-40.40s|%n", "sign", sign));
|
||||
text.append (String.format ("| %-10.10s: %-40.40s%-8.8s|%n", "Value",
|
||||
value.getFullText (), value.getValueType ()));
|
||||
text.append (String.format (FMT2, "sign", sign));
|
||||
text.append (String.format (FMT4, value.getType (), value.getFullText (),
|
||||
value.getValueType (), getValueText (value)));
|
||||
if (index < operators.size ())
|
||||
text.append (
|
||||
String.format ("| %-10.10s: %-48.48s|%n", "operator", operators.get (index)));
|
||||
text.append (String.format (FMT2, "operator", operators.get (index)));
|
||||
++index;
|
||||
}
|
||||
text.append (line);
|
||||
return text.toString ();
|
||||
}
|
||||
}
|
@ -32,12 +32,15 @@ abstract class Function extends AbstractValue
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
String line = "+-------------------------------------------------------------+";
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append (line + "\n");
|
||||
text.append (String.format ("| %-10.10s: FN : %-34.34s%-8.8s|%n",
|
||||
cell.getAddressText (), getFullText (), valueType));
|
||||
text.append (line);
|
||||
text.append (String.format ("%s%n", LINE));
|
||||
text.append (
|
||||
String.format (FMT4, "Function", getFullText (), valueType, getValueText (this)));
|
||||
for (Value value : values)
|
||||
{
|
||||
text.append (String.format (FMT4, value.getType (), value.getFullText (),
|
||||
value.getValueType (), getValueText (value)));
|
||||
}
|
||||
return text.toString ();
|
||||
}
|
||||
}
|
@ -78,18 +78,17 @@ class If extends Function
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
String line = "+-------------------------------------------------------------+";
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append (line + "\n");
|
||||
text.append (String.format ("| %-10.10s: %-40.40s%-8.8s|%n", cell.getAddressText (),
|
||||
fullText, valueType));
|
||||
text.append (String.format ("| condition : %-40.40s%-8.8s|%n", conditionText,
|
||||
condition.getValueType ()));
|
||||
text.append (String.format ("| true : %-40.40s%-8.8s|%n", textTrue,
|
||||
expTrue.getValueType ()));
|
||||
text.append (String.format ("| false : %-40.40s%-8.8s|%n", textFalse,
|
||||
expFalse.getValueType ()));
|
||||
text.append (line);
|
||||
text.append (String.format ("%s%n", LINE));
|
||||
text.append (String.format (FMT4, "IF", fullText, valueType, getValueText (this)));
|
||||
text.append (String.format (FMT4, "condition", conditionText,
|
||||
condition.getValueType (), getValueText (condition)));
|
||||
if (condition.getBoolean ())
|
||||
text.append (String.format (FMT4, "true", textTrue, expTrue.getValueType (),
|
||||
getValueText (expTrue)));
|
||||
else
|
||||
text.append (String.format (FMT4, "false", textFalse, expFalse.getValueType (),
|
||||
getValueText (expFalse)));
|
||||
return text.toString ();
|
||||
}
|
||||
}
|
@ -34,13 +34,10 @@ class Number extends AbstractValue
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
// return String.format ("Number: %f", value);
|
||||
String line = "+-------------------------------------------------------------+";
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append (line + "\n");
|
||||
text.append (String.format ("| %-10.10s: NUM : %-34.34s%-8.8s|%n",
|
||||
cell.getAddressText (), getFullText (), valueType));
|
||||
text.append (line);
|
||||
text.append (String.format ("%s%n", LINE));
|
||||
text.append (String.format (FMT5, cell.getAddressText (), "NUM", getFullText (),
|
||||
valueType, getValueText (this)));
|
||||
return text.toString ();
|
||||
}
|
||||
}
|
@ -473,16 +473,14 @@ public class Sheet
|
||||
+ " ***\n\n");
|
||||
last = cell.getAddress ().getColumn ();
|
||||
}
|
||||
// text.append (cell.getDebugText ());
|
||||
// text.append (cell);
|
||||
// text.append ("\n");
|
||||
if (cell.isCellType (CellType.VALUE))
|
||||
{
|
||||
text.append (cell.getValue ());
|
||||
text.append ("\n");
|
||||
}
|
||||
|
||||
text.append ("\n");
|
||||
// text.append (AbstractValue.LINE + "\n");
|
||||
text.append (cell);
|
||||
if (cell.isCellType (CellType.VALUE))
|
||||
text.append (cell.getValue ());
|
||||
text.append (AbstractValue.LINE);
|
||||
|
||||
text.append ("\n\n");
|
||||
}
|
||||
|
||||
text.append ("\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user