summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorGintas Grigelionis <gintas@apache.org>2018-04-06 14:50:56 +0200
committerGintas Grigelionis <gintas@apache.org>2018-04-06 14:50:56 +0200
commit30f52135af7a18cbf3f140089e90bdb39ceee134 (patch)
treee88e72ed458417ab1009e000fb09f49449ac49ec /src/main
parentcda6c91cf800ba7be7fb479ce8e3264c7ca7c232 (diff)
downloadant-30f52135af7a18cbf3f140089e90bdb39ceee134.tar.gz
Use null-or-empty pattern
Diffstat (limited to 'src/main')
-rw-r--r--src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java2
-rw-r--r--src/main/org/apache/tools/ant/ComponentHelper.java2
-rw-r--r--src/main/org/apache/tools/ant/DirectoryScanner.java5
-rw-r--r--src/main/org/apache/tools/ant/IntrospectionHelper.java11
-rw-r--r--src/main/org/apache/tools/ant/Main.java2
-rw-r--r--src/main/org/apache/tools/ant/NoBannerLogger.java2
-rw-r--r--src/main/org/apache/tools/ant/ProjectHelper.java2
-rw-r--r--src/main/org/apache/tools/ant/ProjectHelperRepository.java2
-rw-r--r--src/main/org/apache/tools/ant/RuntimeConfigurable.java2
-rw-r--r--src/main/org/apache/tools/ant/XmlLogger.java2
-rw-r--r--src/main/org/apache/tools/ant/filters/ClassConstants.java6
-rw-r--r--src/main/org/apache/tools/ant/filters/HeadFilter.java2
-rw-r--r--src/main/org/apache/tools/ant/filters/PrefixLines.java4
-rw-r--r--src/main/org/apache/tools/ant/filters/ReplaceTokens.java12
-rw-r--r--src/main/org/apache/tools/ant/filters/SuffixLines.java16
-rw-r--r--src/main/org/apache/tools/ant/filters/TailFilter.java2
-rw-r--r--src/main/org/apache/tools/ant/filters/TokenFilter.java16
-rw-r--r--src/main/org/apache/tools/ant/helper/ProjectHelper2.java8
-rw-r--r--src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java4
-rw-r--r--src/main/org/apache/tools/ant/listener/MailLogger.java12
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Ant.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Exit.java10
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Get.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Javadoc.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/KeySubst.java4
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/MacroDef.java6
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/MatchingTask.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/SubAnt.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Tar.java8
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Tstamp.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/XmlProperty.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Zip.java4
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java14
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java20
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java4
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultJspCompilerAdapter.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java4
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnit4TestMethodAdapter.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java4
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java4
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java25
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java4
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java12
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java8
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java4
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java6
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java4
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java2
-rw-r--r--src/main/org/apache/tools/ant/types/ArchiveScanner.java2
-rw-r--r--src/main/org/apache/tools/ant/types/Commandline.java7
-rw-r--r--src/main/org/apache/tools/ant/types/CommandlineJava.java4
-rw-r--r--src/main/org/apache/tools/ant/types/FilterSet.java4
-rw-r--r--src/main/org/apache/tools/ant/types/resources/MultiRootFileSet.java5
-rw-r--r--src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java2
-rw-r--r--src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java5
-rw-r--r--src/main/org/apache/tools/ant/types/spi/Service.java2
-rw-r--r--src/main/org/apache/tools/ant/util/DOMElementWriter.java4
-rw-r--r--src/main/org/apache/tools/ant/util/DeweyDecimal.java2
-rw-r--r--src/main/org/apache/tools/ant/util/FileUtils.java6
-rw-r--r--src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java2
-rw-r--r--src/main/org/apache/tools/ant/util/ResourceUtils.java2
-rw-r--r--src/main/org/apache/tools/tar/TarEntry.java2
-rw-r--r--src/main/org/apache/tools/tar/TarOutputStream.java2
-rw-r--r--src/main/org/apache/tools/zip/AsiExtraField.java2
74 files changed, 167 insertions, 185 deletions
diff --git a/src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java b/src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java
index ae6bf81cd..29f8edf53 100644
--- a/src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java
+++ b/src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java
@@ -157,7 +157,7 @@ public class ArgumentProcessorRegistry {
}
BufferedReader rd = new BufferedReader(isr);
String processorClassName = rd.readLine();
- if (processorClassName != null && !"".equals(processorClassName)) {
+ if (processorClassName != null && !processorClassName.isEmpty()) {
return getProcessor(processorClassName);
}
} finally {
diff --git a/src/main/org/apache/tools/ant/ComponentHelper.java b/src/main/org/apache/tools/ant/ComponentHelper.java
index 96e28bcb1..ae3bdea85 100644
--- a/src/main/org/apache/tools/ant/ComponentHelper.java
+++ b/src/main/org/apache/tools/ant/ComponentHelper.java
@@ -1018,7 +1018,7 @@ public class ComponentHelper {
out.println("Action: Check that any custom tasks/types have been declared.");
out.println("Action: Check that any <presetdef>/<macrodef>"
+ " declarations have taken place.");
- if (uri.length() > 0) {
+ if (!uri.isEmpty()) {
final List<AntTypeDefinition> matches = findTypeMatches(uri);
if (matches.isEmpty()) {
out.println("No types or tasks have been defined in this namespace yet");
diff --git a/src/main/org/apache/tools/ant/DirectoryScanner.java b/src/main/org/apache/tools/ant/DirectoryScanner.java
index 967c9ca7a..fd48d127a 100644
--- a/src/main/org/apache/tools/ant/DirectoryScanner.java
+++ b/src/main/org/apache/tools/ant/DirectoryScanner.java
@@ -1016,8 +1016,7 @@ public class DirectoryScanner
continue;
}
if (myfile.isDirectory()) {
- if (isIncluded(currentPath)
- && currentelement.length() > 0) {
+ if (isIncluded(currentPath) && !currentelement.isEmpty()) {
accountForIncludedDir(currentPath, myfile, true);
} else {
scandir(myfile, currentPath, true);
@@ -1200,7 +1199,7 @@ public class DirectoryScanner
private void scandir(final File dir, final TokenizedPath path, final boolean fast,
String[] newFiles, final Deque<String> directoryNamesFollowed) {
String vpath = path.toString();
- if (vpath.length() > 0 && !vpath.endsWith(File.separator)) {
+ if (!vpath.isEmpty() && !vpath.endsWith(File.separator)) {
vpath += File.separator;
}
diff --git a/src/main/org/apache/tools/ant/IntrospectionHelper.java b/src/main/org/apache/tools/ant/IntrospectionHelper.java
index 76cfa8c48..7ab77bad6 100644
--- a/src/main/org/apache/tools/ant/IntrospectionHelper.java
+++ b/src/main/org/apache/tools/ant/IntrospectionHelper.java
@@ -458,7 +458,7 @@ public final class IntrospectionHelper {
if (addText == null) {
text = text.trim();
// Element doesn't handle text content
- if (text.length() == 0) {
+ if (text.isEmpty()) {
// Only whitespace - ignore
return;
}
@@ -530,7 +530,7 @@ public final class IntrospectionHelper {
parentUri = "";
}
NestedCreator nc = null;
- if (uri.equals(parentUri) || uri.length() == 0) {
+ if (uri.equals(parentUri) || uri.isEmpty()) {
nc = nestedCreators.get(name.toLowerCase(Locale.ENGLISH));
}
if (nc == null) {
@@ -741,10 +741,7 @@ public final class IntrospectionHelper {
return false;
}
String uri = ProjectHelper.extractUriFromComponentName(elementName);
- if (uri.equals(ProjectHelper.ANT_CORE_URI)) {
- uri = "";
- }
- if ("".equals(uri)) {
+ if (uri.equals(ProjectHelper.ANT_CORE_URI) || uri.isEmpty()) {
return true;
}
if (parentUri.equals(ProjectHelper.ANT_CORE_URI)) {
@@ -1058,7 +1055,7 @@ public final class IntrospectionHelper {
@Override
public void set(final Project p, final Object parent, final String value)
throws InvocationTargetException, IllegalAccessException {
- if (value.length() == 0) {
+ if (value.isEmpty()) {
throw new BuildException("The value \"\" is not a "
+ "legal value for attribute \"" + attrName + "\"");
}
diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java
index 242e432f3..cfe35853f 100644
--- a/src/main/org/apache/tools/ant/Main.java
+++ b/src/main/org/apache/tools/ant/Main.java
@@ -1217,7 +1217,7 @@ public class Main implements AntMain {
}
final String defaultTarget = project.getDefaultTarget();
- if (defaultTarget != null && !"".equals(defaultTarget)) {
+ if (defaultTarget != null && defaultTarget.isEmpty()) {
// shouldn't need to check but...
project.log("Default target: " + defaultTarget);
}
diff --git a/src/main/org/apache/tools/ant/NoBannerLogger.java b/src/main/org/apache/tools/ant/NoBannerLogger.java
index a086bf5e0..4b1e498e2 100644
--- a/src/main/org/apache/tools/ant/NoBannerLogger.java
+++ b/src/main/org/apache/tools/ant/NoBannerLogger.java
@@ -84,7 +84,7 @@ public class NoBannerLogger extends DefaultLogger {
if (event.getPriority() > msgOutputLevel
|| null == event.getMessage()
- || "".equals(event.getMessage().trim())) {
+ || event.getMessage().trim().isEmpty()) {
return;
}
diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java
index 64a2ea5df..10e528d0f 100644
--- a/src/main/org/apache/tools/ant/ProjectHelper.java
+++ b/src/main/org/apache/tools/ant/ProjectHelper.java
@@ -494,7 +494,7 @@ public class ProjectHelper {
* @return The stringified form of the ns name
*/
public static String genComponentName(String uri, String name) {
- if (uri == null || "".equals(uri) || uri.equals(ANT_CORE_URI)) {
+ if (uri == null || uri.isEmpty() || uri.equals(ANT_CORE_URI)) {
return name;
}
return uri + ":" + name;
diff --git a/src/main/org/apache/tools/ant/ProjectHelperRepository.java b/src/main/org/apache/tools/ant/ProjectHelperRepository.java
index cd2e7dbbb..74a1bf7d7 100644
--- a/src/main/org/apache/tools/ant/ProjectHelperRepository.java
+++ b/src/main/org/apache/tools/ant/ProjectHelperRepository.java
@@ -197,7 +197,7 @@ public class ProjectHelperRepository {
String helperClassName = rd.readLine();
rd.close();
- if (helperClassName != null && !"".equals(helperClassName)) {
+ if (helperClassName != null && !helperClassName.isEmpty()) {
return getHelperConstructor(helperClassName);
}
} catch (Exception e) {
diff --git a/src/main/org/apache/tools/ant/RuntimeConfigurable.java b/src/main/org/apache/tools/ant/RuntimeConfigurable.java
index 107464d2b..7afd82bed 100644
--- a/src/main/org/apache/tools/ant/RuntimeConfigurable.java
+++ b/src/main/org/apache/tools/ant/RuntimeConfigurable.java
@@ -391,7 +391,7 @@ public class RuntimeConfigurable implements Serializable {
* Should not be <code>null</code>.
*/
public synchronized void addText(String data) {
- if (data.length() == 0) {
+ if (data.isEmpty()) {
return;
}
characters = (characters == null)
diff --git a/src/main/org/apache/tools/ant/XmlLogger.java b/src/main/org/apache/tools/ant/XmlLogger.java
index 5fa978e58..edf413be9 100644
--- a/src/main/org/apache/tools/ant/XmlLogger.java
+++ b/src/main/org/apache/tools/ant/XmlLogger.java
@@ -182,7 +182,7 @@ public class XmlLogger implements BuildLogger {
outStream == null ? Files.newOutputStream(Paths.get(outFilename)) : outStream;
Writer out = new OutputStreamWriter(stream, "UTF8")) {
out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- if (xslUri.length() > 0) {
+ if (!xslUri.isEmpty()) {
out.write("<?xml-stylesheet type=\"text/xsl\" href=\"" + xslUri
+ "\"?>\n\n");
}
diff --git a/src/main/org/apache/tools/ant/filters/ClassConstants.java b/src/main/org/apache/tools/ant/filters/ClassConstants.java
index b9d7b7ff9..70dd02abf 100644
--- a/src/main/org/apache/tools/ant/filters/ClassConstants.java
+++ b/src/main/org/apache/tools/ant/filters/ClassConstants.java
@@ -88,13 +88,13 @@ public final class ClassConstants
public int read() throws IOException {
int ch = -1;
- if (queuedData != null && queuedData.length() == 0) {
+ if (queuedData != null && queuedData.isEmpty()) {
queuedData = null;
}
if (queuedData == null) {
final String clazz = readFully();
- if (clazz == null || clazz.length() == 0) {
+ if (clazz == null || clazz.isEmpty()) {
ch = -1;
} else {
final byte[] bytes = clazz.getBytes(ResourceUtils.ISO_8859_1);
@@ -130,7 +130,7 @@ public final class ClassConstants
} else {
ch = queuedData.charAt(0);
queuedData = queuedData.substring(1);
- if (queuedData.length() == 0) {
+ if (queuedData.isEmpty()) {
queuedData = null;
}
}
diff --git a/src/main/org/apache/tools/ant/filters/HeadFilter.java b/src/main/org/apache/tools/ant/filters/HeadFilter.java
index 24e240322..3ac59b72f 100644
--- a/src/main/org/apache/tools/ant/filters/HeadFilter.java
+++ b/src/main/org/apache/tools/ant/filters/HeadFilter.java
@@ -105,7 +105,7 @@ public final class HeadFilter extends BaseParamFilterReader
setInitialized(true);
}
- while (line == null || line.length() == 0) {
+ while (line == null || line.isEmpty()) {
line = lineTokenizer.getToken(in);
if (line == null) {
return -1;
diff --git a/src/main/org/apache/tools/ant/filters/PrefixLines.java b/src/main/org/apache/tools/ant/filters/PrefixLines.java
index e125aa326..4ce17a680 100644
--- a/src/main/org/apache/tools/ant/filters/PrefixLines.java
+++ b/src/main/org/apache/tools/ant/filters/PrefixLines.java
@@ -86,14 +86,14 @@ public final class PrefixLines
int ch = -1;
- if (queuedData != null && queuedData.length() == 0) {
+ if (queuedData != null && queuedData.isEmpty()) {
queuedData = null;
}
if (queuedData != null) {
ch = queuedData.charAt(0);
queuedData = queuedData.substring(1);
- if (queuedData.length() == 0) {
+ if (queuedData.isEmpty()) {
queuedData = null;
}
} else {
diff --git a/src/main/org/apache/tools/ant/filters/ReplaceTokens.java b/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
index 9f1305255..0a9c08bbc 100644
--- a/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
+++ b/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
@@ -134,7 +134,7 @@ public final class ReplaceTokens
}
// is the read buffer empty?
- if (readBuffer.length() == 0) {
+ if (readBuffer.isEmpty()) {
int next = in.read();
if (next == -1) {
return next; // end of stream. all buffers empty.
@@ -169,13 +169,13 @@ public final class ReplaceTokens
* @return the first character from the read buffer or -1 if read buffer is empty.
*/
private int getFirstCharacterFromReadBuffer() {
- if (readBuffer.length() > 0) {
- int chr = readBuffer.charAt(0);
- readBuffer = readBuffer.substring(1);
- return chr;
- } else {
+ if (readBuffer.isEmpty()) {
return -1;
}
+
+ int chr = readBuffer.charAt(0);
+ readBuffer = readBuffer.substring(1);
+ return chr;
}
/**
diff --git a/src/main/org/apache/tools/ant/filters/SuffixLines.java b/src/main/org/apache/tools/ant/filters/SuffixLines.java
index 9c22d2b1b..2da7053c2 100644
--- a/src/main/org/apache/tools/ant/filters/SuffixLines.java
+++ b/src/main/org/apache/tools/ant/filters/SuffixLines.java
@@ -87,17 +87,11 @@ public final class SuffixLines
int ch = -1;
- if (queuedData != null && queuedData.length() == 0) {
+ if (queuedData != null && queuedData.isEmpty()) {
queuedData = null;
}
- if (queuedData != null) {
- ch = queuedData.charAt(0);
- queuedData = queuedData.substring(1);
- if (queuedData.length() == 0) {
- queuedData = null;
- }
- } else {
+ if (queuedData == null) {
queuedData = readLine();
if (queuedData == null) {
ch = -1;
@@ -116,6 +110,12 @@ public final class SuffixLines
}
return read();
}
+ } else {
+ ch = queuedData.charAt(0);
+ queuedData = queuedData.substring(1);
+ if (queuedData.isEmpty()) {
+ queuedData = null;
+ }
}
return ch;
}
diff --git a/src/main/org/apache/tools/ant/filters/TailFilter.java b/src/main/org/apache/tools/ant/filters/TailFilter.java
index 7cad43e0c..fc49a3593 100644
--- a/src/main/org/apache/tools/ant/filters/TailFilter.java
+++ b/src/main/org/apache/tools/ant/filters/TailFilter.java
@@ -108,7 +108,7 @@ public final class TailFilter extends BaseParamFilterReader
setInitialized(true);
}
- while (line == null || line.length() == 0) {
+ while (line == null || line.isEmpty()) {
line = lineTokenizer.getToken(in);
line = tailFilter(line);
if (line == null) {
diff --git a/src/main/org/apache/tools/ant/filters/TokenFilter.java b/src/main/org/apache/tools/ant/filters/TokenFilter.java
index a545147dc..38ab9ecb9 100644
--- a/src/main/org/apache/tools/ant/filters/TokenFilter.java
+++ b/src/main/org/apache/tools/ant/filters/TokenFilter.java
@@ -105,7 +105,7 @@ public class TokenFilter extends BaseFilterReader
if (tokenizer == null) {
tokenizer = new LineTokenizer();
}
- while (line == null || line.length() == 0) {
+ while (line == null || line.isEmpty()) {
line = tokenizer.getToken(in);
if (line == null) {
return -1;
@@ -117,13 +117,11 @@ public class TokenFilter extends BaseFilterReader
}
}
linePos = 0;
- if (line != null) {
- if (tokenizer.getPostToken().length() != 0) {
- if (delimOutput != null) {
- line += delimOutput;
- } else {
- line += tokenizer.getPostToken();
- }
+ if (line != null && !tokenizer.getPostToken().isEmpty()) {
+ if (delimOutput != null) {
+ line += delimOutput;
+ } else {
+ line += tokenizer.getPostToken();
}
}
}
@@ -593,7 +591,7 @@ public class TokenFilter extends BaseFilterReader
* @return the trimmed line
*/
public String filter(String line) {
- if (line.trim().length() == 0) {
+ if (line.trim().isEmpty()) {
return null;
}
return line;
diff --git a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
index 14e42aad5..b88846e7c 100644
--- a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
+++ b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
@@ -467,7 +467,7 @@ public class ProjectHelper2 extends ProjectHelper {
throws SAXParseException {
String s = new String(buf, start, count).trim();
- if (s.length() > 0) {
+ if (!s.isEmpty()) {
throw new SAXParseException("Unexpected text \"" + s + "\"", context.getLocator());
}
}
@@ -984,7 +984,7 @@ public class ProjectHelper2 extends ProjectHelper {
target.getLocation());
}
Hashtable<String, Target> projectTargets = project.getTargets();
- boolean usedTarget = false;
+ boolean usedTarget = false;
// If the name has not already been defined define it
if (projectTargets.containsKey(name)) {
project.log("Already defined in main or a previous import, ignore " + name,
@@ -996,7 +996,7 @@ public class ProjectHelper2 extends ProjectHelper {
usedTarget = true;
}
- if (depends.length() > 0) {
+ if (!depends.isEmpty()) {
if (!isInIncludeMode) {
target.setDepends(depends);
} else {
@@ -1052,7 +1052,7 @@ public class ProjectHelper2 extends ProjectHelper {
private String getTargetPrefix(AntXMLContext context) {
String configuredValue = getCurrentTargetPrefix();
- if (configuredValue != null && configuredValue.length() == 0) {
+ if (configuredValue != null && configuredValue.isEmpty()) {
configuredValue = null;
}
if (configuredValue != null) {
diff --git a/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java b/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
index 06d985422..8f0d13dd3 100644
--- a/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
+++ b/src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java
@@ -246,7 +246,7 @@ public class ProjectHelperImpl extends ProjectHelper {
public void characters(char[] buf, int start, int count) throws SAXParseException {
String s = new String(buf, start, count).trim();
- if (s.length() > 0) {
+ if (!s.isEmpty()) {
throw new SAXParseException("Unexpected text \"" + s + "\"", helperImpl.locator);
}
}
@@ -579,7 +579,7 @@ public class ProjectHelperImpl extends ProjectHelper {
// take care of dependencies
- if (depends.length() > 0) {
+ if (!depends.isEmpty()) {
target.setDepends(depends);
}
}
diff --git a/src/main/org/apache/tools/ant/listener/MailLogger.java b/src/main/org/apache/tools/ant/listener/MailLogger.java
index 58f110e8a..23f2baaa3 100644
--- a/src/main/org/apache/tools/ant/listener/MailLogger.java
+++ b/src/main/org/apache/tools/ant/listener/MailLogger.java
@@ -370,15 +370,15 @@ public class MailLogger extends DefaultLogger {
mailMessage.setSubject(values.subject());
- if (values.charset().length() > 0) {
+ if (values.charset().isEmpty()) {
+ mailMessage.setHeader("Content-Type", values.mimeType());
+ } else {
mailMessage.setHeader("Content-Type", values.mimeType()
+ "; charset=\"" + values.charset() + "\"");
- } else {
- mailMessage.setHeader("Content-Type", values.mimeType());
}
PrintStream ps = mailMessage.getPrintStream();
- ps.println(values.body().length() > 0 ? values.body() : message);
+ ps.println(values.body().isEmpty() ? message : values.body());
mailMessage.sendAndClose();
}
@@ -408,10 +408,10 @@ public class MailLogger extends DefaultLogger {
mailer.setSSL(values.ssl());
mailer.setEnableStartTLS(values.starttls());
Message mymessage =
- new Message(values.body().length() > 0 ? values.body() : message);
+ new Message(!values.body().isEmpty() ? values.body() : message);
mymessage.setProject(project);
mymessage.setMimeType(values.mimeType());
- if (values.charset().length() > 0) {
+ if (!values.charset().isEmpty()) {
mymessage.setCharset(values.charset());
}
mailer.setMessage(mymessage);
diff --git a/src/main/org/apache/tools/ant/taskdefs/Ant.java b/src/main/org/apache/tools/ant/taskdefs/Ant.java
index 0f68c800d..5c7bce50a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Ant.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Ant.java
@@ -488,7 +488,7 @@ public class Ant extends Task {
Set<String> set = new HashSet<>();
for (int i = properties.size() - 1; i >= 0; --i) {
Property p = properties.get(i);
- if (p.getName() != null && !"".equals(p.getName())) {
+ if (p.getName() != null && !p.getName().isEmpty()) {
if (set.contains(p.getName())) {
properties.remove(i);
} else {
diff --git a/src/main/org/apache/tools/ant/taskdefs/Exit.java b/src/main/org/apache/tools/ant/taskdefs/Exit.java
index d803d0b04..c55c58462 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Exit.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Exit.java
@@ -141,12 +141,10 @@ public class Exit extends Task {
if (message != null && !message.trim().isEmpty()) {
text = message.trim();
} else {
- if (ifCondition != null && !"".equals(ifCondition)
- && testIfCondition()) {
+ if (!isNullOrEmpty(ifCondition) && testIfCondition()) {
text = "if=" + ifCondition;
}
- if (unlessCondition != null && !"".equals(unlessCondition)
- && testUnlessCondition()) {
+ if (!isNullOrEmpty(unlessCondition) && testUnlessCondition()) {
if (text == null) {
text = "";
} else {
@@ -166,6 +164,10 @@ public class Exit extends Task {
}
}
+ private boolean isNullOrEmpty(Object value) {
+ return value == null || "".equals(value);
+ }
+
/**
* Set a multiline message.
* @param msg the message to display
diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java
index af81a0cf2..077f7eb4d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Get.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Get.java
@@ -273,7 +273,7 @@ public class Get extends Task {
*/
private void checkAttributes() {
- if (userAgent == null || userAgent.trim().length() == 0) {
+ if (userAgent == null || userAgent.trim().isEmpty()) {
throw new BuildException("userAgent may not be null or empty");
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
index e1e413e71..4fc053e0a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
@@ -1055,7 +1055,7 @@ public class Javadoc extends Task {
final String linkOfflineError = "The linkoffline attribute must include"
+ " a URL and a package-list file location separated by a"
+ " space";
- if (src.trim().length() == 0) {
+ if (src.trim().isEmpty()) {
throw new BuildException(linkOfflineError);
}
final StringTokenizer tok = new StringTokenizer(src, " ", false);
diff --git a/src/main/org/apache/tools/ant/taskdefs/KeySubst.java b/src/main/org/apache/tools/ant/taskdefs/KeySubst.java
index cd34394ca..76508dcb9 100644
--- a/src/main/org/apache/tools/ant/taskdefs/KeySubst.java
+++ b/src/main/org/apache/tools/ant/taskdefs/KeySubst.java
@@ -72,7 +72,7 @@ public class KeySubst extends Task {
String newline = null;
line = br.readLine();
while (line != null) {
- if (line.length() == 0) {
+ if (line.isEmpty()) {
bw.newLine();
} else {
newline = KeySubst.replace(line, replacements);
@@ -128,7 +128,7 @@ public class KeySubst extends Task {
* @param keys a <code>String</code> value
*/
public void setKeys(String keys) {
- if (keys != null && keys.length() > 0) {
+ if (keys != null && !keys.isEmpty()) {
StringTokenizer tok =
new StringTokenizer(keys, this.sep, false);
while (tok.hasMoreTokens()) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/MacroDef.java b/src/main/org/apache/tools/ant/taskdefs/MacroDef.java
index be275e42f..e5d2240ce 100644
--- a/src/main/org/apache/tools/ant/taskdefs/MacroDef.java
+++ b/src/main/org/apache/tools/ant/taskdefs/MacroDef.java
@@ -237,7 +237,7 @@ public class MacroDef extends AntlibDefinition {
* @return true if the name consists of valid name characters
*/
private static boolean isValidName(String name) {
- if (name.length() == 0) {
+ if (name.isEmpty()) {
return false;
}
for (int i = 0; i < name.length(); ++i) {
@@ -724,9 +724,9 @@ public class MacroDef extends AntlibDefinition {
} else if (!text.equals(other.text)) {
return false;
}
- if (getURI() == null || "".equals(getURI())
+ if (getURI() == null || getURI().isEmpty()
|| getURI().equals(ProjectHelper.ANT_CORE_URI)) {
- if (other.getURI() != null && !"".equals(other.getURI())
+ if (other.getURI() != null && !other.getURI().isEmpty()
&& !other.getURI().equals(ProjectHelper.ANT_CORE_URI)) {
return false;
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java b/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java
index 99371d41a..8654bda7b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java
@@ -136,7 +136,7 @@ public abstract class MatchingTask extends Task implements SelectorContainer {
StringTokenizer tok = new StringTokenizer(itemString, ", ");
while (tok.hasMoreTokens()) {
String pattern = tok.nextToken().trim();
- if (pattern.length() > 0) {
+ if (!pattern.isEmpty()) {
createInclude().setName(pattern + "/**");
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/SubAnt.java b/src/main/org/apache/tools/ant/taskdefs/SubAnt.java
index d930a8d2b..3213d25f1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/SubAnt.java
+++ b/src/main/org/apache/tools/ant/taskdefs/SubAnt.java
@@ -569,7 +569,7 @@ public class SubAnt extends Task {
private Ant createAntTask(File directory) {
Ant antTask = new Ant(this);
antTask.init();
- if (subTarget != null && subTarget.length() > 0) {
+ if (subTarget != null && !subTarget.isEmpty()) {
antTask.setTarget(subTarget);
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Tar.java b/src/main/org/apache/tools/ant/taskdefs/Tar.java
index 978b7b54a..5112c5ccc 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Tar.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Tar.java
@@ -399,11 +399,9 @@ public class Tar extends MatchingTask {
if (tarFileSet != null) {
final String fullpath = tarFileSet.getFullpath(this.getProject());
- if (fullpath.length() > 0) {
- vPath = fullpath;
- } else {
+ if (fullpath.isEmpty()) {
// don't add "" to the archive
- if (vPath.length() <= 0) {
+ if (vPath.isEmpty()) {
return;
}
@@ -413,6 +411,8 @@ public class Tar extends MatchingTask {
prefix += "/";
}
vPath = prefix + vPath;
+ } else {
+ vPath = fullpath;
}
preserveLeadingSlashes = tarFileSet.getPreserveLeadingSlashes();
diff --git a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
index aa121698e..88b03e98f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
@@ -144,7 +144,7 @@ public class Tstamp extends Task {
*/
protected Optional<Date> getNow(String propertyName, Function<String, Date> map, BiFunction<String, String, String> log) {
String property = getProject().getProperty(propertyName);
- if (property != null && property.length() > 0) {
+ if (property != null && !property.isEmpty()) {
try {
return Optional.ofNullable(map.apply(property));
} catch (Exception e) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java b/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java
index 1303099de..f4d7886c9 100644
--- a/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java
+++ b/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java
@@ -290,7 +290,7 @@ public class XmlProperty extends Task {
// Set the prefix for this node to include its tag name.
String nodePrefix = prefix;
if (node.getNodeType() != Node.TEXT_NODE) {
- if (prefix.trim().length() > 0) {
+ if (!prefix.trim().isEmpty()) {
nodePrefix += ".";
}
nodePrefix += node.getNodeName();
diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java
index 7dfa1f6b6..a8a4d6ac4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Zip.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java
@@ -936,12 +936,12 @@ public class Zip extends MatchingTask {
fileMode = zfs.getFileMode(getProject());
}
- if (prefix.length() > 0 && fullpath.length() > 0) {
+ if (!prefix.isEmpty() && !fullpath.isEmpty()) {
throw new BuildException(
"Both prefix and fullpath attributes must not be set on the same fileset.");
}
- if (resources.length != 1 && fullpath.length() > 0) {
+ if (resources.length != 1 && !fullpath.isEmpty()) {
throw new BuildException(
"fullpath attribute may only be specified for filesets that specify a single file.");
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
index a8a2d4b3f..e78d94bdf 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
@@ -125,10 +125,10 @@ public class IsReachable extends ProjectComponent implements Condition {
*
* @param string param to check
*
- * @return true if it is empty
+ * @return true if it is isNullOrEmpty
*/
- private boolean empty(final String string) {
- return string == null || string.length() == 0;
+ private boolean isNullOrEmpty(final String string) {
+ return string == null || string.isEmpty();
}
/**
@@ -141,22 +141,22 @@ public class IsReachable extends ProjectComponent implements Condition {
*/
@Override
public boolean eval() throws BuildException {
- if (empty(host) && empty(url)) {
+ if (isNullOrEmpty(host) && isNullOrEmpty(url)) {
throw new BuildException(ERROR_NO_HOSTNAME);
}
if (timeout < 0) {
throw new BuildException(ERROR_BAD_TIMEOUT);
}
String target = host;
- if (!empty(url)) {
- if (!empty(host)) {
+ if (!isNullOrEmpty(url)) {
+ if (!isNullOrEmpty(host)) {
throw new BuildException(ERROR_BOTH_TARGETS);
}
try {
//get the host of a url
final URL realURL = new URL(url);
target = realURL.getHost();
- if (empty(target)) {
+ if (isNullOrEmpty(target)) {
throw new BuildException(ERROR_NO_HOST_IN_URL + url);
}
} catch (final MalformedURLException e) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java b/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
index 8a82c7820..92dd4b68d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
@@ -135,7 +135,7 @@ public class ResourceContains implements Condition {
public synchronized boolean eval() throws BuildException {
validate();
- if (substring.length() == 0) {
+ if (substring.isEmpty()) {
if (getProject() != null) {
getProject().log("Substring is empty; returning true",
Project.MSG_VERBOSE);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java b/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java
index 6f4179c21..007597dd1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java
@@ -184,7 +184,7 @@ public class EchoProperties extends Task {
* @param prefix The new prefix value
*/
public void setPrefix(String prefix) {
- if (prefix != null && prefix.length() != 0) {
+ if (prefix != null && !prefix.isEmpty()) {
this.prefix = prefix;
PropertySet ps = new PropertySet();
ps.setProject(getProject());
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java b/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
index ce99b5a38..d22d511bf 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
@@ -365,7 +365,7 @@ public class ReplaceRegExp extends Task {
log("Replacing pattern '" + regex.getPattern(getProject())
+ "' with '" + subs.getExpression(getProject())
+ "' in '" + f.getPath() + "'" + (byline ? " by line" : "")
- + (flags.length() > 0 ? " with flags: '" + flags + "'" : "")
+ + (flags.isEmpty() ? "" : " with flags: '" + flags + "'")
+ ".", Project.MSG_VERBOSE);
if (byline) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
index 24554a40d..02566a675 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
@@ -417,7 +417,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool {
// Lastly create File object for the Jar files. If we are using
// a flat destination dir, then we need to redefine baseName!
- if (config.flatDestDir && baseName.length() != 0) {
+ if (config.flatDestDir && !baseName.isEmpty()) {
int startName = baseName.lastIndexOf(File.separator);
if (startName == -1) {
startName = 0;
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
index 40cdc23e8..3094b0de8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebsphereDeploymentTool.java
@@ -553,7 +553,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool {
javaTask.createArg().setValue(destJar.getPath());
javaTask.createArg().setLine(getOptions());
if (getCombinedClasspath() != null
- && getCombinedClasspath().toString().length() > 0) {
+ && !getCombinedClasspath().toString().isEmpty()) {
javaTask.createArg().setValue("-cp");
javaTask.createArg().setValue(getCombinedClasspath().toString());
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java b/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java
index 0149cf896..2d27ec8fd 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java
@@ -365,12 +365,9 @@ public class Translate extends MatchingTask {
bundleCountry,
bundleVariant);
- String language = locale.getLanguage().length() > 0
- ? "_" + locale.getLanguage() : "";
- String country = locale.getCountry().length() > 0
- ? "_" + locale.getCountry() : "";
- String variant = locale.getVariant().length() > 0
- ? "_" + locale.getVariant() : "";
+ String language = locale.getLanguage().isEmpty() ? "" : "_" + locale.getLanguage();
+ String country = locale.getCountry().isEmpty() ? "" : "_" + locale.getCountry();
+ String variant = locale.getVariant().isEmpty() ? "" : "_" + locale.getVariant();
processBundle(bundle + language + country + variant, BUNDLE_SPECIFIED_LANGUAGE_COUNTRY_VARIANT, false);
processBundle(bundle + language + country, BUNDLE_SPECIFIED_LANGUAGE_COUNTRY, false);
@@ -381,12 +378,9 @@ public class Translate extends MatchingTask {
//using default file encoding scheme.
locale = Locale.getDefault();
- language = locale.getLanguage().length() > 0
- ? "_" + locale.getLanguage() : "";
- country = locale.getCountry().length() > 0
- ? "_" + locale.getCountry() : "";
- variant = locale.getVariant().length() > 0
- ? "_" + locale.getVariant() : "";
+ language = locale.getLanguage().isEmpty() ? "" : "_" + locale.getLanguage();
+ country = locale.getCountry().isEmpty() ? "" : "_" + locale.getCountry();
+ variant = locale.getVariant().isEmpty() ? "" : "_" + locale.getVariant();
bundleEncoding = System.getProperty("file.encoding");
processBundle(bundle + language + country + variant, BUNDLE_DEFAULT_LANGUAGE_COUNTRY_VARIANT, false);
@@ -456,7 +450,7 @@ public class Translate extends MatchingTask {
break;
}
}
- if (key.length() > 0) {
+ if (!key.isEmpty()) {
//Has key already been loaded into resourceMap?
resourceMap.putIfAbsent(key, value);
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
index 18b776384..17fd3af33 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
@@ -556,7 +556,7 @@ public class JDependTask extends Task {
// not sure whether this test is needed but cost nothing to put.
// hope it will be reviewed by anybody competent
- if (getClasspath().toString().length() > 0) {
+ if (!getClasspath().toString().isEmpty()) {
createJvmarg(commandline).setValue("-classpath");
createJvmarg(commandline).setValue(getClasspath().toString());
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
index e07db782c..1c182de84 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
@@ -174,7 +174,7 @@ public class WLJspc extends MatchingTask {
File jspFile = new File(filename);
args[j] = "-package";
String parents = jspFile.getParent();
- if (parents == null || "".equals(parents)) {
+ if (parents == null || parents.isEmpty()) {
args[j + 1] = destinationPackage;
} else {
parents = this.replaceString(parents, File.separator, "_.");
@@ -265,7 +265,7 @@ public class WLJspc extends MatchingTask {
String parents = jspFile.getParent();
String pack;
- if (parents == null || "".equals(parents)) {
+ if (parents == null || parents.isEmpty()) {
pack = pathToPackage;
} else {
parents = this.replaceString(parents, File.separator, "_/");
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultJspCompilerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultJspCompilerAdapter.java
index c9de17cd2..8eac9de9f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultJspCompilerAdapter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultJspCompilerAdapter.java
@@ -87,7 +87,7 @@ public abstract class DefaultJspCompilerAdapter
* @param argument The argument
*/
protected void addArg(CommandlineJava cmd, String argument) {
- if (argument != null && argument.length() != 0) {
+ if (argument != null && !argument.isEmpty()) {
cmd.createArgument().setValue(argument);
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java
index 6551b79e8..f79246976 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java
@@ -152,7 +152,7 @@ public class BriefJUnitResultFormatter implements JUnitResultFormatter, IgnoredT
sb.append(StringUtils.LINE_SEP);
// append the err and output streams to the log
- if (systemOutput != null && systemOutput.length() > 0) {
+ if (systemOutput != null && !systemOutput.isEmpty()) {
sb.append("------------- Standard Output ---------------")
.append(StringUtils.LINE_SEP)
.append(systemOutput)
@@ -160,7 +160,7 @@ public class BriefJUnitResultFormatter implements JUnitResultFormatter, IgnoredT
.append(StringUtils.LINE_SEP);
}
- if (systemError != null && systemError.length() > 0) {
+ if (systemError != null && !systemError.isEmpty()) {
sb.append("------------- Standard Error -----------------")
.append(StringUtils.LINE_SEP)
.append(systemError)
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnit4TestMethodAdapter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnit4TestMethodAdapter.java
index a1493678a..b1a64017e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnit4TestMethodAdapter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnit4TestMethodAdapter.java
@@ -67,7 +67,7 @@ public class JUnit4TestMethodAdapter implements Test {
if (methodNames[i] == null) {
throw new IllegalArgumentException("method name #" + i + " is <null>");
}
- if (methodNames[i].length() == 0) {
+ if (methodNames[i].isEmpty()) {
throw new IllegalArgumentException("method name #" + i + " is empty");
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
index 1818967f6..59e7f9624 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
@@ -155,7 +155,7 @@ public class JUnitVersionHelper {
if (annotation != null) {
Method valueMethod = annotation.annotationType().getMethod("value");
String value = (String) valueMethod.invoke(annotation);
- if (value != null && value.length() > 0) {
+ if (value != null && !value.isEmpty()) {
message = value;
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java
index 2031f7f1d..736927981 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java
@@ -127,7 +127,7 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter, IgnoredT
nf.format(suite.getRunTime() / ONE_SECOND)));
// write the err and output streams to the log
- if (systemOutput != null && systemOutput.length() > 0) {
+ if (systemOutput != null && !systemOutput.isEmpty()) {
write("------------- Standard Output ---------------");
write(StringUtils.LINE_SEP);
write(systemOutput);
@@ -135,7 +135,7 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter, IgnoredT
write(StringUtils.LINE_SEP);
}
- if (systemError != null && systemError.length() > 0) {
+ if (systemError != null && !systemError.isEmpty()) {
write("------------- Standard Error -----------------");
write(StringUtils.LINE_SEP);
write(systemError);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java
index 264c3b0af..7638f0be5 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java
@@ -190,11 +190,11 @@ public class SummaryJUnitResultFormatter
sb.append(System.lineSeparator());
if (withOutAndErr) {
- if (systemOutput != null && systemOutput.length() > 0) {
+ if (systemOutput != null && !systemOutput.isEmpty()) {
sb.append(String.format("Output:%n%s%n", systemOutput));
}
- if (systemError != null && systemError.length() > 0) {
+ if (systemError != null && !systemError.isEmpty()) {
sb.append(String.format("Output:%n%s%n", systemError));
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
index ed282207a..da56d223c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
@@ -313,7 +313,7 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan
currentTest.appendChild(nested);
final String message = t.getMessage();
- if (message != null && message.length() > 0) {
+ if (message != null && !message.isEmpty()) {
nested.setAttribute(ATTR_MESSAGE, t.getMessage());
}
nested.setAttribute(ATTR_TYPE, t.getClass().getName());
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
index f9a4a95b2..c23ffbc9b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
@@ -467,22 +467,19 @@ public class FTP extends Task implements FTPTaskConfig {
}
if (myfile.isDirectory()) {
- if (isIncluded(currentelement)
- && currentelement.length() > 0) {
+ if (isIncluded(currentelement) && !currentelement.isEmpty()) {
accountForIncludedDir(currentelement, myfile, true);
- } else {
- if (currentelement.length() > 0
+ } else {
+ if (!currentelement.isEmpty()
&& currentelement.charAt(currentelement.length() - 1)
!= File.separatorChar) {
currentelement += File.separatorChar;
}
scandir(myfile.getAbsolutePath(), currentelement, true);
}
- } else if (isCaseSensitive
- && originalpattern.equals(currentelement)) {
+ } else if (isCaseSensitive && originalpattern.equals(currentelement)) {
accountForIncludedFile(currentelement);
- } else if (!isCaseSensitive && originalpattern
- .equalsIgnoreCase(currentelement)) {
+ } else if (!isCaseSensitive && originalpattern.equalsIgnoreCase(currentelement)) {
accountForIncludedFile(currentelement);
}
}
@@ -1490,7 +1487,7 @@ public class FTP extends Task implements FTPTaskConfig {
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setSystemTypeKey(FTPSystemType systemKey) {
- if (systemKey != null && !"".equals(systemKey.getValue())) {
+ if (systemKey != null && !systemKey.getValue().isEmpty()) {
this.systemTypeKey = systemKey;
configurationHasBeenSet();
}
@@ -1503,7 +1500,7 @@ public class FTP extends Task implements FTPTaskConfig {
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setDefaultDateFormatConfig(String defaultDateFormat) {
- if (defaultDateFormat != null && !"".equals(defaultDateFormat)) {
+ if (defaultDateFormat != null && !defaultDateFormat.isEmpty()) {
this.defaultDateFormatConfig = defaultDateFormat;
configurationHasBeenSet();
}
@@ -1516,7 +1513,7 @@ public class FTP extends Task implements FTPTaskConfig {
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setRecentDateFormatConfig(String recentDateFormat) {
- if (recentDateFormat != null && !"".equals(recentDateFormat)) {
+ if (recentDateFormat != null && !recentDateFormat.isEmpty()) {
this.recentDateFormatConfig = recentDateFormat;
configurationHasBeenSet();
}
@@ -1542,7 +1539,7 @@ public class FTP extends Task implements FTPTaskConfig {
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setServerTimeZoneConfig(String serverTimeZoneId) {
- if (serverTimeZoneId != null && !"".equals(serverTimeZoneId)) {
+ if (serverTimeZoneId != null && !serverTimeZoneId.isEmpty()) {
this.serverTimeZoneConfig = serverTimeZoneId;
configurationHasBeenSet();
}
@@ -1556,7 +1553,7 @@ public class FTP extends Task implements FTPTaskConfig {
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setShortMonthNamesConfig(String shortMonthNames) {
- if (shortMonthNames != null && !"".equals(shortMonthNames)) {
+ if (shortMonthNames != null && !shortMonthNames.isEmpty()) {
this.shortMonthNamesConfig = shortMonthNames;
configurationHasBeenSet();
}
@@ -1652,7 +1649,7 @@ public class FTP extends Task implements FTPTaskConfig {
* @param timestampGranularity The timestampGranularity to set.
*/
public void setTimestampGranularity(Granularity timestampGranularity) {
- if (null == timestampGranularity || "".equals(timestampGranularity.getValue())) {
+ if (null == timestampGranularity || timestampGranularity.getValue().isEmpty()) {
return;
}
this.timestampGranularity = timestampGranularity;
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java
index 0604dac9e..f7650be42 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java
@@ -43,7 +43,7 @@ class FTPConfigurator {
task.log("custom configuration", Project.MSG_VERBOSE);
FTPClientConfig config;
String systemTypeKey = task.getSystemTypeKey();
- if (systemTypeKey != null && !"".equals(systemTypeKey)) {
+ if (systemTypeKey != null && !systemTypeKey.isEmpty()) {
config = new FTPClientConfig(systemTypeKey);
task.log("custom config: system key = "
+ systemTypeKey, Project.MSG_VERBOSE);
@@ -69,7 +69,7 @@ class FTPConfigurator {
String serverLanguageCodeConfig = task.getServerLanguageCodeConfig();
if (serverLanguageCodeConfig != null) {
- if (!"".equals(serverLanguageCodeConfig)
+ if (!serverLanguageCodeConfig.isEmpty()
&& !FTPClientConfig.getSupportedLanguageCodes()
.contains(serverLanguageCodeConfig)) {
throw new BuildException("unsupported language code" +
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java
index 87535d23d..5b4081b17 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java
@@ -504,7 +504,7 @@ public class FTPTask extends Task implements FTPTaskConfig {
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setSystemTypeKey(FTPSystemType systemKey) {
- if (systemKey != null && !"".equals(systemKey.getValue())) {
+ if (systemKey != null && !systemKey.getValue().isEmpty()) {
this.systemTypeKey = systemKey;
configurationHasBeenSet();
}
@@ -517,7 +517,7 @@ public class FTPTask extends Task implements FTPTaskConfig {
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setDefaultDateFormatConfig(String defaultDateFormat) {
- if (defaultDateFormat != null && !"".equals(defaultDateFormat)) {
+ if (defaultDateFormat != null && !defaultDateFormat.isEmpty()) {
this.defaultDateFormatConfig = defaultDateFormat;
configurationHasBeenSet();
}
@@ -530,7 +530,7 @@ public class FTPTask extends Task implements FTPTaskConfig {
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setRecentDateFormatConfig(String recentDateFormat) {
- if (recentDateFormat != null && !"".equals(recentDateFormat)) {
+ if (recentDateFormat != null && recentDateFormat.isEmpty()) {
this.recentDateFormatConfig = recentDateFormat;
configurationHasBeenSet();
}
@@ -556,7 +556,7 @@ public class FTPTask extends Task implements FTPTaskConfig {
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setServerTimeZoneConfig(String serverTimeZoneId) {
- if (serverTimeZoneId != null && !"".equals(serverTimeZoneId)) {
+ if (serverTimeZoneId != null && serverTimeZoneId.isEmpty()) {
this.serverTimeZoneConfig = serverTimeZoneId;
configurationHasBeenSet();
}
@@ -570,7 +570,7 @@ public class FTPTask extends Task implements FTPTaskConfig {
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setShortMonthNamesConfig(String shortMonthNames) {
- if (shortMonthNames != null && !"".equals(shortMonthNames)) {
+ if (shortMonthNames != null && !shortMonthNames.isEmpty()) {
this.shortMonthNamesConfig = shortMonthNames;
configurationHasBeenSet();
}
@@ -671,7 +671,7 @@ public class FTPTask extends Task implements FTPTaskConfig {
* @param timestampGranularity The timestampGranularity to set.
*/
public void setTimestampGranularity(Granularity timestampGranularity) {
- if (null == timestampGranularity || "".equals(timestampGranularity.getValue())) {
+ if (null == timestampGranularity || timestampGranularity.getValue().isEmpty()) {
return;
}
this.timestampGranularity = timestampGranularity;
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
index 1a16b80ae..631e73b9d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
@@ -359,12 +359,10 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
}
if (myfile.isDirectory()) {
- if (isIncluded(currentelement)
- && currentelement.length() > 0) {
+ if (isIncluded(currentelement) && !currentelement.isEmpty()) {
accountForIncludedDir(currentelement, myfile, true);
- } else {
- if (currentelement.length() > 0
- && currentelement.charAt(currentelement.length() - 1)
+ } else {
+ if (!currentelement.isEmpty() && currentelement.charAt(currentelement.length() - 1)
!= File.separatorChar) {
currentelement += File.separatorChar;
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java
index 748afcf97..d347a7521 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/SetProxy.java
@@ -181,7 +181,7 @@ public class SetProxy extends Task {
Properties sysprops = System.getProperties();
if (proxyHost != null) {
settingsChanged = true;
- if (proxyHost.length() != 0) {
+ if (!proxyHost.isEmpty()) {
traceSettingInfo();
enablingProxy = true;
sysprops.put(ProxySetup.HTTP_PROXY_HOST, proxyHost);
@@ -216,7 +216,7 @@ public class SetProxy extends Task {
//socks
if (socksProxyHost != null) {
settingsChanged = true;
- if (socksProxyHost.length() != 0) {
+ if (!socksProxyHost.isEmpty()) {
enablingProxy = true;
sysprops.put(ProxySetup.SOCKS_PROXY_HOST, socksProxyHost);
sysprops.put(ProxySetup.SOCKS_PROXY_PORT, Integer.toString(socksProxyPort));
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java b/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java
index a525c3246..51d6cc002 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java
@@ -243,7 +243,7 @@ public class Pvcs extends Task {
commandLine.clearArgs();
commandLine.setExecutable(getExecutable(GET_EXE));
- if (getConfig() != null && getConfig().length() > 0) {
+ if (getConfig() != null && !getConfig().isEmpty()) {
commandLine.createArgument().setValue("-c" + getConfig());
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java
index 840672f3b..e265bbe1e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java
@@ -182,8 +182,8 @@ public class SplashTask extends Task {
sp.setProxyPassword(password);
sp.applyWebProxySettings();
- if (useProxy && (proxy != null && proxy.length() > 0)
- && (port != null && port.length() > 0)) {
+ if (useProxy && (proxy != null && !proxy.isEmpty())
+ && (port != null && !port.isEmpty())) {
log("Using proxied Connection", Project.MSG_DEBUG);
System.getProperties().put("http.proxySet", "true");
@@ -191,7 +191,7 @@ public class SplashTask extends Task {
URL url = new URL(imgurl);
conn = url.openConnection();
- if (user != null && user.length() > 0) {
+ if (user != null && !user.isEmpty()) {
// converted from sun internal classes to
// new Base64Converter
// utility class extracted from Get task
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java
index eef68d7cc..676869f28 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java
@@ -85,7 +85,7 @@ public class SSHSession extends SSHBase {
*/
public void setLocaltunnels(final String tunnels) {
for (String tunnelSpec : tunnels.split(", ")) {
- if (tunnelSpec.length() > 0) {
+ if (!tunnelSpec.isEmpty()) {
final String[] spec = tunnelSpec.split(":", 3);
final int lport = Integer.parseInt(spec[0]);
final String rhost = spec[1];
@@ -107,7 +107,7 @@ public class SSHSession extends SSHBase {
*/
public void setRemotetunnels(final String tunnels) {
for (String tunnelSpec : tunnels.split(", ")) {
- if (tunnelSpec.length() > 0) {
+ if (!tunnelSpec.isEmpty()) {
final String[] spec = tunnelSpec.split(":", 3);
final int rport = Integer.parseInt(spec[0]);
final String lhost = spec[1];
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java
index fcba78725..9e0705db5 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java
@@ -417,7 +417,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants {
*/
protected String getLabel() {
String shortLabel = "";
- if (label != null && label.length() > 0) {
+ if (label != null && !label.isEmpty()) {
shortLabel = FLAG_LABEL + getShortLabel();
}
return shortLabel;
diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java b/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
index d7c4a4ae1..7226246ac 100644
--- a/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
+++ b/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapterFactory.java
@@ -95,7 +95,7 @@ public final class RmicAdapterFactory {
Path classpath)
throws BuildException {
//handle default specially by choosing the sun or kaffe compiler
- if (DEFAULT_COMPILER.equalsIgnoreCase(rmicType) || rmicType.length() == 0) {
+ if (DEFAULT_COMPILER.equalsIgnoreCase(rmicType) || rmicType.isEmpty()) {
if (KaffeRmic.isAvailable()) {
rmicType = KaffeRmic.COMPILER_NAME;
} else if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) {
diff --git a/src/main/org/apache/tools/ant/types/ArchiveScanner.java b/src/main/org/apache/tools/ant/types/ArchiveScanner.java
index cd9eeb838..cb6b882ba 100644
--- a/src/main/org/apache/tools/ant/types/ArchiveScanner.java
+++ b/src/main/org/apache/tools/ant/types/ArchiveScanner.java
@@ -256,7 +256,7 @@ public abstract class ArchiveScanner extends DirectoryScanner {
*/
public boolean match(String path) {
String vpath = path;
- if (path.length() > 0) {
+ if (!path.isEmpty()) {
vpath = path.replace('/', File.separatorChar).
replace('\\', File.separatorChar);
if (vpath.charAt(0) == File.separatorChar) {
diff --git a/src/main/org/apache/tools/ant/types/Commandline.java b/src/main/org/apache/tools/ant/types/Commandline.java
index ce28160ae..2fe0d52f8 100644
--- a/src/main/org/apache/tools/ant/types/Commandline.java
+++ b/src/main/org/apache/tools/ant/types/Commandline.java
@@ -183,8 +183,7 @@ public class Commandline implements Cloneable {
* @return an array of strings.
*/
public String[] getParts() {
- if (parts == null || parts.length == 0
- || (prefix.length() == 0 && suffix.length() == 0)) {
+ if (parts == null || parts.length == 0 || (prefix.isEmpty() && suffix.isEmpty())) {
return parts;
}
String[] fullParts = new String[parts.length];
@@ -327,7 +326,7 @@ public class Commandline implements Cloneable {
* @since Ant 1.9.7
*/
public void setExecutable(String executable, boolean translateFileSeparator) {
- if (executable == null || executable.length() == 0) {
+ if (executable == null || executable.isEmpty()) {
return;
}
this.executable = translateFileSeparator
@@ -468,7 +467,7 @@ public class Commandline implements Cloneable {
* An empty or null toProcess parameter results in a zero sized array.
*/
public static String[] translateCommandline(String toProcess) {
- if (toProcess == null || toProcess.length() == 0) {
+ if (toProcess == null || toProcess.isEmpty()) {
//no command? no string
return new String[0];
}
diff --git a/src/main/org/apache/tools/ant/types/CommandlineJava.java b/src/main/org/apache/tools/ant/types/CommandlineJava.java
index c202a0350..7cace386f 100644
--- a/src/main/org/apache/tools/ant/types/CommandlineJava.java
+++ b/src/main/org/apache/tools/ant/types/CommandlineJava.java
@@ -756,8 +756,8 @@ public class CommandlineJava implements Cloneable {
* @since Ant 1.6
*/
public boolean haveClasspath() {
- Path fullClasspath = classpath != null ? classpath.concatSystemClasspath("ignore") : null;
- return fullClasspath != null && fullClasspath.toString().trim().length() > 0;
+ Path fullClasspath = classpath == null ? null : classpath.concatSystemClasspath("ignore");
+ return fullClasspath != null && !fullClasspath.toString().trim().isEmpty();
}
/**
diff --git a/src/main/org/apache/tools/ant/types/FilterSet.java b/src/main/org/apache/tools/ant/types/FilterSet.java
index 67dc16e8c..41db0587f 100644
--- a/src/main/org/apache/tools/ant/types/FilterSet.java
+++ b/src/main/org/apache/tools/ant/types/FilterSet.java
@@ -283,7 +283,7 @@ public class FilterSet extends DataType implements Cloneable {
if (isReference()) {
throw tooManyAttributes();
}
- if (startOfToken == null || "".equals(startOfToken)) {
+ if (startOfToken == null || startOfToken.isEmpty()) {
throw new BuildException("beginToken must not be empty");
}
this.startOfToken = startOfToken;
@@ -310,7 +310,7 @@ public class FilterSet extends DataType implements Cloneable {
if (isReference()) {
throw tooManyAttributes();
}
- if (endOfToken == null || "".equals(endOfToken)) {
+ if (endOfToken == null || endOfToken.isEmpty()) {
throw new BuildException("endToken must not be empty");
}
this.endOfToken = endOfToken;
diff --git a/src/main/org/apache/tools/ant/types/resources/MultiRootFileSet.java b/src/main/org/apache/tools/ant/types/resources/MultiRootFileSet.java
index 8a02da2c3..9f5113cd4 100644
--- a/src/main/org/apache/tools/ant/types/resources/MultiRootFileSet.java
+++ b/src/main/org/apache/tools/ant/types/resources/MultiRootFileSet.java
@@ -79,9 +79,8 @@ public class MultiRootFileSet extends AbstractFileSet
if (isReference()) {
throw tooManyAttributes();
}
- if (dirs != null && dirs.length() > 0) {
- final String[] ds = dirs.split(",");
- for (final String d : ds) {
+ if (dirs != null && !dirs.isEmpty()) {
+ for (final String d : dirs.split(",")) {
baseDirs.add(getProject().resolveFile(d));
}
}
diff --git a/src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java b/src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java
index c9ee75dc8..91c574f89 100644
--- a/src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java
+++ b/src/main/org/apache/tools/ant/types/selectors/ExtendSelector.java
@@ -56,7 +56,7 @@ public class ExtendSelector extends BaseSelector {
* Instantiates the identified custom selector class.
*/
public void selectorCreate() {
- if (classname != null && classname.length() > 0) {
+ if (classname != null && !classname.isEmpty()) {
try {
Class<?> c;
if (classpath == null) {
diff --git a/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java b/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java
index cf565f7a2..378017205 100644
--- a/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java
+++ b/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java
@@ -64,9 +64,8 @@ public class TokenizedPath {
* @param child the child, must not contain the file separator
*/
public TokenizedPath(TokenizedPath parent, String child) {
- if (parent.path.length() > 0
- && parent.path.charAt(parent.path.length() - 1)
- != File.separatorChar) {
+ if (!parent.path.isEmpty()
+ && parent.path.charAt(parent.path.length() - 1) != File.separatorChar) {
path = parent.path + File.separatorChar + child;
} else {
path = parent.path + child;
diff --git a/src/main/org/apache/tools/ant/types/spi/Service.java b/src/main/org/apache/tools/ant/types/spi/Service.java
index 064bd086f..7d7c8a23e 100644
--- a/src/main/org/apache/tools/ant/types/spi/Service.java
+++ b/src/main/org/apache/tools/ant/types/spi/Service.java
@@ -96,7 +96,7 @@ public class Service extends ProjectComponent {
"type attribute must be set for service element",
getLocation());
}
- if (type.length() == 0) {
+ if (type.isEmpty()) {
throw new BuildException(
"Invalid empty type classname", getLocation());
}
diff --git a/src/main/org/apache/tools/ant/util/DOMElementWriter.java b/src/main/org/apache/tools/ant/util/DOMElementWriter.java
index 0104c34e1..d0cef7c36 100644
--- a/src/main/org/apache/tools/ant/util/DOMElementWriter.java
+++ b/src/main/org/apache/tools/ant/util/DOMElementWriter.java
@@ -248,7 +248,7 @@ public class DOMElementWriter {
out.write("<?");
out.write(child.getNodeName());
String data = child.getNodeValue();
- if (data != null && data.length() > 0) {
+ if (data != null && !data.isEmpty()) {
out.write(' ');
out.write(data);
}
@@ -398,7 +398,7 @@ public class DOMElementWriter {
if (namespacePolicy.qualifyElements) {
String uri = getNamespaceURI(element);
String prefix = nsPrefixMap.get(uri);
- if (prefix != null && !"".equals(prefix)) {
+ if (prefix != null && !prefix.isEmpty()) {
out.write(prefix);
out.write(":");
}
diff --git a/src/main/org/apache/tools/ant/util/DeweyDecimal.java b/src/main/org/apache/tools/ant/util/DeweyDecimal.java
index 32564fd66..d9a28e82e 100644
--- a/src/main/org/apache/tools/ant/util/DeweyDecimal.java
+++ b/src/main/org/apache/tools/ant/util/DeweyDecimal.java
@@ -60,7 +60,7 @@ public class DeweyDecimal implements Comparable<DeweyDecimal> {
for (int i = 0; i < components.length; i++) {
final String component = tokenizer.nextToken();
- if (component.length() == 0) {
+ if (component.isEmpty()) {
throw new NumberFormatException("Empty component in string");
}
diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java
index af76942d5..541353c72 100644
--- a/src/main/org/apache/tools/ant/util/FileUtils.java
+++ b/src/main/org/apache/tools/ant/util/FileUtils.java
@@ -634,7 +634,7 @@ public class FileUtils {
* @since Ant 1.7
*/
public static boolean isContextRelativePath(String filename) {
- if (!(ON_DOS || ON_NETWARE) || filename.length() == 0) {
+ if (!(ON_DOS || ON_NETWARE) || filename.isEmpty()) {
return false;
}
char sep = File.separatorChar;
@@ -658,10 +658,10 @@ public class FileUtils {
* @since Ant 1.6.3
*/
public static boolean isAbsolutePath(String filename) {
- int len = filename.length();
- if (len == 0) {
+ if (filename.isEmpty()) {
return false;
}
+ int len = filename.length();
char sep = File.separatorChar;
filename = filename.replace('/', sep).replace('\\', sep);
char c = filename.charAt(0);
diff --git a/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java b/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java
index f1031e1dc..2ace4d4b3 100644
--- a/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java
+++ b/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java
@@ -353,7 +353,7 @@ public class LayoutPreservingProperties extends Properties {
LogicalLine line;
if (comment) {
line = new Comment(logicalLineBuffer.toString());
- } else if (logicalLineBuffer.toString().trim().length() == 0) {
+ } else if (logicalLineBuffer.toString().trim().isEmpty()) {
line = new Blank();
} else {
line = new Pair(logicalLineBuffer.toString());
diff --git a/src/main/org/apache/tools/ant/util/ResourceUtils.java b/src/main/org/apache/tools/ant/util/ResourceUtils.java
index 741ff6026..f1114e70a 100644
--- a/src/main/org/apache/tools/ant/util/ResourceUtils.java
+++ b/src/main/org/apache/tools/ant/util/ResourceUtils.java
@@ -657,7 +657,7 @@ public class ResourceUtils {
lineTokenizer.setIncludeDelims(true);
String line = lineTokenizer.getToken(in);
while (line != null) {
- if (line.length() == 0) {
+ if (line.isEmpty()) {
// this should not happen, because the lines are
// returned with the end of line delimiter
out.newLine();
diff --git a/src/main/org/apache/tools/tar/TarEntry.java b/src/main/org/apache/tools/tar/TarEntry.java
index feae10927..f706a64a4 100644
--- a/src/main/org/apache/tools/tar/TarEntry.java
+++ b/src/main/org/apache/tools/tar/TarEntry.java
@@ -995,7 +995,7 @@ public class TarEntry implements TarConstants {
if (isDirectory() && !name.endsWith("/")) {
name += "/";
}
- if (prefix.length() > 0) {
+ if (!prefix.isEmpty()) {
name = prefix + "/" + name;
}
}
diff --git a/src/main/org/apache/tools/tar/TarOutputStream.java b/src/main/org/apache/tools/tar/TarOutputStream.java
index 7e92d7a31..2802e95f4 100644
--- a/src/main/org/apache/tools/tar/TarOutputStream.java
+++ b/src/main/org/apache/tools/tar/TarOutputStream.java
@@ -288,7 +288,7 @@ public class TarOutputStream extends FilterOutputStream {
TarConstants.LF_GNUTYPE_LONGNAME, "file name");
final String linkName = entry.getLinkName();
- boolean paxHeaderContainsLinkPath = linkName != null && linkName.length() > 0
+ boolean paxHeaderContainsLinkPath = linkName != null && !linkName.isEmpty()
&& handleLongName(entry, linkName, paxHeaders, "linkpath",
TarConstants.LF_GNUTYPE_LONGLINK, "link name");
diff --git a/src/main/org/apache/tools/zip/AsiExtraField.java b/src/main/org/apache/tools/zip/AsiExtraField.java
index 0108ee236..9b1cb2444 100644
--- a/src/main/org/apache/tools/zip/AsiExtraField.java
+++ b/src/main/org/apache/tools/zip/AsiExtraField.java
@@ -241,7 +241,7 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable {
* @since 1.1
*/
public boolean isLink() {
- return getLinkedFile().length() != 0;
+ return !getLinkedFile().isEmpty();
}
/**