Package com.google.gwt.regexp.shared

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


    URLPattern pattern = getURLPattern(pageName);
    if (pattern.getParamList().size() == 0)
      return pageName;

    MatchResult mr = pattern.getRegex().exec(rawURIPath);
    for (int keyIndex = 0; keyIndex < pattern.getParamList().size(); keyIndex++) {
      builder.put(pattern.getParamList().get(keyIndex), mr.getGroup(keyIndex + 1));
    }
    return pageName;
  }
View Full Code Here


   */
  public String printURL(ImmutableMultimap<String, String> state) {
    RegExp re = RegExp.compile(paramRegex, "g");
    String url = this.urlTemplate;
   
    MatchResult mr;

    while ((mr = re.exec(this.urlTemplate)) != null) {
      String toReplace = mr.getGroup(0);
      String key = mr.getGroup(1);
      if (toReplace.contains(key)) {
        url = url.replace(toReplace, state.get(key).iterator().next());
      }
      else {
        throw new IllegalStateException("Path parameter list did not contain required parameter " + mr.getGroup(1));
      }
    }

    if (state.keySet().size() == paramList.size()) {
      return url;
View Full Code Here

    @Override
    public com.google.gwt.user.client.Element getSubPartElement(String subPart) {
        if ("tabpanel".equals(subPart)) {
            return DOM.asOld(tabPanel.getElement().getFirstChildElement());
        } else if (SUBPART_TAB_REGEXP.test(subPart)) {
            MatchResult result = SUBPART_TAB_REGEXP.exec(subPart);
            int tabIx = Integer.valueOf(result.getGroup(1));
            Tab tab = tb.getTab(tabIx);
            if (tab != null) {
                if ("/close".equals(result.getGroup(2))) {
                    if (tab.isClosable()) {
                        return tab.tabCaption.getCloseButton();
                    }
                } else {
                    return tab.tabCaption.getElement();
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

public class SVGParserImplOpera extends SVGParserImpl {
  private static final String URL = "^url\\((['\"])?[^#\\)]*#([^'\"\\)]*)\\1\\)$";
  private static final RegExp URLExp = RegExp.compile(URL, "g");
  private static String getRef(String expr) {
    URLExp.setLastIndex(0);
    MatchResult result = URLExp.exec(expr);
    if (result != null && result.getGroupCount() == 3) {
      return result.getGroup(2);
    }
    return null;
  }
View Full Code Here

    String[] lengthArray = cssText.split(COMMA);
    for (int i = 0; i < lengthArray.length; i++) {
      if (lengthArray[i].length() > 0) {
        LENGTH.setLastIndex(0);
        String length = lengthArray[i].trim();
        MatchResult result = LENGTH.exec(length);
        if (result != null && result.getGroupCount() == 3) {
          short primitiveType = CSSPrimitiveValue.CSS_NUMBER;
          String unit = result.getGroup(2);
          if (unit != null) {
            primitiveType = unitToPrimitiveType.get(unit.toLowerCase());
          }
          float value = Float.parseFloat(result.getGroup(1));
          lengths.add(new OMCSSPrimitiveValue(value, primitiveType));
        } else {
          throw new JavaScriptException("Invalid length spec: " + length);
        }
      }
View Full Code Here

 
  private OMSVGPaint parse(String cssText, String uri) {
    if (uri == null) {
      // begins with a funciri
      FUNCIRI.setLastIndex(0);
      MatchResult result = FUNCIRI.exec(cssText);
      if (result != null && result.getGroupCount() == 2) {
//        GWT.log("matched funciri: '" + cssText.substring(FUNCIRI.getLastIndex()) + "' '" + result.getGroup(1) + "'");
        String str = FUNCIRI.getLastIndex() == cssText.length() ? null : cssText.substring(FUNCIRI.getLastIndex());
        return parse(str, result.getGroup(1));
      }
    }
    String rgbColor = null;
    String iccColor = null;
    if (cssText != null) {
      if (SVGConstants.CSS_NONE_VALUE.equals(cssText)) {
        // none
        if (uri == null) {
          return NONE;
        }
        OMSVGPaint paint = new OMSVGPaint(OMSVGPaint.SVG_PAINTTYPE_URI_NONE);
        paint.setPaint(OMSVGPaint.SVG_PAINTTYPE_URI_NONE, uri, null, null);
        return paint;
      } else if (SVGConstants.CSS_INHERIT_VALUE.equals(cssText)) {
        // none
        return INHERIT;
      } else if (SVGConstants.CSS_CURRENTCOLOR_VALUE.equals(cssText)) {
        // currentColor
        if (uri == null) {
          return CURRENT_COLOR;
        }
        OMSVGPaint paint = new OMSVGPaint(OMSVGPaint.SVG_PAINTTYPE_URI_CURRENTCOLOR);
        paint.setPaint(OMSVGPaint.SVG_PAINTTYPE_URI_CURRENTCOLOR, uri, null, null);
        return paint;
      }
 
      COLORNAME.setLastIndex(0);
      MatchResult result = COLORNAME.exec(cssText);
      if (result != null && result.getGroupCount() == 2) {
        // color name
        rgbColor = getNamedColor(result.getGroup(1));
        if (rgbColor == null) {
          throw new JavaScriptException("Unknown color keyword: " + cssText)
        }
        iccColor = COLORNAME.getLastIndex() == cssText.length() ? null : cssText.substring(COLORNAME.getLastIndex());
      }
     
      if (rgbColor == null) {
        RGB255.setLastIndex(0);
        result = RGB255.exec(cssText);
        if (result != null && result.getGroupCount() == 4) {
          rgbColor = result.getGroup(0);
          iccColor = RGB255.getLastIndex() == cssText.length() ? null : cssText.substring(RGB255.getLastIndex());
        }
      }
      if (rgbColor == null) {
        RGBPCT.setLastIndex(0);
        result = RGBPCT.exec(cssText);
        if (result != null && result.getGroupCount() == 4) {
          rgbColor = result.getGroup(0);
          iccColor = RGBPCT.getLastIndex() == cssText.length() ? null : cssText.substring(RGBPCT.getLastIndex());
        }
      }
      if (rgbColor == null) {
        RGBHEX.setLastIndex(0);
        result = RGBHEX.exec(cssText);
        if (result != null && result.getGroupCount() == 2) {
          rgbColor = result.getGroup(0);
          iccColor = RGBHEX.getLastIndex() == cssText.length() ? null : cssText.substring(RGBHEX.getLastIndex());
        }
      }
    }
View Full Code Here

  }

  public OMSVGICCColor iccColor(String str) {
//    GWT.log("iccColor(" + str + ")");
    ICC.setLastIndex(0);
    MatchResult result = ICC.exec(str);
    if (result != null && result.getGroupCount() == 3) {
      String[] intArray = result.getGroup(2).split(COMMA);
      List<Integer> intList = new ArrayList<Integer>();
      for (int i = 0; i < intArray.length; i++) {
        if (intArray[i].length() > 0) {
          intList.add(Integer.parseInt(intArray[i]));
        }
      }
      return new OMSVGICCColor(result.getGroup(1), intList);
    }
    throw new JavaScriptException("Invalid icc-color spec: " + str);
  }
View Full Code Here

  }

  public OMRGBColor rgbColor(String str) {
//    GWT.log("rgbColor(" + str + ")");
    RGB255.setLastIndex(0);
    MatchResult result = RGB255.exec(str);
    if (result != null && result.getGroupCount() == 4) {
      return new OMRGBColor(
        Integer.parseInt(result.getGroup(1)),
        Integer.parseInt(result.getGroup(2)),
        Integer.parseInt(result.getGroup(3)));
    }
    RGBPCT.setLastIndex(0);
    result = RGBPCT.exec(str);
    if (result != null && result.getGroupCount() == 4) {
      return new OMRGBColor(
        255 * Integer.parseInt(result.getGroup(1)) / 100,
        255 * Integer.parseInt(result.getGroup(2)) / 100,
        255 * Integer.parseInt(result.getGroup(3)) / 100);
    }
    RGBHEX.setLastIndex(0);
    result = RGBHEX.exec(str);
    if (result != null && result.getGroupCount() == 2) {
      String hex = result.getGroup(1);
      if (hex.length() == 3) {
        return new OMRGBColor(
          Integer.parseInt(hex.substring(0, 1), 16),
          Integer.parseInt(hex.substring(1, 2), 16),
          Integer.parseInt(hex.substring(2, 3), 16));
View Full Code Here

  protected final String replaceParameters(String message,
      Function<String, String> replacer) {
    StringBuffer sb = new StringBuffer();
    int index = 0;

    MatchResult matcher;
    while ((matcher = MESSAGE_PARAMETER_PATTERN.exec(message)) != null) {
      String matched = matcher.getGroup(0);
      sb.append(message.substring(index, matcher.getIndex()));
      Object value = replacer.apply(removeCurlyBrace(matched));
      sb.append(value == null ? matched : value);
      index = MESSAGE_PARAMETER_PATTERN.getLastIndex();
    }
    if (index < message.length()) {
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.