Package com.google.gwt.regexp.shared

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


      return false; // All versions of Chrome are upsupported
    }

    if (userAgent.contains("Firefox")) {
      RegExp versionRegExp = RegExp.compile("Firefox[\\/\\s](\\d+)\\.\\d+", "ig");
      MatchResult result = versionRegExp.exec(userAgent);
      if (result != null) {
        int version = Integer.parseInt(result.getGroup(1));
        return version < 7; // Resize is unsupported for Firefox 7 and newer.
      }
    }
    return true;
  }
View Full Code Here


  public void testSetTabIndex() {
    // Skip this test on Safari 3 because it does not support focusable divs.
    String userAgent = Window.Navigator.getUserAgent();
    if (userAgent.contains("Safari")) {
      RegExp versionRegExp = RegExp.compile("Version/[0-3]", "ig");
      MatchResult result = versionRegExp.exec(userAgent);
      if (result != null && result.getGroupCount() > 0) {
        return;
      }
    }

    AbstractHasData<String> display = createAbstractHasData(new TextCell());
View Full Code Here

    private static PathImpl parseProperty(String property) {
      PathImpl path = new PathImpl();
      String tmp = property;
      do {
        MatchResult matcher = pathPattern.exec(tmp);
        if (matcher != null) {
          String value = matcher.getGroup(1);
          String indexed = matcher.getGroup(2);
          String index = matcher.getGroup(3);
          NodeImpl node = new NodeImpl(value);

          if (indexed != null && indexed.length() > 0) {
            node.setInIterable(true);
          }
          if (index != null && index.length() > 0) {
            try {
              Integer i = Integer.parseInt(index);
              node.setIndex(i);
            } catch (NumberFormatException e) {
              node.setKey(index);
            }
          }
          path.addNode(node);
          tmp = matcher.getGroup(5);
        } else {
          throw new IllegalArgumentException("Unable to parse property path "
              + property);
        }
      } while (tmp != null && tmp.length() > 0);
View Full Code Here

    return getMajorVersion(versionString);
  }

  private static int getMajorVersion(String versionString) {
    MatchResult matchResult = RegExp.compile(VERSION_REGEXP).exec(versionString);
    assert matchResult.getGroup(0).equals(versionString);
    return Integer.parseInt(matchResult.getGroup(1));
  }
View Full Code Here

    String hyphenated = camelCaseMap.get(name);

    // Convert the name to hyphenated format if not in the cache.
    if (hyphenated == null) {
      hyphenated = "";
      MatchResult matches;
      while ((matches = camelCaseWord.exec(name)) != null) {
        String word = matches.getGroup(0);
        if (caseWord.exec(word) == null) {
          // The first letter is already lowercase, probably the first word.
          hyphenated += word;
        } else {
          // Hyphenate the first letter.
          hyphenated += "-" + StringCase.toLower(matches.getGroup(1));
          if (matches.getGroupCount() > 1) {
            hyphenated += matches.getGroup(2);
          }
        }
      }
      camelCaseMap.put(name, hyphenated);
    }
View Full Code Here

   */
  public HashMap<String, Prefix> getPrefixHashMap() {
    HashMap<String, Prefix> queryPrefixes = new HashMap<String, Prefix>();
    RegExp regExp = RegExp.compile(PREFIX_PATTERN, "gm");
    while (true) {
      MatchResult matcher = regExp.exec(getQuery());
      if (matcher == null)
        break;
      queryPrefixes.put(matcher.getGroup(2), new Prefix(matcher.getGroup(1), matcher.getGroup(2)));
    }
    return queryPrefixes;
  }
View Full Code Here

   * screenshot containing lots of popups
   */
  public static boolean isCrawler() {
    String userAgent = JsMethods.getUserAgent();
    RegExp regExp = RegExp.compile(".*(" + CRAWL_USER_AGENTS + ").*");
    MatchResult matcher = regExp.exec(userAgent);
    boolean matchFound = (matcher != null);
    return matchFound;
  }
View Full Code Here

    public void setMask(final String mask, final boolean showMask, final char freeSymbol) {

        final List<Flag> flags = new ArrayList<Flag>();

        int current = 0;
        MatchResult matchResult = regExp.exec(mask);
        while (matchResult != null) {
            final String group = matchResult.getGroup(1);

            // Fill forced
            for (int i = current; i < matchResult.getIndex(); i++) {
                final char c = mask.charAt(current);
                flags.add(new Const(c, showMask, freeSymbol));
                current++;
            }
View Full Code Here

  private static RegExp Pattern = RegExp.compile("\\[\\s*([0-9]*[\\.]?[0-9]+)\\s*,\\s*([0-9]*[\\.]?[0-9]+)\\s*\\]");
 
 
  // parse from String
  public static Vector2 parseVector2(String s) {
    MatchResult res = Pattern.exec(s);
    if (res == null) return null;
    return new Vector2(Double.parseDouble(res.getGroup(1)), Double.parseDouble(res.getGroup(2)));
  }
View Full Code Here

   * Parse a color from a color code.
   */
  public static final Color parseColor(String s) {
   
    // rgba pattern
    MatchResult res = PatternRGBA.exec(s);
    if (res != null && res.getGroupCount() == 5) return new Color(Integer.parseInt(res.getGroup(1)), Integer.parseInt(res.getGroup(2)), Integer.parseInt(res.getGroup(3)), Double.parseDouble(res.getGroup(4)));
   
    // rgb pattern
    res = PatternRGB.exec(s);
    if (res != null && res.getGroupCount() == 4) return new Color(Integer.parseInt(res.getGroup(1)), Integer.parseInt(res.getGroup(2)), Integer.parseInt(res.getGroup(3)));
   
    // hex pattern
    res = PatternHex.exec(s);
    if (res != null && res.getGroupCount() == 4) return new Color(Integer.parseInt(res.getGroup(1), 16), Integer.parseInt(res.getGroup(2), 16), Integer.parseInt(res.getGroup(3), 16));
   
    // no match
    return null;
  }
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.