mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-08-15 08:27:19 +00:00
debugging text
This commit is contained in:
@@ -4,9 +4,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class AbstractValue implements Value, Iterable<Value>
|
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 FMT4 = "| %-9.9s : %-49.49s %-8.8s %-10.10s|%n";
|
||||||
protected static final String FMT2 = "| %-9.9s : %-69.69s|%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 FMT5 = "| %-9.9s : %-3.3s : %-44.44s%-8.8s %-10.10s|%n";
|
||||||
protected static final String LINE =
|
protected static final String LINE =
|
||||||
@@ -64,6 +64,12 @@ public abstract class AbstractValue implements Value, Iterable<Value>
|
|||||||
return bool;
|
return bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size ()
|
||||||
|
{
|
||||||
|
return values.size ();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText ()
|
public String getText ()
|
||||||
{
|
{
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
class Cell implements Value, Comparable<Cell>
|
class Cell implements Value, Comparable<Cell>
|
||||||
{
|
{
|
||||||
private static final String line = "+----------------------------------------"
|
private static final String line = "+----------------------------------------"
|
||||||
@@ -20,7 +22,7 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
|
|
||||||
enum CellType
|
enum CellType
|
||||||
{
|
{
|
||||||
LABEL, REPEATING_CHARACTER, VALUE, EMPTY
|
LABEL, FILLER, VALUE, EMPTY
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cell (Sheet parent, Address address)
|
public Cell (Sheet parent, Address address)
|
||||||
@@ -105,7 +107,7 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
repeatingText = formatText.substring (2);
|
repeatingText = formatText.substring (2);
|
||||||
for (int i = 0; i < 20; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
repeat += repeatingText;
|
repeat += repeatingText;
|
||||||
cellType = CellType.REPEATING_CHARACTER;
|
cellType = CellType.FILLER;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +200,7 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
fmtChar = 'L';
|
fmtChar = 'L';
|
||||||
return Format.justify (label, colWidth, fmtChar);
|
return Format.justify (label, colWidth, fmtChar);
|
||||||
|
|
||||||
case REPEATING_CHARACTER:
|
case FILLER:
|
||||||
return Format.justify (repeat, colWidth, ' ');
|
return Format.justify (repeat, colWidth, ' ');
|
||||||
|
|
||||||
case EMPTY:
|
case EMPTY:
|
||||||
@@ -281,6 +283,18 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
return cellType == CellType.VALUE ? value.getBoolean () : false;
|
return cellType == CellType.VALUE ? value.getBoolean () : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size ()
|
||||||
|
{
|
||||||
|
return cellType == CellType.VALUE ? value.size () : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<Value> iterator ()
|
||||||
|
{
|
||||||
|
return cellType == CellType.VALUE ? value.iterator () : null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFullText ()
|
public String getFullText ()
|
||||||
{
|
{
|
||||||
@@ -288,7 +302,7 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
{
|
{
|
||||||
case LABEL:
|
case LABEL:
|
||||||
return "LBL : " + label;
|
return "LBL : " + label;
|
||||||
case REPEATING_CHARACTER:
|
case FILLER:
|
||||||
return "RPT : " + repeatingText;
|
return "RPT : " + repeatingText;
|
||||||
case EMPTY:
|
case EMPTY:
|
||||||
return "Empty Cell";
|
return "Empty Cell";
|
||||||
@@ -324,14 +338,16 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
public String toString ()
|
public String toString ()
|
||||||
{
|
{
|
||||||
String contents = "";
|
String contents = "";
|
||||||
|
String contents2 = "";
|
||||||
String valueText = "";
|
String valueText = "";
|
||||||
|
String line2 = "";
|
||||||
|
|
||||||
switch (cellType)
|
switch (cellType)
|
||||||
{
|
{
|
||||||
case LABEL:
|
case LABEL:
|
||||||
contents = label;
|
contents = label;
|
||||||
break;
|
break;
|
||||||
case REPEATING_CHARACTER:
|
case FILLER:
|
||||||
contents = repeatingText;
|
contents = repeatingText;
|
||||||
break;
|
break;
|
||||||
case EMPTY:
|
case EMPTY:
|
||||||
@@ -343,8 +359,14 @@ class Cell implements Value, Comparable<Cell>
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.format ("%s%n| %-9.9s : %-49.49s %-18.18s |%n", AbstractValue.LINE,
|
if (contents.length () > 49)
|
||||||
address.getText (), contents, cellType + valueText);
|
{
|
||||||
|
contents2 = contents.substring (49);
|
||||||
|
contents = contents.substring (0, 49);
|
||||||
|
line2 = String.format ("| %-69.69s|%n", contents2);
|
||||||
|
}
|
||||||
|
return String.format ("%s%n| %-9.9s : %-49.49s %-18.18s |%n%s", AbstractValue.LINE,
|
||||||
|
address.getText (), contents, cellType + valueText, line2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -125,11 +125,6 @@ class Expression extends AbstractValue //implements Iterable<Value>
|
|||||||
return values.size () == 1 && signs.get (0).equals ("(+)") ? values.get (0) : this;
|
return values.size () == 1 && signs.get (0).equals ("(+)") ? values.get (0) : this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int size ()
|
|
||||||
{
|
|
||||||
return values.size ();
|
|
||||||
}
|
|
||||||
|
|
||||||
Value get (int index)
|
Value get (int index)
|
||||||
{
|
{
|
||||||
if (index < 0 || index >= values.size ())
|
if (index < 0 || index >= values.size ())
|
||||||
|
@@ -80,15 +80,22 @@ class If extends Function
|
|||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
text.append (String.format ("%s%n", LINE));
|
text.append (String.format ("%s%n", LINE));
|
||||||
text.append (String.format (FMT4, "IF", fullText, valueType, getValueText (this)));
|
text.append (
|
||||||
|
String.format (FMT4, getType (), fullText, valueType, getValueText (this)));
|
||||||
text.append (String.format (FMT4, "condition", conditionText,
|
text.append (String.format (FMT4, "condition", conditionText,
|
||||||
condition.getValueType (), getValueText (condition)));
|
condition.getValueType (), getValueText (condition)));
|
||||||
if (condition.getBoolean ())
|
if (condition.getBoolean ())
|
||||||
text.append (String.format (FMT4, "true", textTrue, expTrue.getValueType (),
|
attach (text, "true", expTrue, textTrue);
|
||||||
getValueText (expTrue)));
|
|
||||||
else
|
else
|
||||||
text.append (String.format (FMT4, "false", textFalse, expFalse.getValueType (),
|
attach (text, "false", expFalse, textFalse);
|
||||||
getValueText (expFalse)));
|
|
||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void attach (StringBuilder text, String title, Value exp, String s)
|
||||||
|
{
|
||||||
|
text.append (String.format (FMT4, title, s, exp.getValueType (), getValueText (exp)));
|
||||||
|
if (exp.size () > 1)
|
||||||
|
for (Value value : exp)
|
||||||
|
text.append (value);
|
||||||
|
}
|
||||||
}
|
}
|
@@ -36,8 +36,8 @@ class Number extends AbstractValue
|
|||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
text.append (String.format ("%s%n", LINE));
|
text.append (String.format ("%s%n", LINE));
|
||||||
text.append (String.format (FMT5, cell.getAddressText (), "NUM", getFullText (),
|
text.append (
|
||||||
valueType, getValueText (this)));
|
String.format (FMT4, "Constant", getFullText (), valueType, getValueText (this)));
|
||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
package com.bytezone.diskbrowser.visicalc;
|
package com.bytezone.diskbrowser.visicalc;
|
||||||
|
|
||||||
interface Value
|
interface Value extends Iterable<Value>
|
||||||
{
|
{
|
||||||
enum ValueType
|
enum ValueType
|
||||||
{
|
{
|
||||||
@@ -29,4 +29,6 @@ interface Value
|
|||||||
public String getFullText (); // original text
|
public String getFullText (); // original text
|
||||||
|
|
||||||
public String getType (); // FUNCTION, CONDITION, EXPRESSION
|
public String getType (); // FUNCTION, CONDITION, EXPRESSION
|
||||||
|
|
||||||
|
public int size ();
|
||||||
}
|
}
|
Reference in New Issue
Block a user