下面列出了java.util.regex.Pattern#equals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private Matcher getMatcher(final Pattern pattern, final String value) throws EdmPrimitiveTypeException {
final Matcher matcher = pattern.matcher(value);
if (!matcher.matches()) {
throw new EdmPrimitiveTypeException("The literal '" + value + "' has illegal content.");
}
Geospatial.Dimension _dimension = null;
Geospatial.Type _type = null;
try {
_dimension = Geospatial.Dimension.valueOf(matcher.group(1).toUpperCase());
_type = Geospatial.Type.valueOf(matcher.group(3).toUpperCase());
} catch (IllegalArgumentException e) {
throw new EdmPrimitiveTypeException("The literal '" + value + "' has illegal content.", e);
}
if (_dimension != this.dimension || (!pattern.equals(COLLECTION_PATTERN) && _type != this.type)) {
throw new EdmPrimitiveTypeException("The literal '" + value + "' has illegal content.");
}
return matcher;
}
@Override
protected Map<String, Integer> getLostFiles(
Pattern pattern, String[] dfsckArgs) throws IOException {
Map<String, Integer> map = new HashMap<String, Integer>();
// Disable CorruptionMonitor
if (pattern.equals(DistBlockIntegrityMonitor.LIST_CORRUPT_FILE_PATTERN)) {
return map;
}
for (String file : TestBlockCopier.decommissioningFiles) {
map.put(file, 1);
}
return map;
}
/**
* Returns a given attribute for an M3U playlist file based on it's parameter.
*
* @param attribute an attribute as found in {@link Constants}
* @param playlistLine a line from a given playlist.
* @return The attribute for that line.
*/
private static String getAttributeFromPlaylistLine(Pattern attribute, String playlistLine) {
Matcher matcher = attribute.matcher(playlistLine);
if (matcher.find()) {
String[] parts = matcher.group().split("=");
String contents = parts[1].replace("\"", "");
/*
It might be possible that the title isn't in the tvg-name tag, retrieve it from the
region after the comma.
*/
if (TextUtils.isEmpty(contents) && attribute.equals(Constants.ATTRIBUTE_TVG_NAME_PATTERN)) {
Pattern commaPattern = Pattern.compile(",.*");
Matcher commaMatcher = commaPattern.matcher(playlistLine);
if (commaMatcher.find()) {
// Don't include the first comma in the title
return (commaMatcher.group().substring(1));
}
}
return (contents);
} else {
return ("");
}
}