Class HtmlUnitRegExpProxy

java.lang.Object
org.htmlunit.corejs.javascript.regexp.RegExpImpl
org.htmlunit.javascript.regexp.HtmlUnitRegExpProxy
All Implemented Interfaces:
org.htmlunit.corejs.javascript.RegExpProxy

public class HtmlUnitRegExpProxy extends org.htmlunit.corejs.javascript.regexp.RegExpImpl
Begins customization of JavaScript RegExp base on JDK regular expression support.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
     
    private static class 
     
    private static final class 
    Simple helper.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final org.apache.commons.logging.Log
     
    private static final Map<String,Pattern>
    Pattern cache
    private final org.htmlunit.corejs.javascript.RegExpProxy
     

    Fields inherited from class org.htmlunit.corejs.javascript.regexp.RegExpImpl

    input, lastMatch, lastParen, leftContext, multiline, parens, rightContext

    Fields inherited from interface org.htmlunit.corejs.javascript.RegExpProxy

    RA_MATCH, RA_REPLACE, RA_REPLACE_ALL, RA_SEARCH
  • Constructor Summary

    Constructors
    Constructor
    Description
    HtmlUnitRegExpProxy(org.htmlunit.corejs.javascript.RegExpProxy wrapped)
    Wraps a proxy to enhance it.
  • Method Summary

    Modifier and Type
    Method
    Description
    action(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, int actionType)
    Use the wrapped proxy except for replacement with string arg where it uses Java regular expression.
    compileRegExp(org.htmlunit.corejs.javascript.Context cx, String source, String flags)
    (package private) String
    computeReplacementValue(String replacement, String originalString, MatchResult matcher, boolean group0ReturnsWholeMatch)
     
    private Object
    doAction(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, int actionType)
     
    private String
    doReplacement(String originalString, String replacement, Matcher matcher, boolean replaceAll)
     
    private String
    doStringReplacement(String originalString, String searchString, String replacement, boolean replaceAll)
     
    int
    find_split(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable scope, String target, String separator, org.htmlunit.corejs.javascript.Scriptable re, int[] ip, int[] matchlen, boolean[] matched, String[][] parensp)
    boolean
    isRegExp(org.htmlunit.corejs.javascript.Scriptable obj)
    (package private) static String
    Transform a JavaScript regular expression to a Java regular expression
    private void
    setProperties(Matcher matcher, String thisString, int startPos, int endPos)
     
    private Object
    wrappedAction(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, int actionType)
    Calls action on the wrapped RegExp proxy.
    org.htmlunit.corejs.javascript.Scriptable
    wrapRegExp(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable scope, Object compiled)

    Methods inherited from class org.htmlunit.corejs.javascript.regexp.RegExpImpl

    js_split

    Methods inherited from class java.lang.Object

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

    • LOG

      private static final org.apache.commons.logging.Log LOG
    • PATTENS

      private static final Map<String,Pattern> PATTENS
      Pattern cache
    • wrapped_

      private final org.htmlunit.corejs.javascript.RegExpProxy wrapped_
  • Constructor Details

    • HtmlUnitRegExpProxy

      public HtmlUnitRegExpProxy(org.htmlunit.corejs.javascript.RegExpProxy wrapped)
      Wraps a proxy to enhance it.
      Parameters:
      wrapped - the original proxy
  • Method Details

    • action

      public Object action(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, int actionType)
      Use the wrapped proxy except for replacement with string arg where it uses Java regular expression.
      Specified by:
      action in interface org.htmlunit.corejs.javascript.RegExpProxy
      Overrides:
      action in class org.htmlunit.corejs.javascript.regexp.RegExpImpl
    • doAction

      private Object doAction(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, int actionType)
    • doStringReplacement

      private String doStringReplacement(String originalString, String searchString, String replacement, boolean replaceAll)
    • doReplacement

      private String doReplacement(String originalString, String replacement, Matcher matcher, boolean replaceAll)
    • computeReplacementValue

      String computeReplacementValue(String replacement, String originalString, MatchResult matcher, boolean group0ReturnsWholeMatch)
    • wrappedAction

      private Object wrappedAction(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, int actionType)
      Calls action on the wrapped RegExp proxy.
    • setProperties

      private void setProperties(Matcher matcher, String thisString, int startPos, int endPos)
    • compileRegExp

      public Object compileRegExp(org.htmlunit.corejs.javascript.Context cx, String source, String flags)
      Specified by:
      compileRegExp in interface org.htmlunit.corejs.javascript.RegExpProxy
      Overrides:
      compileRegExp in class org.htmlunit.corejs.javascript.regexp.RegExpImpl
    • find_split

      public int find_split(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable scope, String target, String separator, org.htmlunit.corejs.javascript.Scriptable re, int[] ip, int[] matchlen, boolean[] matched, String[][] parensp)
      Specified by:
      find_split in interface org.htmlunit.corejs.javascript.RegExpProxy
      Overrides:
      find_split in class org.htmlunit.corejs.javascript.regexp.RegExpImpl
    • isRegExp

      public boolean isRegExp(org.htmlunit.corejs.javascript.Scriptable obj)
      Specified by:
      isRegExp in interface org.htmlunit.corejs.javascript.RegExpProxy
      Overrides:
      isRegExp in class org.htmlunit.corejs.javascript.regexp.RegExpImpl
    • wrapRegExp

      public org.htmlunit.corejs.javascript.Scriptable wrapRegExp(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.Scriptable scope, Object compiled)
      Specified by:
      wrapRegExp in interface org.htmlunit.corejs.javascript.RegExpProxy
      Overrides:
      wrapRegExp in class org.htmlunit.corejs.javascript.regexp.RegExpImpl
    • jsRegExpToJavaRegExp

      static String jsRegExpToJavaRegExp(String re)
      Transform a JavaScript regular expression to a Java regular expression
      Parameters:
      re - the JavaScript regular expression to transform
      Returns:
      the transformed expression