refactoring of new formatters

This commit is contained in:
hneemann 2021-01-24 09:21:25 +01:00
parent 71551ad174
commit d0c79c983b
30 changed files with 175 additions and 222 deletions

View File

@ -7,9 +7,6 @@ package de.neemann.digital.core;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.valueFormatter.*;
import static de.neemann.digital.core.valueFormatter.ValueFormatterDefault.DIGITS;
/**
* The available number formats
@ -102,6 +99,122 @@ public enum IntFormat {
ValueFormatter create(ElementAttributes attributes);
}
/**
* The default formatter
*/
public static final ValueFormatter DEFAULT_FORMATTER = ValueFormatterDefault.INSTANCE;
/**
* The hexadecimal formatter
*/
public static final ValueFormatter HEX_FORMATTER = ValueFormatterHex.INSTANCE;
private static final char[] DIGITS = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
/**
* The default value formatter
*/
private static final class ValueFormatterDefault implements ValueFormatter {
private static final ValueFormatter INSTANCE = new ValueFormatterDefault();
@Override
public String formatToView(Value inValue) {
if (inValue.isHighZ())
return inValue.toString();
else
return toShortHex(inValue.getValue(), false);
}
@Override
public String formatToEdit(Value inValue) {
if (inValue.isHighZ())
return "Z";
final long value = inValue.getValue();
if (value >= 0 && value < 10)
return Long.toString(value);
else
return "0x" + toShortHex(value, true);
}
@Override
public int strLen(int bits) {
return (bits - 1) / 4 + 3;
}
@Override
public boolean isSuitedForAddresses() {
return false; // difficult to read in a table
}
}
/**
* the hexadecimal formatter
*/
private static final class ValueFormatterHex extends ValueFormatterViewEdit {
private static final ValueFormatterHex INSTANCE = new ValueFormatterHex();
private ValueFormatterHex() {
super(true);
}
@Override
protected String format(Value inValue) {
final int bits = inValue.getBits();
final int numChars = (bits - 1) / 4 + 1;
StringBuilder sb = new StringBuilder("0x");
final long value = inValue.getValue();
for (int i = numChars - 1; i >= 0; i--) {
int c = (int) ((value >> (i * 4)) & 0xf);
sb.append(DIGITS[c]);
}
return sb.toString();
}
@Override
public int strLen(int bits) {
return (bits - 1) / 4 + 3;
}
}
/**
* Creates a short hex representation of the given value.
* Use only to represent a value.
* If confusion is excluded, the prefix '0x' is omitted.
* Thus 0x1A3 is converted to "1A3" which can not be parsed back to a long because "0x" is missing.
*
* @param value the value
* @return the hex string
*/
public static String toShortHex(long value) {
return toShortHex(value, false);
}
private static final int BUF = 16;
private static String toShortHex(long value, boolean omitPrefix) {
if (value == 0)
return "0";
boolean wasChar = false;
int p = BUF;
char[] data = new char[BUF];
while (value != 0) {
final int d = (int) (value & 0xf);
if (d >= 10) wasChar = true;
p--;
data[p] = DIGITS[d];
value >>>= 4;
}
if (omitPrefix || wasChar || p == BUF - 1)
return new String(data, p, BUF - p);
else
return "0x" + new String(data, p, BUF - p);
}
/**
* the octal formatter
*/
@ -137,7 +250,7 @@ public enum IntFormat {
private static final class ValueFormatterBinary extends ValueFormatterViewEdit {
private ValueFormatterBinary() {
super(false); // becomes to large
super(false); // column becomes to wide
}
@Override
@ -237,7 +350,7 @@ public enum IntFormat {
/**
* Creates a new generic instance
*
* @param attr the definig elements attributes
* @param attr the defining elements attributes
* @param signed signed
*/
private ValueFormatterFixedPoint(ElementAttributes attr, boolean signed) {
@ -298,7 +411,7 @@ public enum IntFormat {
case 64:
return Double.toString(Double.longBitsToDouble(inValue.getValue()));
default:
return ValueFormatterHex.INSTANCE.formatToView(inValue);
return HEX_FORMATTER.formatToView(inValue);
}
}
@ -313,7 +426,7 @@ public enum IntFormat {
case 64:
return Double.longBitsToDouble(inValue.getValue()) + "d";
default:
return ValueFormatterHex.INSTANCE.formatToEdit(inValue);
return HEX_FORMATTER.formatToEdit(inValue);
}
}
@ -325,7 +438,7 @@ public enum IntFormat {
case 64:
return SIZE64;
default:
return ValueFormatterHex.INSTANCE.strLen(bits);
return HEX_FORMATTER.strLen(bits);
}
}

View File

@ -7,7 +7,6 @@ package de.neemann.digital.core;
import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.PinDescription;
import de.neemann.digital.core.valueFormatter.ValueFormatterDefault;
import de.neemann.digital.lang.Lang;
import java.util.Random;
@ -173,7 +172,7 @@ public class ObservableValue extends Observable implements PinDescription {
return zMaskString(value, highZ, bits);
}
else {
return ValueFormatterDefault.toShortHex(value);
return IntFormat.toShortHex(value);
}
}

View File

@ -5,9 +5,6 @@
*/
package de.neemann.digital.core;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.valueFormatter.ValueFormatterDefault;
/**
* A simple storage bean for signals
*/
@ -15,7 +12,7 @@ public final class Signal implements Comparable<Signal> {
private final String name;
private final ObservableValue value;
private final Setter setter;
private ValueFormatter format = ValueFormatterDefault.INSTANCE;
private ValueFormatter format = IntFormat.DEFAULT_FORMATTER;
private String pinNumber;
private ObservableValue bidirectionalReader;
private boolean showInGraph;

View File

@ -6,7 +6,6 @@
package de.neemann.digital.core;
import de.neemann.digital.core.io.InValue;
import de.neemann.digital.core.valueFormatter.ValueFormatterDefault;
import static de.neemann.digital.core.ObservableValue.zMaskString;
@ -119,7 +118,7 @@ public class Value {
return zMaskString(value, highZ, bits);
}
else {
return ValueFormatterDefault.toShortHex(value);
return IntFormat.toShortHex(value);
}
}

View File

@ -3,10 +3,7 @@
* Use of this source code is governed by the GPL v3 license
* that can be found in the LICENSE file.
*/
package de.neemann.digital.core.valueFormatter;
import de.neemann.digital.core.Bits;
import de.neemann.digital.core.Value;
package de.neemann.digital.core;
/**
* Used to format a Value

View File

@ -3,9 +3,7 @@
* Use of this source code is governed by the GPL v3 license
* that can be found in the LICENSE file.
*/
package de.neemann.digital.core.valueFormatter;
import de.neemann.digital.core.Value;
package de.neemann.digital.core;
/**
* Base class of all formatters where the string to edit and the string to display are the same.
@ -15,9 +13,9 @@ public abstract class ValueFormatterViewEdit implements ValueFormatter {
private final boolean suitedForAddresses;
/**
* Constructor to configure class
* Constructor to configure the instance
*
* @param suitedForAddresses tru if formatter is suited to be used for addresses
* @param suitedForAddresses true if formatter is suited to be used for addresses
* @see ValueFormatter#isSuitedForAddresses()
*/
public ValueFormatterViewEdit(boolean suitedForAddresses) {

View File

@ -5,7 +5,7 @@
*/
package de.neemann.digital.core.element;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.ValueFormatter;
import de.neemann.digital.hdl.hgs.HGSMap;
import java.io.File;

View File

@ -10,7 +10,7 @@ import de.neemann.digital.core.element.Element;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.ValueFormatter;
import de.neemann.digital.lang.Lang;
/**

View File

@ -7,7 +7,7 @@ package de.neemann.digital.core.io;
import de.neemann.digital.core.*;
import de.neemann.digital.core.element.*;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.ValueFormatter;
import de.neemann.digital.lang.Lang;
import static de.neemann.digital.core.element.PinInfo.input;

View File

@ -10,7 +10,7 @@ import de.neemann.digital.core.element.Element;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.ValueFormatter;
import static de.neemann.digital.core.element.PinInfo.input;

View File

@ -11,7 +11,7 @@ import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.memory.rom.ROMInterface;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.ValueFormatter;
import de.neemann.digital.draw.elements.VisualElement;
import de.neemann.digital.gui.components.CircuitModifier;
import de.neemann.digital.gui.components.modification.ModifyAttribute;

View File

@ -10,7 +10,7 @@ import de.neemann.digital.core.element.Element;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.ValueFormatter;
import static de.neemann.digital.core.element.PinInfo.input;

View File

@ -5,9 +5,9 @@
*/
package de.neemann.digital.core.memory;
import de.neemann.digital.core.IntFormat;
import de.neemann.digital.core.stats.Countable;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.valueFormatter.ValueFormatterHex;
import de.neemann.digital.core.ValueFormatter;
/**
* Interface to get access to the rams data.
@ -32,6 +32,6 @@ public interface RAMInterface extends ProgramMemory, Countable {
* @return the integer format to be used to visualize the values
*/
default ValueFormatter getValueFormatter() {
return ValueFormatterHex.INSTANCE;
return IntFormat.HEX_FORMATTER;
}
}

View File

@ -12,7 +12,7 @@ import de.neemann.digital.core.element.ElementTypeDescription;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.memory.importer.Importer;
import de.neemann.digital.core.memory.rom.ROMInterface;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.ValueFormatter;
import de.neemann.digital.lang.Lang;
import java.io.File;

View File

@ -7,7 +7,7 @@ package de.neemann.digital.core.memory.rom;
import de.neemann.digital.core.memory.DataField;
import de.neemann.digital.core.stats.Countable;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.ValueFormatter;
/**
* Interface implemented by al ROM or EEPROM components

View File

@ -1,93 +0,0 @@
/*
* Copyright (c) 2021 Helmut Neemann.
* Use of this source code is governed by the GPL v3 license
* that can be found in the LICENSE file.
*/
package de.neemann.digital.core.valueFormatter;
import de.neemann.digital.core.Value;
/**
* The default value formatter
*/
public final class ValueFormatterDefault implements ValueFormatter {
/**
* hex digits
*/
public static final char[] DIGITS = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
/**
* the singleton instance
*/
public static final ValueFormatter INSTANCE = new ValueFormatterDefault();
private ValueFormatterDefault() {
}
@Override
public String formatToView(Value inValue) {
if (inValue.isHighZ())
return inValue.toString();
else
return toShortHex(inValue.getValue(), false);
}
@Override
public String formatToEdit(Value inValue) {
if (inValue.isHighZ())
return "Z";
final long value = inValue.getValue();
if (value >= 0 && value < 10)
return Long.toString(value);
else
return "0x" + toShortHex(value, true);
}
@Override
public int strLen(int bits) {
return (bits - 1) / 4 + 3;
}
@Override
public boolean isSuitedForAddresses() {
return false;
}
/**
* Creates a short hex representation of the given value.
* Use only to represent a value.
* If confusion is excluded, the prefix '0x' is omitted.
* Thus 0x1A3 is converted to "1A3" which can not be parsed back to a long because "0x" is missing.
*
* @param value the value
* @return the hex string
*/
public static String toShortHex(long value) {
return toShortHex(value, false);
}
private static final int BUF = 16;
static String toShortHex(long value, boolean omitPrefix) {
if (value == 0)
return "0";
boolean wasChar = false;
int p = BUF;
char[] data = new char[BUF];
while (value != 0) {
final int d = (int) (value & 0xf);
if (d >= 10) wasChar = true;
p--;
data[p] = DIGITS[d];
value >>>= 4;
}
if (omitPrefix || wasChar || p == BUF - 1)
return new String(data, p, BUF - p);
else
return "0x" + new String(data, p, BUF - p);
}
}

View File

@ -1,42 +0,0 @@
/*
* Copyright (c) 2021 Helmut Neemann.
* Use of this source code is governed by the GPL v3 license
* that can be found in the LICENSE file.
*/
package de.neemann.digital.core.valueFormatter;
import de.neemann.digital.core.Value;
/**
* the hexadecimal formatter
*/
public final class ValueFormatterHex extends ValueFormatterViewEdit {
/**
* the singleton instance
*/
public static final ValueFormatterHex INSTANCE = new ValueFormatterHex();
private ValueFormatterHex() {
super(true);
}
@Override
protected String format(Value inValue) {
final int bits = inValue.getBits();
final int numChars = (bits - 1) / 4 + 1;
StringBuilder sb = new StringBuilder("0x");
final long value = inValue.getValue();
for (int i = numChars - 1; i >= 0; i--) {
int c = (int) ((value >> (i * 4)) & 0xf);
sb.append(ValueFormatterDefault.DIGITS[c]);
}
return sb.toString();
}
@Override
public int strLen(int bits) {
return (bits - 1) / 4 + 3;
}
}

View File

@ -1,9 +0,0 @@
/*
* Copyright (c) 2021 Helmut Neemann.
* Use of this source code is governed by the GPL v3 license
* that can be found in the LICENSE file.
*/
/**
* Classes to format values
*/
package de.neemann.digital.core.valueFormatter;

View File

@ -5,8 +5,8 @@
*/
package de.neemann.digital.data;
import de.neemann.digital.core.IntFormat;
import de.neemann.digital.core.SyncAccess;
import de.neemann.digital.core.valueFormatter.ValueFormatterDefault;
import de.neemann.digital.draw.graphics.Graphic;
import de.neemann.digital.draw.graphics.Orientation;
import de.neemann.digital.draw.graphics.Style;
@ -182,7 +182,7 @@ public class DataPlotter implements Drawable {
last[i].hasChanged = true;
if (width > 4 && last[i].textWidth == 0 && last[i].hasChanged) {
final String text = ValueFormatterDefault.toShortHex(value);
final String text = IntFormat.toShortHex(value);
last[i].textWidth = text.length() * SIZE / 2;
if (ry > CENTER)
g.drawText(new Vector(x1 + 1, y - SEP2 + 1), text, Orientation.LEFTTOP, Style.SHAPE_PIN);

View File

@ -6,8 +6,8 @@
package de.neemann.digital.data;
import de.neemann.digital.core.Bits;
import de.neemann.digital.core.IntFormat;
import de.neemann.digital.core.ObservableValue;
import de.neemann.digital.core.valueFormatter.ValueFormatterDefault;
/**
* A single value to test
@ -176,7 +176,7 @@ public class Value {
case CLOCK:
return "C";
default:
return ValueFormatterDefault.toShortHex(value);
return IntFormat.toShortHex(value);
}
}

View File

@ -7,9 +7,7 @@ package de.neemann.digital.data;
import de.neemann.digital.core.IntFormat;
import de.neemann.digital.core.Observable;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.valueFormatter.ValueFormatterDefault;
import de.neemann.digital.core.valueFormatter.ValueFormatterHex;
import de.neemann.digital.core.ValueFormatter;
import de.neemann.digital.testing.parser.TestRow;
import java.io.*;
@ -319,9 +317,9 @@ public class ValueTable extends Observable implements Iterable<TestRow> {
*/
public ColumnInfo(ValueFormatter format, int bits) {
if (format == null)
format = ValueFormatterDefault.INSTANCE;
if (format.equals(IntFormat.def) && (bits > 3))
format = ValueFormatterHex.INSTANCE;
format = IntFormat.HEX_FORMATTER;
else if (format.equals(IntFormat.DEFAULT_FORMATTER) && (bits > 3))
format = IntFormat.HEX_FORMATTER;
this.format = format;
this.bits = bits;
}

View File

@ -9,7 +9,7 @@ import de.neemann.digital.core.Value;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.element.PinDescriptions;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.ValueFormatter;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;

View File

@ -11,7 +11,7 @@ import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.element.PinDescriptions;
import de.neemann.digital.core.io.In;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.ValueFormatter;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;

View File

@ -9,7 +9,7 @@ import de.neemann.digital.core.Value;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.element.PinDescriptions;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.ValueFormatter;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;

View File

@ -9,7 +9,7 @@ import de.neemann.digital.core.ObservableValue;
import de.neemann.digital.core.Value;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.PinDescriptions;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.ValueFormatter;
import de.neemann.digital.draw.elements.IOState;
import de.neemann.digital.draw.elements.Pin;
import de.neemann.digital.draw.elements.Pins;

View File

@ -8,7 +8,6 @@ package de.neemann.digital.gui.components;
import de.neemann.digital.core.*;
import de.neemann.digital.core.memory.DataField;
import de.neemann.digital.core.memory.importer.Importer;
import de.neemann.digital.core.valueFormatter.*;
import de.neemann.digital.gui.SaveAsHelper;
import de.neemann.digital.lang.Lang;
import de.neemann.gui.ErrorMessage;
@ -63,7 +62,7 @@ public class DataEditor extends JDialog {
if (dataFormat.isSuitedForAddresses())
addrFormat = dataFormat;
else
addrFormat = ValueFormatterHex.INSTANCE;
addrFormat = IntFormat.HEX_FORMATTER;
if (modelIsRunning)
localDataField = dataField;

View File

@ -6,8 +6,7 @@
package de.neemann.digital.gui.components;
import de.neemann.digital.core.*;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.valueFormatter.ValueFormatterDefault;
import de.neemann.digital.core.ValueFormatter;
import de.neemann.digital.lang.Lang;
import de.neemann.gui.Screen;
@ -71,7 +70,7 @@ public final class SingleValueDialog extends JDialog implements ModelStateObserv
private final long mask;
private JCheckBox[] checkBoxes;
private Value editValue;
private ValueFormatter valueFormatter = ValueFormatterDefault.INSTANCE;
private ValueFormatter valueFormatter = IntFormat.DEFAULT_FORMATTER;
/**
* Edits a single value

View File

@ -7,25 +7,25 @@ package de.neemann.digital.core;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.valueFormatter.*;
import junit.framework.TestCase;
public class IntFormatTest extends TestCase {
public void testHex() {
assertEquals("0x1", ValueFormatterHex.INSTANCE.formatToView(new Value(1, 1)));
assertEquals("0x1", ValueFormatterHex.INSTANCE.formatToView(new Value(1, 2)));
assertEquals("0x1", ValueFormatterHex.INSTANCE.formatToView(new Value(1, 3)));
assertEquals("0x1", ValueFormatterHex.INSTANCE.formatToView(new Value(1, 4)));
assertEquals("0xF", ValueFormatterHex.INSTANCE.formatToView(new Value(-1, 4)));
assertEquals("0x01", ValueFormatterHex.INSTANCE.formatToView(new Value(1, 5)));
assertEquals("0x1F", ValueFormatterHex.INSTANCE.formatToView(new Value(-1, 5)));
assertEquals("0xFFF", ValueFormatterHex.INSTANCE.formatToView(new Value(-1, 12)));
assertEquals("0x1FFF", ValueFormatterHex.INSTANCE.formatToView(new Value(-1, 13)));
assertEquals("0x3FFF", ValueFormatterHex.INSTANCE.formatToView(new Value(-1, 14)));
assertEquals("0x7FFF", ValueFormatterHex.INSTANCE.formatToView(new Value(-1, 15)));
assertEquals("0xFFFF", ValueFormatterHex.INSTANCE.formatToView(new Value(-1, 16)));
assertEquals("0xFEDCBA9876543210", ValueFormatterHex.INSTANCE.formatToView(new Value(0xFEDCBA9876543210L, 64)));
ValueFormatter vf = IntFormat.HEX_FORMATTER;
assertEquals("0x1", vf.formatToView(new Value(1, 1)));
assertEquals("0x1", vf.formatToView(new Value(1, 2)));
assertEquals("0x1", vf.formatToView(new Value(1, 3)));
assertEquals("0x1", vf.formatToView(new Value(1, 4)));
assertEquals("0xF", vf.formatToView(new Value(-1, 4)));
assertEquals("0x01", vf.formatToView(new Value(1, 5)));
assertEquals("0x1F", vf.formatToView(new Value(-1, 5)));
assertEquals("0xFFF", vf.formatToView(new Value(-1, 12)));
assertEquals("0x1FFF", vf.formatToView(new Value(-1, 13)));
assertEquals("0x3FFF", vf.formatToView(new Value(-1, 14)));
assertEquals("0x7FFF", vf.formatToView(new Value(-1, 15)));
assertEquals("0xFFFF", vf.formatToView(new Value(-1, 16)));
assertEquals("0xFEDCBA9876543210", vf.formatToView(new Value(0xFEDCBA9876543210L, 64)));
}
public void testBin() {
@ -44,10 +44,11 @@ public class IntFormatTest extends TestCase {
}
public void testDef() {
assertEquals("3", ValueFormatterDefault.INSTANCE.formatToView(new Value(3, 64)));
assertEquals("0x113", ValueFormatterDefault.INSTANCE.formatToView(new Value(0x113, 64)));
assertEquals("1A3", ValueFormatterDefault.INSTANCE.formatToView(new Value(0x1A3, 64)));
assertEquals("FFFFFFFFFFFFFFFF", ValueFormatterDefault.INSTANCE.formatToView(new Value(-1, 64)));
ValueFormatter vf = IntFormat.DEFAULT_FORMATTER;
assertEquals("3", vf.formatToView(new Value(3, 64)));
assertEquals("0x113", vf.formatToView(new Value(0x113, 64)));
assertEquals("1A3", vf.formatToView(new Value(0x1A3, 64)));
assertEquals("FFFFFFFFFFFFFFFF", vf.formatToView(new Value(-1, 64)));
}
/**

View File

@ -6,8 +6,6 @@
package de.neemann.digital.core;
import de.neemann.digital.core.io.InValue;
import de.neemann.digital.core.valueFormatter.ValueFormatter;
import de.neemann.digital.core.valueFormatter.ValueFormatterHex;
import junit.framework.TestCase;
public class ValueTest extends TestCase {
@ -22,6 +20,6 @@ public class ValueTest extends TestCase {
public void testFromInValue() throws Bits.NumberFormatException {
assertEquals("5", new Value(new InValue("5"), 4).toString());
assertEquals("Z", new Value(new InValue("z"), 4).toString());
assertEquals("Z", ValueFormatterHex.INSTANCE.formatToEdit(new Value(new InValue("z"), 4)));
assertEquals("Z", IntFormat.HEX_FORMATTER.formatToEdit(new Value(new InValue("z"), 4)));
}
}

View File

@ -6,7 +6,6 @@
package de.neemann.digital.data;
import de.neemann.digital.core.IntFormat;
import de.neemann.digital.core.valueFormatter.ValueFormatterHex;
import de.neemann.digital.testing.parser.TestRow;
import junit.framework.TestCase;
@ -45,7 +44,7 @@ public class ValueTableTest extends TestCase {
public void testCSV2() throws Exception {
StringWriter sw = new StringWriter();
ValueTable.ColumnInfo[] infos = new ValueTable.ColumnInfo[]{
new ValueTable.ColumnInfo(ValueFormatterHex.INSTANCE, 4),
new ValueTable.ColumnInfo(IntFormat.HEX_FORMATTER, 4),
new ValueTable.ColumnInfo(IntFormat.oct.createFormatter(null), 4),
new ValueTable.ColumnInfo(IntFormat.bin.createFormatter(null), 4),
};