method header lines

This commit is contained in:
Denis Molony 2020-02-08 17:50:03 +10:00
parent 09965c02aa
commit 4788f4bca4
14 changed files with 348 additions and 239 deletions

View File

@ -6,7 +6,9 @@ import java.util.List;
import com.bytezone.diskbrowser.applefile.AbstractFile; import com.bytezone.diskbrowser.applefile.AbstractFile;
import com.bytezone.diskbrowser.utilities.HexFormatter; import com.bytezone.diskbrowser.utilities.HexFormatter;
// -----------------------------------------------------------------------------------//
public class AppleworksADBFile extends AbstractFile public class AppleworksADBFile extends AbstractFile
// -----------------------------------------------------------------------------------//
{ {
static final String line = "-------------------------------------------------------" static final String line = "-------------------------------------------------------"
+ "-----------------------------------\n"; + "-----------------------------------\n";
@ -42,7 +44,9 @@ public class AppleworksADBFile extends AbstractFile
final List<Record> records = new ArrayList<> (); final List<Record> records = new ArrayList<> ();
private final Record standardRecord; private final Record standardRecord;
// ---------------------------------------------------------------------------------//
public AppleworksADBFile (String name, byte[] buffer) public AppleworksADBFile (String name, byte[] buffer)
// ---------------------------------------------------------------------------------//
{ {
super (name, buffer); super (name, buffer);
@ -125,8 +129,10 @@ public class AppleworksADBFile extends AbstractFile
} }
} }
// ---------------------------------------------------------------------------------//
@Override @Override
public String getText () public String getText ()
// ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
@ -179,7 +185,9 @@ public class AppleworksADBFile extends AbstractFile
return text.toString (); return text.toString ();
} }
// ---------------------------------------------------------------------------------//
private void removeTrailing (StringBuilder text, char c) private void removeTrailing (StringBuilder text, char c)
// ---------------------------------------------------------------------------------//
{ {
while (text.charAt (text.length () - 1) == c) while (text.charAt (text.length () - 1) == c)
text.deleteCharAt (text.length () - 1); text.deleteCharAt (text.length () - 1);

View File

@ -6,12 +6,16 @@ import java.util.List;
import com.bytezone.diskbrowser.applefile.AbstractFile; import com.bytezone.diskbrowser.applefile.AbstractFile;
import com.bytezone.diskbrowser.utilities.HexFormatter; import com.bytezone.diskbrowser.utilities.HexFormatter;
// -----------------------------------------------------------------------------------//
public class AppleworksSSFile extends AbstractFile public class AppleworksSSFile extends AbstractFile
// -----------------------------------------------------------------------------------//
{ {
Header header; Header header;
List<Row> rows = new ArrayList<> (); List<Row> rows = new ArrayList<> ();
// ---------------------------------------------------------------------------------//
public AppleworksSSFile (String name, byte[] buffer) public AppleworksSSFile (String name, byte[] buffer)
// ---------------------------------------------------------------------------------//
{ {
super (name, buffer); super (name, buffer);
@ -32,8 +36,10 @@ public class AppleworksSSFile extends AbstractFile
} }
} }
// ---------------------------------------------------------------------------------//
@Override @Override
public String getText () public String getText ()
// ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (header.toString ()); StringBuilder text = new StringBuilder (header.toString ());
@ -47,14 +53,18 @@ public class AppleworksSSFile extends AbstractFile
return text.toString (); return text.toString ();
} }
// ---------------------------------------------------------------------------------//
static String getCellName (int row, int column) static String getCellName (int row, int column)
// ---------------------------------------------------------------------------------//
{ {
char c1 = (char) ('A' + column / 26 - 1); char c1 = (char) ('A' + column / 26 - 1);
char c2 = (char) ('A' + column % 26); char c2 = (char) ('A' + column % 26);
return "" + (c1 == '@' ? "" : c1) + c2 + row; return "" + (c1 == '@' ? "" : c1) + c2 + row;
} }
// ---------------------------------------------------------------------------------//
private class Header private class Header
// ---------------------------------------------------------------------------------//
{ {
private final int[] columnWidths = new int[127]; private final int[] columnWidths = new int[127];
private final char calcOrder; private final char calcOrder;
@ -245,7 +255,9 @@ public class AppleworksSSFile extends AbstractFile
} }
} }
// ---------------------------------------------------------------------------------//
private class Row private class Row
// ---------------------------------------------------------------------------------//
{ {
private final int rowNumber; private final int rowNumber;
private final List<Cell> cells = new ArrayList<> (); private final List<Cell> cells = new ArrayList<> ();

View File

@ -2,19 +2,25 @@ package com.bytezone.diskbrowser.appleworks;
import com.bytezone.diskbrowser.applefile.AbstractFile; import com.bytezone.diskbrowser.applefile.AbstractFile;
// -----------------------------------------------------------------------------------//
public class AppleworksWPFile extends AbstractFile public class AppleworksWPFile extends AbstractFile
// -----------------------------------------------------------------------------------//
{ {
Header header; Header header;
// ---------------------------------------------------------------------------------//
public AppleworksWPFile (String name, byte[] buffer) public AppleworksWPFile (String name, byte[] buffer)
// ---------------------------------------------------------------------------------//
{ {
super (name, buffer); super (name, buffer);
header = new Header (); header = new Header ();
} }
// ---------------------------------------------------------------------------------//
@Override @Override
public String getText () public String getText ()
// ---------------------------------------------------------------------------------//
{ {
int leftMargin = header.leftMargin; int leftMargin = header.leftMargin;
int rightMargin; int rightMargin;
@ -31,7 +37,6 @@ public class AppleworksWPFile extends AbstractFile
{ {
int b1 = buffer[ptr] & 0xFF; int b1 = buffer[ptr] & 0xFF;
int b2 = buffer[ptr + 1] & 0xFF; int b2 = buffer[ptr + 1] & 0xFF;
// System.out.printf ("%02X%02X %n", (buffer[ptr] & 0xFF), (buffer[ptr + 1] & 0xFF));
if (b1 == 0xFF && b2 == 0xFF) if (b1 == 0xFF && b2 == 0xFF)
break; break;
@ -144,7 +149,9 @@ public class AppleworksWPFile extends AbstractFile
return text.toString (); return text.toString ();
} }
// ---------------------------------------------------------------------------------//
private class Header private class Header
// ---------------------------------------------------------------------------------//
{ {
private final char[] tabStops = new char[80]; private final char[] tabStops = new char[80];
private final String tabs; private final String tabs;

View File

@ -1,6 +1,8 @@
package com.bytezone.diskbrowser.appleworks; package com.bytezone.diskbrowser.appleworks;
// -----------------------------------------------------------------------------------//
class Cell class Cell
// -----------------------------------------------------------------------------------//
{ {
final String cellName; final String cellName;
final int row; final int row;
@ -8,14 +10,18 @@ class Cell
String value; String value;
String type; String type;
// ---------------------------------------------------------------------------------//
static String getCellName (int row, int column) static String getCellName (int row, int column)
// ---------------------------------------------------------------------------------//
{ {
char c1 = (char) ('A' + column / 26 - 1); char c1 = (char) ('A' + column / 26 - 1);
char c2 = (char) ('A' + column % 26); char c2 = (char) ('A' + column % 26);
return "" + (c1 == '@' ? "" : c1) + c2 + row; return "" + (c1 == '@' ? "" : c1) + c2 + row;
} }
// ---------------------------------------------------------------------------------//
public Cell (int row, int column, int offset, int length) public Cell (int row, int column, int offset, int length)
// ---------------------------------------------------------------------------------//
{ {
this.row = row; this.row = row;
this.column = column; this.column = column;
@ -23,8 +29,10 @@ class Cell
cellName = getCellName (row, column); cellName = getCellName (row, column);
} }
// ---------------------------------------------------------------------------------//
@Override @Override
public String toString () public String toString ()
// ---------------------------------------------------------------------------------//
{ {
return String.format ("%5s : %s %s%n", cellName, type, value); return String.format ("%5s : %s %s%n", cellName, type, value);
} }

View File

@ -2,19 +2,25 @@ package com.bytezone.diskbrowser.appleworks;
import com.bytezone.diskbrowser.utilities.HexFormatter; import com.bytezone.diskbrowser.utilities.HexFormatter;
public class CellAddress // -----------------------------------------------------------------------------------//
class CellAddress
// -----------------------------------------------------------------------------------//
{ {
int colRef; int colRef;
int rowRef; int rowRef;
public CellAddress (byte[] buffer, int offset) // ---------------------------------------------------------------------------------//
CellAddress (byte[] buffer, int offset)
// ---------------------------------------------------------------------------------//
{ {
colRef = buffer[offset]; colRef = buffer[offset];
rowRef = HexFormatter.intValue (buffer[offset + 1], buffer[offset + 2]); rowRef = HexFormatter.intValue (buffer[offset + 1], buffer[offset + 2]);
} }
// ---------------------------------------------------------------------------------//
@Override @Override
public String toString () public String toString ()
// ---------------------------------------------------------------------------------//
{ {
return String.format ("[Row=%04d, Col=%04d]", rowRef, colRef); return String.format ("[Row=%04d, Col=%04d]", rowRef, colRef);
} }

View File

@ -2,12 +2,16 @@ package com.bytezone.diskbrowser.appleworks;
import com.bytezone.diskbrowser.utilities.HexFormatter; import com.bytezone.diskbrowser.utilities.HexFormatter;
public class CellConstant extends Cell // -----------------------------------------------------------------------------------//
class CellConstant extends Cell
// -----------------------------------------------------------------------------------//
{ {
double saneDouble; double saneDouble;
CellFormat format; CellFormat format;
public CellConstant (byte[] buffer, int row, int column, int offset, int length) // ---------------------------------------------------------------------------------//
CellConstant (byte[] buffer, int row, int column, int offset, int length)
// ---------------------------------------------------------------------------------//
{ {
super (row, column, offset, length); super (row, column, offset, length);

View File

@ -1,6 +1,8 @@
package com.bytezone.diskbrowser.appleworks; package com.bytezone.diskbrowser.appleworks;
public class CellFormat // -----------------------------------------------------------------------------------//
class CellFormat
// -----------------------------------------------------------------------------------//
{ {
boolean labelAllowed; boolean labelAllowed;
boolean valueAllowed; boolean valueAllowed;
@ -13,7 +15,9 @@ public class CellFormat
boolean appropriate; boolean appropriate;
int decimals; int decimals;
public CellFormat (byte format) // ---------------------------------------------------------------------------------//
CellFormat (byte format)
// ---------------------------------------------------------------------------------//
{ {
display = (format & 0x40) == 0; display = (format & 0x40) == 0;
labelAllowed = (format & 0x10) == 0; labelAllowed = (format & 0x10) == 0;
@ -29,13 +33,17 @@ public class CellFormat
appropriate = formatting == 6; appropriate = formatting == 6;
} }
public CellFormat (byte format, byte decimals) // ---------------------------------------------------------------------------------//
CellFormat (byte format, byte decimals)
// ---------------------------------------------------------------------------------//
{ {
this (format); this (format);
this.decimals = decimals & 0x07; this.decimals = decimals & 0x07;
} }
public String mask () // ---------------------------------------------------------------------------------//
String mask ()
// ---------------------------------------------------------------------------------//
{ {
String fmt = dollars ? "$%" : "%"; String fmt = dollars ? "$%" : "%";
if (commas) if (commas)

View File

@ -2,18 +2,22 @@ package com.bytezone.diskbrowser.appleworks;
import com.bytezone.diskbrowser.utilities.HexFormatter; import com.bytezone.diskbrowser.utilities.HexFormatter;
public class CellFormula // -----------------------------------------------------------------------------------//
class CellFormula
// -----------------------------------------------------------------------------------//
{ {
private static String[] tokens = {// private static String[] tokens =
"@Deg", "@Rad", "@Pi", "@True", "@False", "@Not", "@IsBlank", "@IsNA", "@IsError", { "@Deg", "@Rad", "@Pi", "@True", "@False", "@Not", "@IsBlank", "@IsNA", "@IsError",
"@Exp", "@Ln", "@Log", "@Cos", "@Sin", "@Tan", "@ACos", "@ASin", "@ATan2", "@Exp", "@Ln", "@Log", "@Cos", "@Sin", "@Tan", "@ACos", "@ASin", "@ATan2",
"@ATan", "@Mod", "@FV", "@PV", "@PMT", "@Term", "@Rate", "@Round", "@Or", "@And", "@ATan", "@Mod", "@FV", "@PV", "@PMT", "@Term", "@Rate", "@Round", "@Or", "@And",
"@Sum", "@Avg", "@Choose", "@Count", "@Error", "@IRR", "@If", "@Int", "@Lookup", "@Sum", "@Avg", "@Choose", "@Count", "@Error", "@IRR", "@If", "@Int", "@Lookup",
"@Max", "@Min", "@NA", "@NPV", "@Sqrt", "@Abs", "", "<>", ">=", "<=", "=", ">", "@Max", "@Min", "@NA", "@NPV", "@Sqrt", "@Abs", "", "<>", ">=", "<=", "=", ">",
"<", ",", "^", ")", "-", "+", "/", "*", "(", "-", "+", "..." }; "<", ",", "^", ")", "-", "+", "/", "*", "(", "-", "+", "..." };
String value; String value;
public CellFormula (Cell cell, byte[] buffer, int offset, int length) // ---------------------------------------------------------------------------------//
CellFormula (Cell cell, byte[] buffer, int offset, int length)
// ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
@ -42,7 +46,7 @@ public class CellFormula
{ {
CellAddress address = new CellAddress (buffer, offset + i + 1); CellAddress address = new CellAddress (buffer, offset + i + 1);
String cellName = String cellName =
Cell.getCellName (cell.row + address.rowRef, cell.column + address.colRef); Cell.getCellName (cell.row + address.rowRef, cell.column + address.colRef);
i += 3; i += 3;
text.append (cellName); text.append (cellName);
} }

View File

@ -2,12 +2,16 @@ package com.bytezone.diskbrowser.appleworks;
import com.bytezone.diskbrowser.utilities.HexFormatter; import com.bytezone.diskbrowser.utilities.HexFormatter;
public class CellLabel extends Cell // -----------------------------------------------------------------------------------//
class CellLabel extends Cell
// -----------------------------------------------------------------------------------//
{ {
boolean propagated; boolean propagated;
String label; String label;
public CellLabel (byte[] buffer, int row, int column, int offset, int length) // ---------------------------------------------------------------------------------//
CellLabel (byte[] buffer, int row, int column, int offset, int length)
// ---------------------------------------------------------------------------------//
{ {
super (row, column, offset, length); super (row, column, offset, length);

View File

@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.appleworks;
import com.bytezone.diskbrowser.utilities.HexFormatter; import com.bytezone.diskbrowser.utilities.HexFormatter;
public class CellValue extends Cell // -----------------------------------------------------------------------------------//
class CellValue extends Cell
// -----------------------------------------------------------------------------------//
{ {
CellFormat format; CellFormat format;
CellFormula formula; CellFormula formula;
@ -10,7 +12,9 @@ public class CellValue extends Cell
boolean lastEvalError; boolean lastEvalError;
double saneDouble; double saneDouble;
public CellValue (byte[] buffer, int row, int column, int offset, int length) // ---------------------------------------------------------------------------------//
CellValue (byte[] buffer, int row, int column, int offset, int length)
// ---------------------------------------------------------------------------------//
{ {
super (row, column, offset, length); super (row, column, offset, length);

View File

@ -1,15 +1,20 @@
package com.bytezone.diskbrowser.appleworks; package com.bytezone.diskbrowser.appleworks;
// -----------------------------------------------------------------------------------//
class LabelReport extends Report class LabelReport extends Report
// -----------------------------------------------------------------------------------//
{ {
// ---------------------------------------------------------------------------------//
public LabelReport (AppleworksADBFile parent, byte[] buffer, int offset) LabelReport (AppleworksADBFile parent, byte[] buffer, int offset)
// ---------------------------------------------------------------------------------//
{ {
super (parent, buffer, offset); super (parent, buffer, offset);
} }
// ---------------------------------------------------------------------------------//
@Override @Override
public String getText () public String getText ()
// ---------------------------------------------------------------------------------//
{ {
return "Skipping vertical report\n"; return "Skipping vertical report\n";
} }

View File

@ -7,14 +7,18 @@ import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
// -----------------------------------------------------------------------------------//
class Record class Record
// -----------------------------------------------------------------------------------//
{ {
AppleworksADBFile parent; AppleworksADBFile parent;
int length; int length;
List<String> items = new ArrayList<> (); List<String> items = new ArrayList<> ();
Map<Integer, Double> calculatedItems = new HashMap<Integer, Double> ();// move to TableReport Map<Integer, Double> calculatedItems = new HashMap<> (); // move to TableReport
public Record (AppleworksADBFile parent, byte[] buffer, int ptr) // ---------------------------------------------------------------------------------//
Record (AppleworksADBFile parent, byte[] buffer, int ptr)
// ---------------------------------------------------------------------------------//
{ {
this.parent = parent; this.parent = parent;
int count; int count;
@ -55,16 +59,20 @@ class Record
items.add (""); items.add ("");
} }
public String getItem (int index) // ---------------------------------------------------------------------------------//
String getItem (int index)
// ---------------------------------------------------------------------------------//
{ {
return items.get (index); return items.get (index);
} }
public double calculateItem (int pos, int name, String condition) // ---------------------------------------------------------------------------------//
double calculateItem (int pos, int name, String condition)
// ---------------------------------------------------------------------------------//
{ {
try try
{ {
// System.out.printf ("%nCalculating %d (%s): %s%n", pos, (char) name, condition); // System.out.printf ("%nCalculating %d (%s): %s%n", pos, (char) name, condition);
Pattern p = Pattern.compile ("([A-Za-z]{1,2})(([-+*/]([A-Za-z]{1,2}|[0-9]))*)"); Pattern p = Pattern.compile ("([A-Za-z]{1,2})(([-+*/]([A-Za-z]{1,2}|[0-9]))*)");
Matcher m = p.matcher (condition); Matcher m = p.matcher (condition);
if (m.matches ()) if (m.matches ())
@ -112,7 +120,9 @@ class Record
return 0.0; return 0.0;
} }
// ---------------------------------------------------------------------------------//
private String valueOf (int field) private String valueOf (int field)
// ---------------------------------------------------------------------------------//
{ {
int itemNo = field - 'A'; int itemNo = field - 'A';
@ -138,12 +148,16 @@ class Record
return "0.0"; return "0.0";
} }
public String getReportLine (String format) // ---------------------------------------------------------------------------------//
String getReportLine (String format)
// ---------------------------------------------------------------------------------//
{ {
return String.format (format, (Object[]) items.toArray (new String[items.size ()])); return String.format (format, (Object[]) items.toArray (new String[items.size ()]));
} }
public String getReportLine () // ---------------------------------------------------------------------------------//
String getReportLine ()
// ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
String format = String.format ("%%-%ds : %%s%%n", parent.maxCategoryName); String format = String.format ("%%-%ds : %%s%%n", parent.maxCategoryName);
@ -163,8 +177,10 @@ class Record
return text.toString (); return text.toString ();
} }
// ---------------------------------------------------------------------------------//
@Override @Override
public String toString () public String toString ()
// ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
String format = "%-" + parent.maxCategoryName + "s [%s]%n"; String format = "%-" + parent.maxCategoryName + "s [%s]%n";

View File

@ -2,7 +2,9 @@ package com.bytezone.diskbrowser.appleworks;
import com.bytezone.diskbrowser.utilities.HexFormatter; import com.bytezone.diskbrowser.utilities.HexFormatter;
// -----------------------------------------------------------------------------------//
abstract class Report abstract class Report
// -----------------------------------------------------------------------------------//
{ {
static final String line = "-------------------------------------------------------" static final String line = "-------------------------------------------------------"
+ "-----------------------------------\n"; + "-----------------------------------\n";
@ -37,7 +39,9 @@ abstract class Report
private final boolean printDash; private final boolean printDash;
private String fudgeReason; private String fudgeReason;
public Report (AppleworksADBFile parent, byte[] buffer, int offset) // ---------------------------------------------------------------------------------//
Report (AppleworksADBFile parent, byte[] buffer, int offset)
// ---------------------------------------------------------------------------------//
{ {
this.parent = parent; this.parent = parent;
@ -126,24 +130,32 @@ abstract class Report
if (buffer[offset + 480 + fudge] == 0) // test high byte if (buffer[offset + 480 + fudge] == 0) // test high byte
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
selectionRules[i] = HexFormatter.unsignedShort (buffer, offset + 479 + i * 2 + fudge); selectionRules[i] =
HexFormatter.unsignedShort (buffer, offset + 479 + i * 2 + fudge);
testTypes[i] = HexFormatter.unsignedShort (buffer, offset + 485 + i * 2 + fudge); testTypes[i] = HexFormatter.unsignedShort (buffer, offset + 485 + i * 2 + fudge);
continuation[i] = HexFormatter.unsignedShort (buffer, offset + 491 + i * 2 + fudge); continuation[i] =
HexFormatter.unsignedShort (buffer, offset + 491 + i * 2 + fudge);
comparison[i] = pascalString (buffer, offset + 497 + i * 32 + fudge); comparison[i] = pascalString (buffer, offset + 497 + i * 32 + fudge);
} }
else else
System.out.println ("*** Invalid value in report rules ***"); System.out.println ("*** Invalid value in report rules ***");
} }
public abstract String getText (); // ---------------------------------------------------------------------------------//
abstract String getText ();
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------//
protected String pascalString (byte[] buffer, int ptr) protected String pascalString (byte[] buffer, int ptr)
// ---------------------------------------------------------------------------------//
{ {
return new String (buffer, ptr + 1, buffer[ptr] & 0xFF); return new String (buffer, ptr + 1, buffer[ptr] & 0xFF);
} }
// ---------------------------------------------------------------------------------//
@Override @Override
public String toString () public String toString ()
// ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();

View File

@ -1,6 +1,8 @@
package com.bytezone.diskbrowser.appleworks; package com.bytezone.diskbrowser.appleworks;
// -----------------------------------------------------------------------------------//
class TableReport extends Report class TableReport extends Report
// -----------------------------------------------------------------------------------//
{ {
private final int[] columnWidths = new int[33]; private final int[] columnWidths = new int[33];
private final int[] spaces = new int[33]; private final int[] spaces = new int[33];
@ -15,7 +17,9 @@ class TableReport extends Report
private final int groupTotalColumn; private final int groupTotalColumn;
private final boolean printGroupTotals; private final boolean printGroupTotals;
public TableReport (AppleworksADBFile parent, byte[] buffer, int offset) // ---------------------------------------------------------------------------------//
TableReport (AppleworksADBFile parent, byte[] buffer, int offset)
// ---------------------------------------------------------------------------------//
{ {
super (parent, buffer, offset); super (parent, buffer, offset);
@ -39,8 +43,10 @@ class TableReport extends Report
printGroupTotals = buffer[offset + 217] != 0; printGroupTotals = buffer[offset + 217] != 0;
} }
// ---------------------------------------------------------------------------------//
@Override @Override
public String getText () public String getText ()
// ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
@ -69,7 +75,8 @@ class TableReport extends Report
categoryName = categoryName.substring (0, columnWidths[i]); categoryName = categoryName.substring (0, columnWidths[i]);
header.append (categoryName); header.append (categoryName);
header.append (gap.substring (0, columnWidths[i] + spaces[i] - categoryName.length ())); header.append (
gap.substring (0, columnWidths[i] + spaces[i] - categoryName.length ()));
underline.append (line.substring (0, columnWidths[i])); underline.append (line.substring (0, columnWidths[i]));
underline.append (gap.substring (0, spaces[i])); underline.append (gap.substring (0, spaces[i]));
} }
@ -98,8 +105,8 @@ class TableReport extends Report
String cond = calculatedRules[calcField]; String cond = calculatedRules[calcField];
int col = calculatedColumn[calcField] - 1; int col = calculatedColumn[calcField] - 1;
String format = "%12." + justification[col] + "f"; String format = "%12." + justification[col] + "f";
item = item = String.format (format, record.calculateItem (calcField, i + 97, cond))
String.format (format, record.calculateItem (calcField, i + 97, cond)).trim (); .trim ();
// System.out.println (item); // System.out.println (item);
} }
@ -178,19 +185,23 @@ class TableReport extends Report
return text.toString (); return text.toString ();
} }
// ---------------------------------------------------------------------------------//
private StringBuilder trimRight (StringBuilder text) private StringBuilder trimRight (StringBuilder text)
// ---------------------------------------------------------------------------------//
{ {
while (text.length () > 0 && text.charAt (text.length () - 1) == ' ') while (text.length () > 0 && text.charAt (text.length () - 1) == ' ')
text.deleteCharAt (text.length () - 1); text.deleteCharAt (text.length () - 1);
return text; return text;
} }
// ---------------------------------------------------------------------------------//
@Override @Override
public String toString () public String toString ()
// ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (super.toString ()); StringBuilder text = new StringBuilder (super.toString ());
text.append (String.format ("Calculated ......... %d %d %d%n", calculatedColumn[0], text.append (String.format ("Calculated ......... %d %d %d%n", calculatedColumn[0],
calculatedColumn[1], calculatedColumn[2])); calculatedColumn[1], calculatedColumn[2]));
text.append (String.format ("Group total ........ %d%n", groupTotalColumn)); text.append (String.format ("Group total ........ %d%n", groupTotalColumn));
text.append (String.format ("Print gr totals .... %s%n", printGroupTotals)); text.append (String.format ("Print gr totals .... %s%n", printGroupTotals));
text.append (String.format ("Calc category1 ..... %s%n", calculatedCategory[0])); text.append (String.format ("Calc category1 ..... %s%n", calculatedCategory[0]));
@ -202,9 +213,9 @@ class TableReport extends Report
text.append (String.format ("%n Width Space Name Foot Just%n")); text.append (String.format ("%n Width Space Name Foot Just%n"));
for (int i = 0; i < categoriesOnThisReport; i++) for (int i = 0; i < categoriesOnThisReport; i++)
text.append (String.format (" %2d %2d %02X %02X %02X %n", columnWidths[i], text.append (
spaces[i], reportCategoryNames[i], footTotals[i], String.format (" %2d %2d %02X %02X %02X %n", columnWidths[i],
justification[i])); spaces[i], reportCategoryNames[i], footTotals[i], justification[i]));
return text.toString (); return text.toString ();
} }