Package com.google.gwt.regexp.shared

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


  // public static final String STYLE = "style";
  public static final String USER = "user";

  public static String parseClientContent(String content) {
    RegExp p = RegExp.compile("\\[{2}((?:.)*?)\\]{2}", "g");
    MatchResult m;
    StringBuffer sb = new StringBuffer();
    int beginIndex = 0;
    while ((m = p.exec(content)) != null) {
      String one = m.getGroup(1);
      String[] split = one.split("\\|");
      int endIndex = m.getIndex();

      sb.append(content.substring(beginIndex, endIndex));

      sb.append("<a href=\"/#!p:" + URL.encodeQueryString(split[0])
          + "\">" + (split.length > 1 ? split[1] : split[0]) + "</a>");
View Full Code Here


  public static String getLinkHost(String link) {
    if (link != null) {
      // It doesn't seem as if java.net.URL is GWT-friendly.  Thus...  GWT regular expressions!
      RegExp regExp = RegExp.compile("(\\w+?)://([\\-\\.\\w]+?)/.*");
      // toLowerCase is okay because nothing we're interested in is case sensitive.
      MatchResult result = regExp.exec(link.toLowerCase());

      if (result != null) {
        String protocol = result.getGroup(1);
        String host = result.getGroup(2);
        if (PROTOCOL_WHITELIST.contains(protocol)) {
          return "[" + host + "/]";
        }
      }
    }
View Full Code Here

    String maxAgeMatch = null;
    if (cacheControlHeader != null) {
      if (maxAgeRegExp == null) {
        maxAgeRegExp = RegExp.compile("max-age=(\\d+)");
      }
      MatchResult matchResult = maxAgeRegExp.exec(cacheControlHeader);
      if (matchResult != null && matchResult.getGroupCount() > 1) {
        maxAgeMatch = matchResult.getGroup(1);
      }
    }

    // The max-age overrides Expires in most modern browsers.
    if (maxAgeMatch != null) {
View Full Code Here

        SplitResult result = ITEMS.split(RESOURCES.auditLog().getText());
        for (int i = 0; i < result.length(); i++) {
            String nextResult = result.get(i);
            if (nextResult != null && nextResult.length() != 0) {
                String itemText = nextResult.trim() + "\n}";
                MatchResult match = ITEM.exec(itemText);
                if (match != null) {
                    store.add(parseItem(match));
                }
            }
        }
View Full Code Here

  protected final String replaceParameters(String message,
      Function<String, String> replacer) {
    StringBuilder sb = new StringBuilder();
    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

      if (name.startsWith("-") && name.length() > 1) {
        name = name.substring(1);
      }

      camelCase = "";
      MatchResult matches;
      while ((matches = maybeHyphenatedWord.exec(name)) != null) {
        String word = matches.getGroup(0);
        if (!word.startsWith("-")) {
          // The word is not hyphenated. Probably the first word.
          camelCase += word;
        } else {
          // Remove hyphen and uppercase next letter.
          camelCase += StringCase.toUpper(matches.getGroup(2));
          if (matches.getGroupCount() > 2) {
            camelCase += matches.getGroup(3);
          }
        }
      }
      putCamelCaseName(hyphenatedMap, name, camelCase);
    }
View Full Code Here

   public final String getOffsetParseError(int offsetline)
   {
      String error = getParseError();
      String lineRegex = "line (\\d+),";
      RegExp reg = RegExp.compile(lineRegex);
      MatchResult result = reg.exec(error);
      if (result == null || result.getGroupCount() < 2)
         return getParseError();
      else
      {
         Integer newLine = Integer.parseInt(result.getGroup(1)) + offsetline;
         return error.replaceAll(lineRegex,
                                 "line " + newLine.toString() + ",");
      }
   }
View Full Code Here

      {
         // consider the list element indicator (-) to be part of the node's
         // indentation, to prevent list continuations from being treated as
         // sibling nodes
         RegExp whitespace = RegExp.compile("^\\s*-?\\s*");
         MatchResult result = whitespace.exec(yamlLine);
         if (result == null)
            return "";
         else
            return result.getGroup(0);
      }
View Full Code Here

      public List<YamlTreeNode> children = new ArrayList<YamlTreeNode>();
     
      private String getKey(String line)
      {
         RegExp keyReg = RegExp.compile("^\\s*([^:]+):");
         MatchResult result = keyReg.exec(line);
         if (result == null)
            return "";
          else
            return result.getGroup(1);
      }
View Full Code Here

   @Override
   public void onConsoleWriteInput(ConsoleWriteInputEvent event)
   {
      // when a file is sourced, replay all the breakpoints in the file.
      RegExp sourceExp = RegExp.compile("source(.with.encoding)?\\('([^']*)'.*");
      MatchResult fileMatch = sourceExp.exec(event.getInput());
      if (fileMatch == null || fileMatch.getGroupCount() == 0)
      {
         return;
      }     
      String path = FilePathUtils.normalizePath(
            fileMatch.getGroup(2),
            workbench_.getCurrentWorkingDir().getPath());
      resetBreakpointsInPath(path, true);
   }
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.