Package com.google.gwt.regexp.shared

Examples of com.google.gwt.regexp.shared.MatchResult


      trsStart = "0";
    } else if ("hide".equals(val)) {
      g.saveCssAttrs(key);
      trsEnd = "0";
    } else {
      MatchResult parts = REGEX_SYMBOL_NUMBER_UNIT.exec(val);
      if (parts != null) {

        String part1 = parts.getGroup(1);
        String part2 = parts.getGroup(2);
        String part3 = parts.getGroup(3);
        trsEnd = "" + Double.parseDouble(part2);

        unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" :  part3 == null || part3.isEmpty() ? "px" : part3;

        if (trsStart.isEmpty()) {
          trsStart = key.matches("scale") ? "1" : "0";
        }

        if (part1 != null && !part1.isEmpty()) {
          double n = "-=".equals(part1) ? -1 : 1;

          double st = 0;
          MatchResult sparts = REGEX_SYMBOL_NUMBER_UNIT.exec(trsStart);
          if (sparts != null) {
            st = Double.parseDouble(sparts.getGroup(2));
            unit = sparts.getGroup(3).isEmpty() ? unit : sparts.getGroup(3);
          }
          trsStart = "" + st;

          double en = Double.parseDouble(trsEnd);
          trsEnd = "" + (st + n*en);
 
View Full Code Here


    public int[] getStartColor() {
      return startColor;
    }

    protected int[] parseColor(String color) {
      MatchResult matches = REGEX_RGB_COLOR_PATTERN.exec(color);
      if (matches != null) {
        return parseRGBColor(matches);
      }

      matches = REGEX_HEX_COLOR_PATTERN.exec(color);
View Full Code Here

    if (timeout > 0) {
      builder.setTimeout(timeout);
    }
    // jQuery allows a parameter callback=? to figure out the callback parameter
    if (callbackParam == null) {
      MatchResult tmp = callbackRegex.exec(url);
      if  (tmp != null && tmp.getGroupCount() == 4) {
        callbackParam = tmp.getGroup(2);
        url = tmp.getGroup(1) + tmp.getGroup(3);
      }
    }
    if (callbackParam != null) {
      builder.setCallbackParam(callbackParam);
    }
View Full Code Here

  public NodeList<Element> select(String selector, Node ctx) {

    if (nativePseudo.test(selector)) {
      // move gQuery filters at the end to improve performance, and deal with issue #220
      MatchResult r;
      while ((r = nativePseudo.exec(selector)) != null) {
        selector = r.getGroup(1) + ":" + r.getGroup(3);
        if (!r.getGroup(3).equals(r.getGroup(2))) {
          selector += ":" + r.getGroup(2);
        }
        selector += r.getGroup(4);
      }
    }

    if (gQueryPseudo.test(selector)) {
      JsNodeArray res = JsNodeArray.create();
      for (String s : selector.trim().split("\\s*,\\s*")) {
        NodeList<Element> nodes;
        MatchResult a = gQueryPseudo.exec(s);
        if (a != null) {
          String select = a.getGroup(1).isEmpty() ? "*" : a.getGroup(1);
          String pseudo = a.getGroup(2);
          Predicate pred = filters.get(pseudo.toLowerCase());
          if (pred != null) {
            nodes = filter(select(select, ctx), pred);
          } else if (nativePseudo.test(pseudo)) {
            nodes =  select(select, ctx);
View Full Code Here

    double cur;
    String rkey = null;
    if (key.startsWith("$")) {
      rkey = key.substring(1).toLowerCase();
      String attr = g.attr(rkey);
      MatchResult parts = REGEX_NUMBER_UNIT.exec(attr);
      if (parts != null) {
        String $1 = parts.getGroup(1);
        String $2 = parts.getGroup(2);
        cur = Double.parseDouble($1);
        unit = $2 == null ? "" : $2;
      } else {
        cur = g.cur(key, true);
        key = rkey;
      }
    } else {
      cur = g.cur(key, true);
    }

    double start = cur, end = start;

    if ("show".equals(val)) {
      g.saveCssAttrs(key);
      start = 0;
      unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : "px";
    } else if ("hide".equals(val)) {
      if (hidden) {
        return null;
      }
      g.saveCssAttrs(key);
      end = 0;
      unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : "px";
    } else {
      MatchResult parts = REGEX_SYMBOL_NUMBER_UNIT.exec(val);

      if (parts != null) {
        String $1 = parts.getGroup(1);
        String $2 = parts.getGroup(2);
        String $3 = parts.getGroup(3);
        end = Double.parseDouble($2);

        if (rkey == null) {
          unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : //
            $3 == null || $3.isEmpty() ? "px" : $3;
View Full Code Here

            public InlineValidationResult getValidation(ValueBoxBase<String> widget) {
                if(widget.getText().trim().isEmpty()) {
                    return lastValidationResult = InlineValidationResult.getInvalid("Please enter an email address");
                }

                MatchResult matchResult = EMAIL_PATTERN.exec(widget.getText().trim());
                if(matchResult != null) {
                    return lastValidationResult = InlineValidationResult.getValid();
                }
                else {
                    return lastValidationResult = InlineValidationResult.getInvalid("Invalid email address");
View Full Code Here

    }

    public static PlacePropertyValueList parse(String token) {
        final String globalFlag = "g";
        RegExp regExp = RegExp.compile("([^" + PROPERTY_VALUE_SEPARATOR + "]+)" + PROPERTY_VALUE_SEPARATOR + "([^" + PROPERTY_VALUE_ITEM_SEPARATOR + "]+)" + PROPERTY_VALUE_ITEM_SEPARATOR, globalFlag);
        MatchResult matchResult = regExp.exec(token);
        Builder resultBuilder = builder();
        while(matchResult != null) {
            String name = URL.decodeQueryString(matchResult.getGroup(1));
            String value = URL.decodeQueryString(matchResult.getGroup(2));
            resultBuilder.set(name, value);
            final int matchLength = matchResult.getGroup(0).length();
            final int matchStart = matchResult.getIndex();
            final int nextIndex = matchStart + matchLength;
            regExp.setLastIndex(nextIndex);
            matchResult = regExp.exec(token);
        }
        return resultBuilder.build();
View Full Code Here

                         * the request and served non-UIDL content (for
                         * instance, a login page if the session has expired.)
                         * If the response contains a magic substring, do a
                         * synchronous refresh. See #8241.
                         */
                        MatchResult refreshToken = RegExp.compile(
                                UIDL_REFRESH_TOKEN + "(:\\s*(.*?))?(\\s|$)")
                                .exec(response.getText());
                        if (refreshToken != null) {
                            redirect(refreshToken.getGroup(2));
                            return;
                        }
                    }

                    final Date start = new Date();
View Full Code Here

    private int countNewlines(String string) {
        RegExp newlineRegExp = RegExp.compile(newlineRegex, "g");

        int count = 0;
        MatchResult matchResult = newlineRegExp.exec(string);
        while (matchResult != null) {
            count++;
            matchResult = newlineRegExp.exec(string);
        }
        return count;
View Full Code Here

     * @param text
     * @return
     */
    private static String
            replaceEntityWithEmptyString(RegExp regex, String text) {
        MatchResult result = regex.exec(text);
        while (result != null) {
            // replace match entity with empty string
            text = text.replace(result.getGroup(0), "");
            result = regex.exec(text);
        }
        return text;
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.regexp.shared.MatchResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.