本文整理汇总了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);
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
示例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());
}
示例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;
}
示例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();
}
示例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();
}