Class InputTracker

java.lang.Object
cs1302.tracer.trace.InputTracker

public class InputTracker extends Object
Tracks the progressive, monotonic consumption of standard input during guest program execution.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new InputTracker with the specified standard input string.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    consumeBytes(int count)
    Records raw UTF-8 byte consumption, advancing only through complete code points.
    Returns the cumulative string of standard input consumed up to this point.
    void
    Records consumption of a full line (e.g., from Scanner.nextLine, BufferedReader.readLine, or IO.readln), advancing through the line and consuming any immediate line terminator (CRLF, LF, or CR).
    void
    Records consumption of a token (e.g., from Scanner.next*), advancing past any leading whitespace/delimiters and through the token itself.
    boolean
    Returns true if all standard input has been consumed.
    int
    Returns the current character offset within the standard input.
    Returns the complete standard input string.
    Returns the unconsumed portion of standard input.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InputTracker

      public InputTracker(String stdin)
      Constructs a new InputTracker with the specified standard input string.
      Parameters:
      stdin - The standard input string provided to the guest.
  • Method Details

    • stdin

      public String stdin()
      Returns the complete standard input string.
      Returns:
      The standard input string.
    • consumed

      public String consumed()
      Returns the cumulative string of standard input consumed up to this point.
      Returns:
      Substring of consumed standard input.
    • offset

      public int offset()
      Returns the current character offset within the standard input.
      Returns:
      Current 0-based character index.
    • unconsumed

      public String unconsumed()
      Returns the unconsumed portion of standard input.
      Returns:
      Unconsumed standard input substring.
    • isExhausted

      public boolean isExhausted()
      Returns true if all standard input has been consumed.
      Returns:
      True if cursor reached or exceeded standard input length.
    • consumeToken

      public void consumeToken(String token)
      Records consumption of a token (e.g., from Scanner.next*), advancing past any leading whitespace/delimiters and through the token itself.
      Parameters:
      token - The token consumed.
    • consumeLine

      public void consumeLine(String line)
      Records consumption of a full line (e.g., from Scanner.nextLine, BufferedReader.readLine, or IO.readln), advancing through the line and consuming any immediate line terminator (CRLF, LF, or CR).
      Parameters:
      line - The line content consumed (excluding newline delimiter).
    • consumeBytes

      public void consumeBytes(int count)
      Records raw UTF-8 byte consumption, advancing only through complete code points. Character offsets remain UTF-16 indices into the supplied input string.
      Parameters:
      count - Number of bytes consumed by InputStream.read.