Class RegExpJsToJavaConverter.Tape

  • Enclosing class:
    RegExpJsToJavaConverter

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

      Fields 
      Modifier and Type Field Description
      private int currentPos_  
      private java.lang.StringBuilder tape_  
    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void insert​(java.lang.String token, int offset)
      Inserts a string at the current position + offset.
      void insertAt​(java.lang.String token, int pos)
      Inserts a string at the given pos.
      void move​(int offset)
      Moves the current read position by offset.
      int read()
      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, java.lang.String token)
      Replaces the current char with the given string.
      java.lang.String toString()
      Read the whole tape content.
      • Methods inherited from class java.lang.Object

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

      • tape_

        private final java.lang.StringBuilder tape_
      • currentPos_

        private int currentPos_
    • Constructor Detail

      • Tape

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

      • 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​(java.lang.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​(java.lang.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,
                            java.lang.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 java.lang.String toString()
        Read the whole tape content.
        Overrides:
        toString in class java.lang.Object
        Returns:
        tape content