Class RegExpJsToJavaConverter.Tape

java.lang.Object
org.htmlunit.javascript.regexp.RegExpJsToJavaConverter.Tape
Enclosing class:
RegExpJsToJavaConverter

private static class RegExpJsToJavaConverter.Tape extends Object
Helper to encapsulate the transformations.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
     
    private final StringBuilder
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Tape(String input)
    Wraps a JavaScript RegExp to access it char by char like a tape.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    insert(String token, int offset)
    Inserts a string at the current position + offset.
    void
    insertAt(String token, int pos)
    Inserts a string at the given pos.
    void
    move(int offset)
    Moves the current read position by offset.
    int
    Reads the character at the current position and moves the read position by 1.
    void
    remove(int count)
    Removes number of chars from the given string.
    void
    replace(int count, String token)
    Replaces the current char with the given string.
    Read the whole tape content.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • tape_

      private final StringBuilder tape_
    • currentPos_

      private int currentPos_
  • Constructor Details

    • Tape

      Tape(String input)
      Wraps a JavaScript RegExp to access it char by char like a tape.
      Parameters:
      input - the Javascript RegExp
  • Method Details

    • move

      public void move(int offset)
      Moves the current read position by offset.
      Parameters:
      offset - the move position offset
    • read

      public int read()
      Reads the character at the current position and moves the read position by 1.
      Returns:
      the character at current position
    • insert

      public void insert(String token, int offset)
      Inserts a string at the current position + offset.
      Parameters:
      token - the string to insert
      offset - the move position offset
    • insertAt

      public void insertAt(String token, int pos)
      Inserts a string at the given pos.
      Parameters:
      token - the string to insert
      pos - the move position offset
    • replace

      public void replace(int count, String token)
      Replaces the current char with the given string.
      Parameters:
      token - the string to insert
    • remove

      public void remove(int count)
      Removes number of chars from the given string.
      Parameters:
      count - the number of chars to remove
    • toString

      public String toString()
      Read the whole tape content.
      Overrides:
      toString in class Object
      Returns:
      tape content