feat(fls): topology of a .fls file as Java loads it
readTopology maps the decoded JavaBeans graph to devices, cables and documentation items the way SzenarioVerwaltung.netzwerkLaden does: the kind from the Java class (the palette label is not file data), devices without bounds at 0,0, interface values through Java's setters. All 23 corpus files match Java field by field. Found on the way: - listItems mixed a constructor's elements with added ones; a router's second interface was lost. Lists now replay add/set in order after the elements the constructor made. - The first 0 of a file may be SwingConstants.CENTER; measured like the getter defaults. - IP.ipCheck (javaIp.ts) measured on 46 cases: empty tokens skipped, signs, leading zeros and BMP digits of any script accepted. - The Java oracle took lower-case MACs in a file for random ones (8 interfaces); it now compares case-insensitively and reports the host name flags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
// Runs FILIUS's own IP.ipCheck on every case of a list and writes what Java
|
||||
// returns — the reference for packages/fls/src/javaIp.ts. The cases file is
|
||||
// ASCII, one case per line, with Java-style unicode escapes (backslash, u,
|
||||
// four hex digits) for anything else (so no editor or
|
||||
// hook can change a case by trimming or normalising it).
|
||||
//
|
||||
// Usage: java -cp filius.jar:lib/*:classes IpCheckCases <cases txt> <output json>
|
||||
|
||||
import filius.software.vermittlungsschicht.IP;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class IpCheckCases {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
List<Object> result = new ArrayList<>();
|
||||
for (String line : Files.readAllLines(Path.of(args[0]), StandardCharsets.US_ASCII)) {
|
||||
String input = unescape(line);
|
||||
String output;
|
||||
try {
|
||||
output = IP.ipCheck(input);
|
||||
} catch (RuntimeException error) {
|
||||
output = "!" + error.getClass().getSimpleName();
|
||||
}
|
||||
result.add(Arrays.asList(line, output));
|
||||
}
|
||||
try (FileOutputStream out = new FileOutputStream(args[1])) {
|
||||
out.write((FlsOracle.Json.write(result, "") + "\n").getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
System.out.println("ip check cases: " + result.size());
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
static String unescape(String line) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
for (int index = 0; index < line.length(); index++) {
|
||||
if (line.startsWith("\\u", index) && index + 6 <= line.length()) {
|
||||
out.append((char) Integer.parseInt(line.substring(index + 2, index + 6), 16));
|
||||
index += 5;
|
||||
} else {
|
||||
out.append(line.charAt(index));
|
||||
}
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user