You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/08/24 15:15:04 UTC
[commons-exec] 04/07: Remove extra parens
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-exec.git
commit ba5b69ebee3f8615e0b73b13166e41a5bbe0a50d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Aug 24 11:07:59 2022 -0400
Remove extra parens
No need to nest, format
---
.../org/apache/commons/exec/util/StringUtils.java | 90 +++++++++++-----------
1 file changed, 43 insertions(+), 47 deletions(-)
diff --git a/src/main/java/org/apache/commons/exec/util/StringUtils.java b/src/main/java/org/apache/commons/exec/util/StringUtils.java
index 46e78e7..9f2afe8 100644
--- a/src/main/java/org/apache/commons/exec/util/StringUtils.java
+++ b/src/main/java/org/apache/commons/exec/util/StringUtils.java
@@ -87,65 +87,61 @@ public class StringUtils {
switch (ch) {
- case '$':
- final StringBuilder nameBuf = new StringBuilder();
- del = argStr.charAt(cIdx + 1);
- if (del == '{') {
- cIdx++;
-
- for (++cIdx; cIdx < argStr.length(); ++cIdx) {
- ch = argStr.charAt(cIdx);
- if ((ch != '_') && (ch != '.') && (ch != '-') && (ch != '+') && !Character.isLetterOrDigit(ch)) {
- break;
- }
- nameBuf.append(ch);
+ case '$':
+ final StringBuilder nameBuf = new StringBuilder();
+ del = argStr.charAt(cIdx + 1);
+ if (del == '{') {
+ cIdx++;
+
+ for (++cIdx; cIdx < argStr.length(); ++cIdx) {
+ ch = argStr.charAt(cIdx);
+ if (ch != '_' && ch != '.' && ch != '-' && ch != '+' && !Character.isLetterOrDigit(ch)) {
+ break;
}
+ nameBuf.append(ch);
+ }
- if (nameBuf.length() >= 0) {
+ if (nameBuf.length() >= 0) {
- String value;
- final Object temp = vars.get(nameBuf.toString());
+ String value;
+ final Object temp = vars.get(nameBuf.toString());
- if (temp instanceof File) {
- // for a file we have to fix the separator chars to allow
- // cross-platform compatibility
- value = fixFileSeparatorChar(((File) temp).getAbsolutePath());
- }
- else {
- value = temp != null ? temp.toString() : null;
- }
+ if (temp instanceof File) {
+ // for a file we have to fix the separator chars to allow
+ // cross-platform compatibility
+ value = fixFileSeparatorChar(((File) temp).getAbsolutePath());
+ } else {
+ value = temp != null ? temp.toString() : null;
+ }
- if (value != null) {
- argBuf.append(value);
- } else {
- if (!isLenient) {
- // complain that no variable was found
- throw new RuntimeException("No value found for : " + nameBuf);
- }
- // just append the unresolved variable declaration
- argBuf.append("${").append(nameBuf.toString()).append("}");
+ if (value != null) {
+ argBuf.append(value);
+ } else {
+ if (!isLenient) {
+ // complain that no variable was found
+ throw new RuntimeException("No value found for : " + nameBuf);
}
+ // just append the unresolved variable declaration
+ argBuf.append("${").append(nameBuf.toString()).append("}");
+ }
- del = argStr.charAt(cIdx);
+ del = argStr.charAt(cIdx);
- if (del != '}') {
- throw new RuntimeException("Delimiter not found for : " + nameBuf);
- }
+ if (del != '}') {
+ throw new RuntimeException("Delimiter not found for : " + nameBuf);
}
-
- cIdx++;
- }
- else {
- argBuf.append(ch);
- ++cIdx;
}
+ } else {
+ argBuf.append(ch);
+ }
+ cIdx++;
- break;
+ break;
- default:
- argBuf.append(ch);
- ++cIdx;
- break;
+ default:
+ argBuf.append(ch);
+ ++cIdx;
+ break;
}
}