Skip to content

Commit

Permalink
replace
Browse files Browse the repository at this point in the history
  • Loading branch information
snuyanzin committed Feb 20, 2024
1 parent 4645880 commit 448f500
Show file tree
Hide file tree
Showing 22 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,10 @@ private static Pattern convertNamePattern(@Nullable String pattern) {
String wStr = ".*";
return Pattern.compile(
pattern.replaceAll("([^\\\\])%", "$1" + wStr)
.replaceAll("\\\\%", "%")
.replace("\\\\%", "%")
.replaceAll("^%", wStr)
.replaceAll("([^\\\\])_", "$1.")
.replaceAll("\\\\_", "_")
.replace("\\\\_", "_")
.replaceAll("^_", "."));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ Identifier
fragment
QuotedIdentifier
:
'`' ( '``' | ~('`') )* '`' { setText(getText().substring(1, getText().length() -1 ).replaceAll("``", "`")); }
'`' ( '``' | ~('`') )* '`' { setText(getText().substring(1, getText().length() -1 ).replace("``", "`")); }
;

CharSetName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ private static void verifyWrittenData(List<Row> expected, List<String> results)
Set<String> expectedSet = new HashSet<>();
for (int i = 0; i < results.size(); i++) {
final String rowString = expected.get(i).toString();
expectedSet.add(rowString.substring(3, rowString.length() - 1).replaceAll(", ", "\t"));
expectedSet.add(rowString.substring(3, rowString.length() - 1).replace(", ", "\t"));
}
assertThat(new HashSet<>(results)).isEqualTo(expectedSet);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2013,7 +2013,7 @@ private boolean isValidPojoField(Field f, Class<?> clazz, List<Type> typeHierarc
return true;
} else {
boolean hasGetter = false, hasSetter = false;
final String fieldNameLow = f.getName().toLowerCase().replaceAll("_", "");
final String fieldNameLow = f.getName().toLowerCase().replace("_", "");

Type fieldType = f.getGenericType();
Class<?> fieldTypeWrapper = ClassUtils.primitiveToWrapper(f.getType());
Expand All @@ -2028,9 +2028,9 @@ private boolean isValidPojoField(Field f, Class<?> clazz, List<Type> typeHierarc
m.getName().endsWith("_$eq")
? m.getName()
.toLowerCase()
.replaceAll("_", "")
.replace("_", "")
.replaceFirst("\\$eq$", "_\\$eq")
: m.getName().toLowerCase().replaceAll("_", "");
: m.getName().toLowerCase().replace("_", "");

// check for getter
if ( // The name should be "get<FieldName>" or "<fieldName>" (for scala) or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static String escapeWithSingleQuote(String string, String... charsToEscape) {
|| string.contains("'");

if (escape) {
return "'" + string.replaceAll("'", "''") + "'";
return "'" + string.replace("'", "''") + "'";
}

return string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ protected abstract void formatText(
private static final String TEMPORARY_PLACEHOLDER = "randomPlaceholderForStringFormat";

private static String escapeFormatPlaceholder(String value) {
return value.replaceAll("%s", TEMPORARY_PLACEHOLDER)
.replaceAll("%", "%%")
.replaceAll(TEMPORARY_PLACEHOLDER, "%s");
return value.replace("%s", TEMPORARY_PLACEHOLDER)
.replace("%", "%%")
.replace(TEMPORARY_PLACEHOLDER, "%s");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static List<Class<?>> discoverOptionsAndApply(
throws IOException, ClassNotFoundException {

Path configDir =
rootDir.resolve(Paths.get(module, pathPrefix, packageName.replaceAll("\\.", "/")));
rootDir.resolve(Paths.get(module, pathPrefix, packageName.replace(".", "/")));

List<Class<?>> optionClasses = new ArrayList<>();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(configDir)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public enum Utils {
private static final String TEMPORARY_PLACEHOLDER = "superRandomTemporaryPlaceholder";

public static String escapeCharacters(String value) {
return value.replaceAll("<wbr>", TEMPORARY_PLACEHOLDER)
.replaceAll("<", "&lt;")
.replaceAll(">", "&gt;")
.replaceAll(TEMPORARY_PLACEHOLDER, "<wbr>");
return value.replace("<wbr>", TEMPORARY_PLACEHOLDER)
.replace("<", "&lt;")
.replace(">", "&gt;")
.replace(TEMPORARY_PLACEHOLDER, "<wbr>");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static void main(String[] args) throws IOException {
failed =
!expected[i]
.trim()
.equals(actual[i].replaceAll("\"", "").trim());
.equals(actual[i].replace("\"", "").trim());
}
}
if (failed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* #invert()}, the direction may change accordingly. To generalize, the left side is called source
* and the right side is called target(s) in this class.
*
* <p>{@ImplNote This class omits trailing empty targets.}
* <p>{@implNote This class omits trailing empty targets.}
*/
public class RescaleMappings implements Serializable {
public static final RescaleMappings SYMMETRIC_IDENTITY =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ static Pattern convertToPattern(String scopeOrNameComponent) {

final String rawPattern =
Arrays.stream(split)
.map(s -> s.replaceAll("\\.", "\\."))
.map(s -> s.replaceAll("\\*", ".*"))
.map(s -> s.replace(".", "\\."))
.map(s -> s.replace("*", ".*"))
.collect(Collectors.joining("|", "(", ")"));

return Pattern.compile(rawPattern);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ protected void channelRead0(ChannelHandlerContext ctx, RoutedRequest<Object> rou

@VisibleForTesting
static String generateLogUrl(String pattern, String jobId, String taskManagerId) {
String generatedUrl = pattern.replaceAll("<jobid>", jobId);
String generatedUrl = pattern.replace("<jobid>", jobId);
if (null != taskManagerId) {
generatedUrl = generatedUrl.replaceAll("<tmid>", taskManagerId);
generatedUrl = generatedUrl.replace("<tmid>", taskManagerId);
}
return generatedUrl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private static long getSizeOfPhysicalMemoryForWindows() {
continue;
}

line = line.replaceAll(" ", "");
line = line.replace(" ", "");
sizeOfPhyiscalMemory += Long.parseLong(line);
}
return sizeOfPhyiscalMemory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public RocksDBSnapshotStrategyBase(
this.localRecoveryConfig = localRecoveryConfig;
this.description = description;
this.instanceBasePath = instanceBasePath;
this.localDirectoryName = backendUID.toString().replaceAll("[\\-]", "");
this.localDirectoryName = backendUID.toString().replace("-", "");
this.backendUID = backendUID;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class SqlClientSyntaxHighlighter extends DefaultHighlighter {
private static final Set<String> KEYWORDS =
Collections.unmodifiableSet(
Arrays.stream(FlinkSqlParserImplConstants.tokenImage)
.map(t -> t.replaceAll("\"", ""))
.map(t -> t.replace("\"", ""))
.collect(Collectors.toSet()));

private final Executor executor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public String asSerializableString() {
"SELECT %s FROM (%s\n) %s JOIN %s ON %s",
OperationUtils.formatSelectColumns(resolvedSchema),
OperationUtils.indent(left.asSerializableString()),
joinType.toString().replaceAll("_", " "),
joinType.toString().replace("_", " "),
rightToSerializable(),
condition.asSerializableString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static String indent(String item) {
if (group.startsWith("'")) {
matcher.appendReplacement(output, Matcher.quoteReplacement(group));
} else {
String replaced = group.replaceAll("\n", "\n" + OPERATION_INDENT);
String replaced = group.replace("\n", "\n" + OPERATION_INDENT);
matcher.appendReplacement(output, Matcher.quoteReplacement(replaced));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class JsonFunctionsCallSyntax {
operands.get(0).asSerializableString(),
operands.get(1).asSerializableString(),
toString(wrapper),
onEmpty.toString().replaceAll("_", " "),
onError.toString().replaceAll("_", " "));
onEmpty.toString().replace("_", " "),
onError.toString().replace("_", " "));
};

static final SqlCallSyntax JSON_OBJECT =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class IndentStringContext(sc: StringContext) {

val ind = getindent(s)
if (ind.nonEmpty) {
sb.append(a.toString.replaceAll("\n", "\n" + ind))
sb.append(a.toString.replace("\n", "\n" + ind))
} else {
sb.append(a.toString)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object LogicalPlanFormatUtils {
private val tempPattern = """TMP_\d+""".r

def formatTempTableId(preStr: String): String = {
val str = preStr.replaceAll("ArrayBuffer\\(", "List\\(")
val str = preStr.replace("ArrayBuffer(", "List(")
val minId = getMinTempTableId(str)
tempPattern.replaceAllIn(str, s => "TMP_" + (s.matched.substring(4).toInt - minId))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ abstract class TableTestUtilBase(test: TableTestBase, isStreamingMode: Boolean)
// add the postfix to the path to avoid conflicts
// between the test class name and the result file name
val clazz = test.getClass
val testClassDirPath = clazz.getName.replaceAll("\\.", "/") + "_jsonplan"
val testClassDirPath = clazz.getName.replace(".", "/") + "_jsonplan"
val testMethodFileName = test.methodName + ".out"
val resourceTestFilePath = s"/$testClassDirPath/$testMethodFileName"
val plannerDirPath = clazz.getResource("/").getFile.replace("/target/test-classes/", "")
Expand Down Expand Up @@ -1165,7 +1165,7 @@ abstract class TableTestUtilBase(test: TableTestBase, isStreamingMode: Boolean)

/** Replace the estimated costs for the given plan, because it may be unstable. */
protected def replaceEstimatedCost(s: String): String = {
var str = s.replaceAll("\\r\\n", "\n")
var str = s.replace("\r\n", "\n")
val scientificFormRegExpr = "[+-]?[\\d]+([\\.][\\d]*)?([Ee][+-]?[0-9]{0,2})?"
str = str.replaceAll(s"rowcount = $scientificFormRegExpr", "rowcount = ")
str = str.replaceAll(s"$scientificFormRegExpr rows", "rows")
Expand Down Expand Up @@ -1813,7 +1813,7 @@ object TableTestUtil {
* StreamExecutionEnvironment is up
*/
def replaceStageId(s: String): String = {
s.replaceAll("\\r\\n", "\n").replaceAll("Stage \\d+", "")
s.replace("\r\n", "\n").replaceAll("Stage \\d+", "")
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private static Collection<Pattern> asPatterns(String... texts) {

private static Pattern asPatternWithPotentialLineBreaks(String text) {
// allows word sequences to be separated by whitespace, line-breaks and comments(//, #)
return Pattern.compile(text.toLowerCase(Locale.ROOT).replaceAll(" ", " ?\\\\R?[\\\\s/#]*"));
return Pattern.compile(text.toLowerCase(Locale.ROOT).replace(" ", " ?\\\\R?[\\\\s/#]*"));
}

private static int findNonBinaryFilesContainingText(
Expand Down

0 comments on commit 448f500

Please sign in to comment.