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 Jul 16, 2024
1 parent 4d038c3 commit 3942a45
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 3942a45

Please sign in to comment.