Package cs1302.tracer.serialize
Class ModernTraceSerializer
java.lang.Object
cs1302.tracer.serialize.ModernTraceSerializer
Serializes
ExecutionSnapshot objects into the modern clean JSON trace format.-
Constructor Summary
ConstructorsConstructorDescriptionModernTraceSerializer(boolean removeMainArgs, boolean inlineStrings, boolean removeMethodThis) Constructs a ModernTraceSerializer defaulting to fully qualified type names.ModernTraceSerializer(boolean removeMainArgs, boolean inlineStrings, boolean removeMethodThis, TypeStyle typeStyle) Constructs a ModernTraceSerializer with the specified formatting options and TypeStyle. -
Method Summary
Modifier and TypeMethodDescriptioncreateBreakpointsTrace(String javaSource, String stdin, Map<Integer, ?> breakpointSnapshots) Creates a modern trace for a breakpoints map with standard input.createBreakpointsTrace(String javaSource, Map<Integer, ?> breakpointSnapshots) Creates a modern trace for a breakpoints map.createStep(ExecutionSnapshot snapshot, int stepNumber, boolean isMultiFile) Converts an individualExecutionSnapshotinto aStep.createTrace(String javaSource, ExecutionSnapshot snapshot) Creates a modern trace for a single execution snapshot.createTrace(String javaSource, String stdin, ExecutionSnapshot snapshot) Creates a modern trace for a single snapshot with standard input.createTrace(String javaSource, String stdin, List<ExecutionSnapshot> snapshots) Creates a modern trace for a chronological list of snapshots with standard input.createTrace(String javaSource, List<ExecutionSnapshot> snapshots) Creates a modern trace for a chronological list of snapshots.static com.google.gson.GsongetGson()Gets the shared Gson serializer instance.static com.google.gson.GsongetGson(boolean pretty) Gets the shared Gson serializer instance with optional pretty-printing.
-
Constructor Details
-
ModernTraceSerializer
public ModernTraceSerializer(boolean removeMainArgs, boolean inlineStrings, boolean removeMethodThis, TypeStyle typeStyle) Constructs a ModernTraceSerializer with the specified formatting options and TypeStyle.- Parameters:
removeMainArgs- Whether to remove args from the main stack frame.inlineStrings- Whether strings should be inlined.removeMethodThis- Whether this references should be omitted from method frames.typeStyle- The type qualification style (FQN or SIMPLE).
-
ModernTraceSerializer
public ModernTraceSerializer(boolean removeMainArgs, boolean inlineStrings, boolean removeMethodThis) Constructs a ModernTraceSerializer defaulting to fully qualified type names.- Parameters:
removeMainArgs- Whether to remove args from the main stack frame.inlineStrings- Whether strings should be inlined.removeMethodThis- Whether this references should be omitted from method frames.
-
-
Method Details
-
getGson
public static com.google.gson.Gson getGson()Gets the shared Gson serializer instance.- Returns:
- The Gson instance.
-
getGson
public static com.google.gson.Gson getGson(boolean pretty) Gets the shared Gson serializer instance with optional pretty-printing.- Parameters:
pretty- True to enable pretty-printing.- Returns:
- The Gson instance.
-
createTrace
Creates a modern trace for a single execution snapshot.- Parameters:
javaSource- The original Java source code.snapshot- The single execution snapshot.- Returns:
- The generated modern Trace object.
-
createTrace
Creates a modern trace for a single snapshot with standard input.- Parameters:
javaSource- The original Java source code.stdin- The standard input string.snapshot- The single execution snapshot.- Returns:
- The generated modern Trace object.
-
createTrace
Creates a modern trace for a chronological list of snapshots.- Parameters:
javaSource- The original Java source code.snapshots- The list of execution snapshots.- Returns:
- The generated modern Trace object.
-
createTrace
Creates a modern trace for a chronological list of snapshots with standard input.- Parameters:
javaSource- The original Java source code.stdin- The standard input string.snapshots- The list of execution snapshots.- Returns:
- The generated modern Trace object.
-
createBreakpointsTrace
Creates a modern trace for a breakpoints map.- Parameters:
javaSource- The original Java source code.breakpointSnapshots- The mapping of line numbers to snapshots.- Returns:
- The generated modern Trace object.
-
createBreakpointsTrace
public Trace createBreakpointsTrace(String javaSource, String stdin, Map<Integer, ?> breakpointSnapshots) Creates a modern trace for a breakpoints map with standard input.- Parameters:
javaSource- The original Java source code.stdin- The standard input string.breakpointSnapshots- The mapping of line numbers to snapshots.- Returns:
- The generated modern Trace object.
-
createStep
Converts an individualExecutionSnapshotinto aStep.- Parameters:
snapshot- The execution snapshot.stepNumber- The 1-based step sequence number.isMultiFile- True if file path attributes should be serialized.- Returns:
- The converted Step.
-