当前位置: 首页>>代码示例>>Java>>正文


Java Matcher.matches方法代码示例

本文整理汇总了Java中com.google.re2j.Matcher.matches方法的典型用法代码示例。如果您正苦于以下问题:Java Matcher.matches方法的具体用法?Java Matcher.matches怎么用?Java Matcher.matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.re2j.Matcher的用法示例。


在下文中一共展示了Matcher.matches方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserialize

import com.google.re2j.Matcher; //导入方法依赖的package包/类
@Override
public DeserializedEvent deserialize(String raw) {
  Matcher m = this.pattern.matcher(raw);

  if (!m.matches()) {
    throw new DeserializationException("raw event does not match string");
  }

  int groups = m.groupCount();
  Map<String, Object> mapping = new HashMap<>(groups);
  for (int i = 0; i < groups && i < fields.size(); i++) {
    String str = m.group(i + 1);

    ReFieldConfig field = this.fields.get(i);
    mapping.put(field.getName(), RegexDeserializer.parse(str, field.getType()));
  }

  return new RegexEvent(mapping);
}
 
开发者ID:Nextdoor,项目名称:bender,代码行数:20,代码来源:Re2jRegexDeserializer.java

示例2: lsTree

import com.google.re2j.Matcher; //导入方法依赖的package包/类
ImmutableList<TreeElement> lsTree(GitRevision reference, String treeish) throws RepoException {
  ImmutableList.Builder<TreeElement> result = ImmutableList.builder();
  String stdout = simpleCommand("ls-tree", reference.getSha1(), "--", treeish).getStdout();
  for (String line : Splitter.on('\n').split(stdout)) {
    if (line.isEmpty()) {
      continue;
    }
    Matcher matcher = LS_TREE_ELEMENT.matcher(line);
    if (!matcher.matches()) {
      throw new RepoException("Unexpected format for ls-tree output: " + line);
    }
    // We ignore the mode for now
    GitObjectType objectType = GitObjectType.valueOf(matcher.group(2).toUpperCase());
    String sha1 = matcher.group(3);
    String path = matcher.group(4)
        // Per ls-tree documentation. Replace those escaped characters.
        .replace("\\\\", "\\").replace("\\t", "\t").replace("\\n", "\n");

    result.add(new TreeElement(objectType, sha1, path));
  }
  return result.build();
}
 
开发者ID:google,项目名称:copybara,代码行数:23,代码来源:GitRepository.java

示例3: parse

import com.google.re2j.Matcher; //导入方法依赖的package包/类
@Nullable
static GerritIntegrateLabel parse(String str, GitRepository repository,
    GeneralOptions generalOptions) {
  Matcher matcher = LABEL_PATTERN.matcher(str);
  return matcher.matches()
         ? new GerritIntegrateLabel(repository, generalOptions,
                                    matcher.group(1),
                                    Integer.parseInt(matcher.group(2)),
                                    (matcher.group(3) == null
                                     ? null
                                     : Integer.parseInt(matcher.group(3))),
                                    matcher.group(4))
         : null;
}
 
开发者ID:google,项目名称:copybara,代码行数:15,代码来源:GerritIntegrateLabel.java

示例4: parse

import com.google.re2j.Matcher; //导入方法依赖的package包/类
@Nullable
static GithubPRIntegrateLabel parse(String str, GitRepository repository,
    GeneralOptions generalOptions) {
  Matcher matcher = LABEL_PATTERN.matcher(str);
  return matcher.matches()
         ? new GithubPRIntegrateLabel(repository, generalOptions,
                                      matcher.group(1),
                                      Long.parseLong(matcher.group(2)),
                                      matcher.group(3),
                                      matcher.group(4))
         : null;
}
 
开发者ID:google,项目名称:copybara,代码行数:13,代码来源:GithubPRIntegrateLabel.java

示例5: maybeParseGithubPrFromHeadRef

import com.google.re2j.Matcher; //导入方法依赖的package包/类
/**
 * Given a ref like 'refs/pull/12345/head' returns 12345 or null it not a GitHub PR ref
 */
static Optional<Integer> maybeParseGithubPrFromHeadRef(String ref) {
  Matcher matcher = GITHUB_PULL_REQUEST_REF.matcher(ref);
  return (matcher.matches() && "head".equals(matcher.group(2)))
         ? Optional.of(Integer.parseInt(matcher.group(1)))
         : Optional.empty();
}
 
开发者ID:google,项目名称:copybara,代码行数:10,代码来源:GithubUtil.java

示例6: parse

import com.google.re2j.Matcher; //导入方法依赖的package包/类
/**
 * Parses a Git author {@code string} into an {@link Author}.
 */
public static Author parse(String author) throws InvalidAuthorException {
  Preconditions.checkNotNull(author);
  Matcher matcher = AUTHOR_PATTERN.matcher(author);
  if (!matcher.matches()) {
    throw new InvalidAuthorException(
        String.format("Invalid author '%s'. Must be in the form of 'Name <email>'", author));
  }
  return new Author(matcher.group(1).trim(), matcher.group(2).trim());
}
 
开发者ID:google,项目名称:copybara,代码行数:13,代码来源:AuthorParser.java

示例7: mapUsers

import com.google.re2j.Matcher; //导入方法依赖的package包/类
private List<String> mapUsers(List<String> users, String rawText, Path path, Console console)
    throws ValidationException {
  Set<String> alreadyAdded = new HashSet<>();
  List<String> result = new ArrayList<>();
  for (String rawUser : users) {
    Matcher matcher = SINGLE_USER_PATTERN.matcher(rawUser);
    // Throw VE if the pattern doesn't match and mode is MAP_OR_FAIL
    if (!matcher.matches()) {
      if (mode == Mode.MAP_OR_FAIL) {
        throw new ValidationException(String.format(
            "Unexpected '%s' doesn't match expected format", rawUser));
      } else {
        console.warnFmt("Skipping '%s' that doesn't match expected format", rawUser);
        continue;
      }
    }
    String prefix = matcher.group(1);
    String originUser = matcher.group(2);
    String suffix = matcher.group(3);
    switch (mode) {
      case MAP_OR_FAIL:
        checkCondition(mapping.containsKey(originUser),
            "Cannot find a mapping '%s' in '%s' (%s)", originUser, rawText, path);
        // fall through
      case MAP_OR_IGNORE:
        String destUser = mapping.getOrDefault(originUser, originUser);
        if (alreadyAdded.add(destUser)) {
          result.add(prefix + destUser + suffix);
        }
        break;
      case MAP_OR_DEFAULT:
        destUser = mapping.getOrDefault(originUser, defaultString);
        if (alreadyAdded.add(destUser)) {
          result.add(prefix + destUser + suffix);
        }
        break;
      case SCRUB_NAMES:
        break;
      case USE_DEFAULT:
        if (alreadyAdded.add(defaultString)) {
          result.add(prefix + defaultString + suffix);
        }
        break;
    }
  }
  return result;
}
 
开发者ID:google,项目名称:copybara,代码行数:48,代码来源:TodoReplace.java

示例8: maybeParseGithubPrFromMergeOrHeadRef

import com.google.re2j.Matcher; //导入方法依赖的package包/类
/**
 * Given a ref like 'refs/pull/12345/merge' returns 12345 or null it not a GitHub PR ref
 */
static Optional<Integer> maybeParseGithubPrFromMergeOrHeadRef(String ref) {
  Matcher matcher = GITHUB_PULL_REQUEST_REF.matcher(ref);
  return matcher.matches() ? Optional.of(Integer.parseInt(matcher.group(1))) : Optional.empty();
}
 
开发者ID:google,项目名称:copybara,代码行数:8,代码来源:GithubUtil.java

示例9: maybeParseGithubPrUrl

import com.google.re2j.Matcher; //导入方法依赖的package包/类
static Optional<GithubPrUrl> maybeParseGithubPrUrl(String ref) {
  Matcher matcher = GITHUB_PULL_REQUEST.matcher(ref);
  return matcher.matches()
         ? Optional.of(new GithubPrUrl(matcher.group(1), Integer.parseInt(matcher.group(2))))
         : Optional.empty();
}
 
开发者ID:google,项目名称:copybara,代码行数:7,代码来源:GithubUtil.java


注:本文中的com.google.re2j.Matcher.matches方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。