Skip to content

Commit

Permalink
Java: Implement interface PositionInfo if positions is generated
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingun committed Sep 8, 2024
1 parent a0ec4b2 commit 65b4413
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,22 @@ class JavaCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
""
}

out.puts(s"public ${staticStr}class ${type2class(name)} extends $kstructName {")
val iface = if (config.readStoresPos) {
"implements PositionInfo "
} else {
""
}

out.puts(s"public ${staticStr}class ${type2class(name)} extends $kstructName $iface{")
out.inc

if (config.readStoresPos) {
out.puts("public final Map<String, Span> _spans = new HashMap<String, Span>();")
out.puts("@Override")
out.puts("public final Map<String, Span> _spans() { return this._spans; }")
out.puts

importList.add("io.kaitai.struct.PositionInfo")
importList.add("io.kaitai.struct.Span")
importList.add("java.util.ArrayList")
importList.add("java.util.HashMap")
Expand Down

0 comments on commit 65b4413

Please sign in to comment.