Package org.htmlunit.javascript.regexp
Class RegExpJsToJavaConverter.Tape
- java.lang.Object
-
- org.htmlunit.javascript.regexp.RegExpJsToJavaConverter.Tape
-
- Enclosing class:
- RegExpJsToJavaConverter
private static class RegExpJsToJavaConverter.Tape extends java.lang.ObjectHelper to encapsulate the transformations.
-
-
Field Summary
Fields Modifier and Type Field Description private intcurrentPos_private java.lang.StringBuildertape_
-
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 voidinsert(java.lang.String token, int offset)Inserts a string at the current position + offset.voidinsertAt(java.lang.String token, int pos)Inserts a string at the given pos.voidmove(int offset)Moves the current read position by offset.intread()Reads the character at the current position and moves the read position by 1.voidremove(int count)Removes number of chars from the given string.voidreplace(int count, java.lang.String token)Replaces the current char with the given string.java.lang.StringtoString()Read the whole tape content.
-
-
-
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 insertoffset- 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 insertpos- 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:
toStringin classjava.lang.Object- Returns:
- tape content
-
-