@@ -157,7 +157,7 @@ public class ArgumentProcessorRegistry { | |||||
} | } | ||||
BufferedReader rd = new BufferedReader(isr); | BufferedReader rd = new BufferedReader(isr); | ||||
String processorClassName = rd.readLine(); | String processorClassName = rd.readLine(); | ||||
if (processorClassName != null && !"".equals(processorClassName)) { | |||||
if (processorClassName != null && !processorClassName.isEmpty()) { | |||||
return getProcessor(processorClassName); | return getProcessor(processorClassName); | ||||
} | } | ||||
} finally { | } finally { | ||||
@@ -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 custom tasks/types have been declared."); | ||||
out.println("Action: Check that any <presetdef>/<macrodef>" | out.println("Action: Check that any <presetdef>/<macrodef>" | ||||
+ " declarations have taken place."); | + " declarations have taken place."); | ||||
if (uri.length() > 0) { | |||||
if (!uri.isEmpty()) { | |||||
final List<AntTypeDefinition> matches = findTypeMatches(uri); | final List<AntTypeDefinition> matches = findTypeMatches(uri); | ||||
if (matches.isEmpty()) { | if (matches.isEmpty()) { | ||||
out.println("No types or tasks have been defined in this namespace yet"); | out.println("No types or tasks have been defined in this namespace yet"); | ||||
@@ -1016,8 +1016,7 @@ public class DirectoryScanner | |||||
continue; | continue; | ||||
} | } | ||||
if (myfile.isDirectory()) { | if (myfile.isDirectory()) { | ||||
if (isIncluded(currentPath) | |||||
&& currentelement.length() > 0) { | |||||
if (isIncluded(currentPath) && !currentelement.isEmpty()) { | |||||
accountForIncludedDir(currentPath, myfile, true); | accountForIncludedDir(currentPath, myfile, true); | ||||
} else { | } else { | ||||
scandir(myfile, currentPath, true); | scandir(myfile, currentPath, true); | ||||
@@ -1200,7 +1199,7 @@ public class DirectoryScanner | |||||
private void scandir(final File dir, final TokenizedPath path, final boolean fast, | private void scandir(final File dir, final TokenizedPath path, final boolean fast, | ||||
String[] newFiles, final Deque<String> directoryNamesFollowed) { | String[] newFiles, final Deque<String> directoryNamesFollowed) { | ||||
String vpath = path.toString(); | String vpath = path.toString(); | ||||
if (vpath.length() > 0 && !vpath.endsWith(File.separator)) { | |||||
if (!vpath.isEmpty() && !vpath.endsWith(File.separator)) { | |||||
vpath += File.separator; | vpath += File.separator; | ||||
} | } | ||||
@@ -458,7 +458,7 @@ public final class IntrospectionHelper { | |||||
if (addText == null) { | if (addText == null) { | ||||
text = text.trim(); | text = text.trim(); | ||||
// Element doesn't handle text content | // Element doesn't handle text content | ||||
if (text.length() == 0) { | |||||
if (text.isEmpty()) { | |||||
// Only whitespace - ignore | // Only whitespace - ignore | ||||
return; | return; | ||||
} | } | ||||
@@ -530,7 +530,7 @@ public final class IntrospectionHelper { | |||||
parentUri = ""; | parentUri = ""; | ||||
} | } | ||||
NestedCreator nc = null; | NestedCreator nc = null; | ||||
if (uri.equals(parentUri) || uri.length() == 0) { | |||||
if (uri.equals(parentUri) || uri.isEmpty()) { | |||||
nc = nestedCreators.get(name.toLowerCase(Locale.ENGLISH)); | nc = nestedCreators.get(name.toLowerCase(Locale.ENGLISH)); | ||||
} | } | ||||
if (nc == null) { | if (nc == null) { | ||||
@@ -741,10 +741,7 @@ public final class IntrospectionHelper { | |||||
return false; | return false; | ||||
} | } | ||||
String uri = ProjectHelper.extractUriFromComponentName(elementName); | 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; | return true; | ||||
} | } | ||||
if (parentUri.equals(ProjectHelper.ANT_CORE_URI)) { | if (parentUri.equals(ProjectHelper.ANT_CORE_URI)) { | ||||
@@ -1058,7 +1055,7 @@ public final class IntrospectionHelper { | |||||
@Override | @Override | ||||
public void set(final Project p, final Object parent, final String value) | public void set(final Project p, final Object parent, final String value) | ||||
throws InvocationTargetException, IllegalAccessException { | throws InvocationTargetException, IllegalAccessException { | ||||
if (value.length() == 0) { | |||||
if (value.isEmpty()) { | |||||
throw new BuildException("The value \"\" is not a " | throw new BuildException("The value \"\" is not a " | ||||
+ "legal value for attribute \"" + attrName + "\""); | + "legal value for attribute \"" + attrName + "\""); | ||||
} | } | ||||
@@ -1217,7 +1217,7 @@ public class Main implements AntMain { | |||||
} | } | ||||
final String defaultTarget = project.getDefaultTarget(); | final String defaultTarget = project.getDefaultTarget(); | ||||
if (defaultTarget != null && !"".equals(defaultTarget)) { | |||||
if (defaultTarget != null && defaultTarget.isEmpty()) { | |||||
// shouldn't need to check but... | // shouldn't need to check but... | ||||
project.log("Default target: " + defaultTarget); | project.log("Default target: " + defaultTarget); | ||||
} | } | ||||
@@ -84,7 +84,7 @@ public class NoBannerLogger extends DefaultLogger { | |||||
if (event.getPriority() > msgOutputLevel | if (event.getPriority() > msgOutputLevel | ||||
|| null == event.getMessage() | || null == event.getMessage() | ||||
|| "".equals(event.getMessage().trim())) { | |||||
|| event.getMessage().trim().isEmpty()) { | |||||
return; | return; | ||||
} | } | ||||
@@ -494,7 +494,7 @@ public class ProjectHelper { | |||||
* @return The stringified form of the ns name | * @return The stringified form of the ns name | ||||
*/ | */ | ||||
public static String genComponentName(String uri, String 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 name; | ||||
} | } | ||||
return uri + ":" + name; | return uri + ":" + name; | ||||
@@ -197,7 +197,7 @@ public class ProjectHelperRepository { | |||||
String helperClassName = rd.readLine(); | String helperClassName = rd.readLine(); | ||||
rd.close(); | rd.close(); | ||||
if (helperClassName != null && !"".equals(helperClassName)) { | |||||
if (helperClassName != null && !helperClassName.isEmpty()) { | |||||
return getHelperConstructor(helperClassName); | return getHelperConstructor(helperClassName); | ||||
} | } | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
@@ -391,7 +391,7 @@ public class RuntimeConfigurable implements Serializable { | |||||
* Should not be <code>null</code>. | * Should not be <code>null</code>. | ||||
*/ | */ | ||||
public synchronized void addText(String data) { | public synchronized void addText(String data) { | ||||
if (data.length() == 0) { | |||||
if (data.isEmpty()) { | |||||
return; | return; | ||||
} | } | ||||
characters = (characters == null) | characters = (characters == null) | ||||
@@ -182,7 +182,7 @@ public class XmlLogger implements BuildLogger { | |||||
outStream == null ? Files.newOutputStream(Paths.get(outFilename)) : outStream; | outStream == null ? Files.newOutputStream(Paths.get(outFilename)) : outStream; | ||||
Writer out = new OutputStreamWriter(stream, "UTF8")) { | Writer out = new OutputStreamWriter(stream, "UTF8")) { | ||||
out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); | 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 | out.write("<?xml-stylesheet type=\"text/xsl\" href=\"" + xslUri | ||||
+ "\"?>\n\n"); | + "\"?>\n\n"); | ||||
} | } | ||||
@@ -88,13 +88,13 @@ public final class ClassConstants | |||||
public int read() throws IOException { | public int read() throws IOException { | ||||
int ch = -1; | int ch = -1; | ||||
if (queuedData != null && queuedData.length() == 0) { | |||||
if (queuedData != null && queuedData.isEmpty()) { | |||||
queuedData = null; | queuedData = null; | ||||
} | } | ||||
if (queuedData == null) { | if (queuedData == null) { | ||||
final String clazz = readFully(); | final String clazz = readFully(); | ||||
if (clazz == null || clazz.length() == 0) { | |||||
if (clazz == null || clazz.isEmpty()) { | |||||
ch = -1; | ch = -1; | ||||
} else { | } else { | ||||
final byte[] bytes = clazz.getBytes(ResourceUtils.ISO_8859_1); | final byte[] bytes = clazz.getBytes(ResourceUtils.ISO_8859_1); | ||||
@@ -130,7 +130,7 @@ public final class ClassConstants | |||||
} else { | } else { | ||||
ch = queuedData.charAt(0); | ch = queuedData.charAt(0); | ||||
queuedData = queuedData.substring(1); | queuedData = queuedData.substring(1); | ||||
if (queuedData.length() == 0) { | |||||
if (queuedData.isEmpty()) { | |||||
queuedData = null; | queuedData = null; | ||||
} | } | ||||
} | } | ||||
@@ -105,7 +105,7 @@ public final class HeadFilter extends BaseParamFilterReader | |||||
setInitialized(true); | setInitialized(true); | ||||
} | } | ||||
while (line == null || line.length() == 0) { | |||||
while (line == null || line.isEmpty()) { | |||||
line = lineTokenizer.getToken(in); | line = lineTokenizer.getToken(in); | ||||
if (line == null) { | if (line == null) { | ||||
return -1; | return -1; | ||||
@@ -86,14 +86,14 @@ public final class PrefixLines | |||||
int ch = -1; | int ch = -1; | ||||
if (queuedData != null && queuedData.length() == 0) { | |||||
if (queuedData != null && queuedData.isEmpty()) { | |||||
queuedData = null; | queuedData = null; | ||||
} | } | ||||
if (queuedData != null) { | if (queuedData != null) { | ||||
ch = queuedData.charAt(0); | ch = queuedData.charAt(0); | ||||
queuedData = queuedData.substring(1); | queuedData = queuedData.substring(1); | ||||
if (queuedData.length() == 0) { | |||||
if (queuedData.isEmpty()) { | |||||
queuedData = null; | queuedData = null; | ||||
} | } | ||||
} else { | } else { | ||||
@@ -134,7 +134,7 @@ public final class ReplaceTokens | |||||
} | } | ||||
// is the read buffer empty? | // is the read buffer empty? | ||||
if (readBuffer.length() == 0) { | |||||
if (readBuffer.isEmpty()) { | |||||
int next = in.read(); | int next = in.read(); | ||||
if (next == -1) { | if (next == -1) { | ||||
return next; // end of stream. all buffers empty. | 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. | * @return the first character from the read buffer or -1 if read buffer is empty. | ||||
*/ | */ | ||||
private int getFirstCharacterFromReadBuffer() { | private int getFirstCharacterFromReadBuffer() { | ||||
if (readBuffer.length() > 0) { | |||||
int chr = readBuffer.charAt(0); | |||||
readBuffer = readBuffer.substring(1); | |||||
return chr; | |||||
} else { | |||||
if (readBuffer.isEmpty()) { | |||||
return -1; | return -1; | ||||
} | } | ||||
int chr = readBuffer.charAt(0); | |||||
readBuffer = readBuffer.substring(1); | |||||
return chr; | |||||
} | } | ||||
/** | /** | ||||
@@ -87,17 +87,11 @@ public final class SuffixLines | |||||
int ch = -1; | int ch = -1; | ||||
if (queuedData != null && queuedData.length() == 0) { | |||||
if (queuedData != null && queuedData.isEmpty()) { | |||||
queuedData = null; | 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(); | queuedData = readLine(); | ||||
if (queuedData == null) { | if (queuedData == null) { | ||||
ch = -1; | ch = -1; | ||||
@@ -116,6 +110,12 @@ public final class SuffixLines | |||||
} | } | ||||
return read(); | return read(); | ||||
} | } | ||||
} else { | |||||
ch = queuedData.charAt(0); | |||||
queuedData = queuedData.substring(1); | |||||
if (queuedData.isEmpty()) { | |||||
queuedData = null; | |||||
} | |||||
} | } | ||||
return ch; | return ch; | ||||
} | } | ||||
@@ -108,7 +108,7 @@ public final class TailFilter extends BaseParamFilterReader | |||||
setInitialized(true); | setInitialized(true); | ||||
} | } | ||||
while (line == null || line.length() == 0) { | |||||
while (line == null || line.isEmpty()) { | |||||
line = lineTokenizer.getToken(in); | line = lineTokenizer.getToken(in); | ||||
line = tailFilter(line); | line = tailFilter(line); | ||||
if (line == null) { | if (line == null) { | ||||
@@ -105,7 +105,7 @@ public class TokenFilter extends BaseFilterReader | |||||
if (tokenizer == null) { | if (tokenizer == null) { | ||||
tokenizer = new LineTokenizer(); | tokenizer = new LineTokenizer(); | ||||
} | } | ||||
while (line == null || line.length() == 0) { | |||||
while (line == null || line.isEmpty()) { | |||||
line = tokenizer.getToken(in); | line = tokenizer.getToken(in); | ||||
if (line == null) { | if (line == null) { | ||||
return -1; | return -1; | ||||
@@ -117,13 +117,11 @@ public class TokenFilter extends BaseFilterReader | |||||
} | } | ||||
} | } | ||||
linePos = 0; | 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 | * @return the trimmed line | ||||
*/ | */ | ||||
public String filter(String line) { | public String filter(String line) { | ||||
if (line.trim().length() == 0) { | |||||
if (line.trim().isEmpty()) { | |||||
return null; | return null; | ||||
} | } | ||||
return line; | return line; | ||||
@@ -467,7 +467,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
throws SAXParseException { | throws SAXParseException { | ||||
String s = new String(buf, start, count).trim(); | String s = new String(buf, start, count).trim(); | ||||
if (s.length() > 0) { | |||||
if (!s.isEmpty()) { | |||||
throw new SAXParseException("Unexpected text \"" + s + "\"", context.getLocator()); | throw new SAXParseException("Unexpected text \"" + s + "\"", context.getLocator()); | ||||
} | } | ||||
} | } | ||||
@@ -984,7 +984,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
target.getLocation()); | target.getLocation()); | ||||
} | } | ||||
Hashtable<String, Target> projectTargets = project.getTargets(); | Hashtable<String, Target> projectTargets = project.getTargets(); | ||||
boolean usedTarget = false; | |||||
boolean usedTarget = false; | |||||
// If the name has not already been defined define it | // If the name has not already been defined define it | ||||
if (projectTargets.containsKey(name)) { | if (projectTargets.containsKey(name)) { | ||||
project.log("Already defined in main or a previous import, ignore " + name, | project.log("Already defined in main or a previous import, ignore " + name, | ||||
@@ -996,7 +996,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
usedTarget = true; | usedTarget = true; | ||||
} | } | ||||
if (depends.length() > 0) { | |||||
if (!depends.isEmpty()) { | |||||
if (!isInIncludeMode) { | if (!isInIncludeMode) { | ||||
target.setDepends(depends); | target.setDepends(depends); | ||||
} else { | } else { | ||||
@@ -1052,7 +1052,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
private String getTargetPrefix(AntXMLContext context) { | private String getTargetPrefix(AntXMLContext context) { | ||||
String configuredValue = getCurrentTargetPrefix(); | String configuredValue = getCurrentTargetPrefix(); | ||||
if (configuredValue != null && configuredValue.length() == 0) { | |||||
if (configuredValue != null && configuredValue.isEmpty()) { | |||||
configuredValue = null; | configuredValue = null; | ||||
} | } | ||||
if (configuredValue != null) { | if (configuredValue != null) { | ||||
@@ -246,7 +246,7 @@ public class ProjectHelperImpl extends ProjectHelper { | |||||
public void characters(char[] buf, int start, int count) throws SAXParseException { | public void characters(char[] buf, int start, int count) throws SAXParseException { | ||||
String s = new String(buf, start, count).trim(); | String s = new String(buf, start, count).trim(); | ||||
if (s.length() > 0) { | |||||
if (!s.isEmpty()) { | |||||
throw new SAXParseException("Unexpected text \"" + s + "\"", helperImpl.locator); | throw new SAXParseException("Unexpected text \"" + s + "\"", helperImpl.locator); | ||||
} | } | ||||
} | } | ||||
@@ -579,7 +579,7 @@ public class ProjectHelperImpl extends ProjectHelper { | |||||
// take care of dependencies | // take care of dependencies | ||||
if (depends.length() > 0) { | |||||
if (!depends.isEmpty()) { | |||||
target.setDepends(depends); | target.setDepends(depends); | ||||
} | } | ||||
} | } | ||||
@@ -370,15 +370,15 @@ public class MailLogger extends DefaultLogger { | |||||
mailMessage.setSubject(values.subject()); | 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() | mailMessage.setHeader("Content-Type", values.mimeType() | ||||
+ "; charset=\"" + values.charset() + "\""); | + "; charset=\"" + values.charset() + "\""); | ||||
} else { | |||||
mailMessage.setHeader("Content-Type", values.mimeType()); | |||||
} | } | ||||
PrintStream ps = mailMessage.getPrintStream(); | PrintStream ps = mailMessage.getPrintStream(); | ||||
ps.println(values.body().length() > 0 ? values.body() : message); | |||||
ps.println(values.body().isEmpty() ? message : values.body()); | |||||
mailMessage.sendAndClose(); | mailMessage.sendAndClose(); | ||||
} | } | ||||
@@ -408,10 +408,10 @@ public class MailLogger extends DefaultLogger { | |||||
mailer.setSSL(values.ssl()); | mailer.setSSL(values.ssl()); | ||||
mailer.setEnableStartTLS(values.starttls()); | mailer.setEnableStartTLS(values.starttls()); | ||||
Message mymessage = | Message mymessage = | ||||
new Message(values.body().length() > 0 ? values.body() : message); | |||||
new Message(!values.body().isEmpty() ? values.body() : message); | |||||
mymessage.setProject(project); | mymessage.setProject(project); | ||||
mymessage.setMimeType(values.mimeType()); | mymessage.setMimeType(values.mimeType()); | ||||
if (values.charset().length() > 0) { | |||||
if (!values.charset().isEmpty()) { | |||||
mymessage.setCharset(values.charset()); | mymessage.setCharset(values.charset()); | ||||
} | } | ||||
mailer.setMessage(mymessage); | mailer.setMessage(mymessage); | ||||
@@ -488,7 +488,7 @@ public class Ant extends Task { | |||||
Set<String> set = new HashSet<>(); | Set<String> set = new HashSet<>(); | ||||
for (int i = properties.size() - 1; i >= 0; --i) { | for (int i = properties.size() - 1; i >= 0; --i) { | ||||
Property p = properties.get(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())) { | if (set.contains(p.getName())) { | ||||
properties.remove(i); | properties.remove(i); | ||||
} else { | } else { | ||||
@@ -141,12 +141,10 @@ public class Exit extends Task { | |||||
if (message != null && !message.trim().isEmpty()) { | if (message != null && !message.trim().isEmpty()) { | ||||
text = message.trim(); | text = message.trim(); | ||||
} else { | } else { | ||||
if (ifCondition != null && !"".equals(ifCondition) | |||||
&& testIfCondition()) { | |||||
if (!isNullOrEmpty(ifCondition) && testIfCondition()) { | |||||
text = "if=" + ifCondition; | text = "if=" + ifCondition; | ||||
} | } | ||||
if (unlessCondition != null && !"".equals(unlessCondition) | |||||
&& testUnlessCondition()) { | |||||
if (!isNullOrEmpty(unlessCondition) && testUnlessCondition()) { | |||||
if (text == null) { | if (text == null) { | ||||
text = ""; | text = ""; | ||||
} else { | } else { | ||||
@@ -166,6 +164,10 @@ public class Exit extends Task { | |||||
} | } | ||||
} | } | ||||
private boolean isNullOrEmpty(Object value) { | |||||
return value == null || "".equals(value); | |||||
} | |||||
/** | /** | ||||
* Set a multiline message. | * Set a multiline message. | ||||
* @param msg the message to display | * @param msg the message to display | ||||
@@ -273,7 +273,7 @@ public class Get extends Task { | |||||
*/ | */ | ||||
private void checkAttributes() { | 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"); | throw new BuildException("userAgent may not be null or empty"); | ||||
} | } | ||||
@@ -1055,7 +1055,7 @@ public class Javadoc extends Task { | |||||
final String linkOfflineError = "The linkoffline attribute must include" | final String linkOfflineError = "The linkoffline attribute must include" | ||||
+ " a URL and a package-list file location separated by a" | + " a URL and a package-list file location separated by a" | ||||
+ " space"; | + " space"; | ||||
if (src.trim().length() == 0) { | |||||
if (src.trim().isEmpty()) { | |||||
throw new BuildException(linkOfflineError); | throw new BuildException(linkOfflineError); | ||||
} | } | ||||
final StringTokenizer tok = new StringTokenizer(src, " ", false); | final StringTokenizer tok = new StringTokenizer(src, " ", false); | ||||
@@ -72,7 +72,7 @@ public class KeySubst extends Task { | |||||
String newline = null; | String newline = null; | ||||
line = br.readLine(); | line = br.readLine(); | ||||
while (line != null) { | while (line != null) { | ||||
if (line.length() == 0) { | |||||
if (line.isEmpty()) { | |||||
bw.newLine(); | bw.newLine(); | ||||
} else { | } else { | ||||
newline = KeySubst.replace(line, replacements); | newline = KeySubst.replace(line, replacements); | ||||
@@ -128,7 +128,7 @@ public class KeySubst extends Task { | |||||
* @param keys a <code>String</code> value | * @param keys a <code>String</code> value | ||||
*/ | */ | ||||
public void setKeys(String keys) { | public void setKeys(String keys) { | ||||
if (keys != null && keys.length() > 0) { | |||||
if (keys != null && !keys.isEmpty()) { | |||||
StringTokenizer tok = | StringTokenizer tok = | ||||
new StringTokenizer(keys, this.sep, false); | new StringTokenizer(keys, this.sep, false); | ||||
while (tok.hasMoreTokens()) { | while (tok.hasMoreTokens()) { | ||||
@@ -237,7 +237,7 @@ public class MacroDef extends AntlibDefinition { | |||||
* @return true if the name consists of valid name characters | * @return true if the name consists of valid name characters | ||||
*/ | */ | ||||
private static boolean isValidName(String name) { | private static boolean isValidName(String name) { | ||||
if (name.length() == 0) { | |||||
if (name.isEmpty()) { | |||||
return false; | return false; | ||||
} | } | ||||
for (int i = 0; i < name.length(); ++i) { | for (int i = 0; i < name.length(); ++i) { | ||||
@@ -724,9 +724,9 @@ public class MacroDef extends AntlibDefinition { | |||||
} else if (!text.equals(other.text)) { | } else if (!text.equals(other.text)) { | ||||
return false; | return false; | ||||
} | } | ||||
if (getURI() == null || "".equals(getURI()) | |||||
if (getURI() == null || getURI().isEmpty() | |||||
|| getURI().equals(ProjectHelper.ANT_CORE_URI)) { | || 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)) { | && !other.getURI().equals(ProjectHelper.ANT_CORE_URI)) { | ||||
return false; | return false; | ||||
} | } | ||||
@@ -136,7 +136,7 @@ public abstract class MatchingTask extends Task implements SelectorContainer { | |||||
StringTokenizer tok = new StringTokenizer(itemString, ", "); | StringTokenizer tok = new StringTokenizer(itemString, ", "); | ||||
while (tok.hasMoreTokens()) { | while (tok.hasMoreTokens()) { | ||||
String pattern = tok.nextToken().trim(); | String pattern = tok.nextToken().trim(); | ||||
if (pattern.length() > 0) { | |||||
if (!pattern.isEmpty()) { | |||||
createInclude().setName(pattern + "/**"); | createInclude().setName(pattern + "/**"); | ||||
} | } | ||||
} | } | ||||
@@ -569,7 +569,7 @@ public class SubAnt extends Task { | |||||
private Ant createAntTask(File directory) { | private Ant createAntTask(File directory) { | ||||
Ant antTask = new Ant(this); | Ant antTask = new Ant(this); | ||||
antTask.init(); | antTask.init(); | ||||
if (subTarget != null && subTarget.length() > 0) { | |||||
if (subTarget != null && !subTarget.isEmpty()) { | |||||
antTask.setTarget(subTarget); | antTask.setTarget(subTarget); | ||||
} | } | ||||
@@ -399,11 +399,9 @@ public class Tar extends MatchingTask { | |||||
if (tarFileSet != null) { | if (tarFileSet != null) { | ||||
final String fullpath = tarFileSet.getFullpath(this.getProject()); | final String fullpath = tarFileSet.getFullpath(this.getProject()); | ||||
if (fullpath.length() > 0) { | |||||
vPath = fullpath; | |||||
} else { | |||||
if (fullpath.isEmpty()) { | |||||
// don't add "" to the archive | // don't add "" to the archive | ||||
if (vPath.length() <= 0) { | |||||
if (vPath.isEmpty()) { | |||||
return; | return; | ||||
} | } | ||||
@@ -413,6 +411,8 @@ public class Tar extends MatchingTask { | |||||
prefix += "/"; | prefix += "/"; | ||||
} | } | ||||
vPath = prefix + vPath; | vPath = prefix + vPath; | ||||
} else { | |||||
vPath = fullpath; | |||||
} | } | ||||
preserveLeadingSlashes = tarFileSet.getPreserveLeadingSlashes(); | preserveLeadingSlashes = tarFileSet.getPreserveLeadingSlashes(); | ||||
@@ -144,7 +144,7 @@ public class Tstamp extends Task { | |||||
*/ | */ | ||||
protected Optional<Date> getNow(String propertyName, Function<String, Date> map, BiFunction<String, String, String> log) { | protected Optional<Date> getNow(String propertyName, Function<String, Date> map, BiFunction<String, String, String> log) { | ||||
String property = getProject().getProperty(propertyName); | String property = getProject().getProperty(propertyName); | ||||
if (property != null && property.length() > 0) { | |||||
if (property != null && !property.isEmpty()) { | |||||
try { | try { | ||||
return Optional.ofNullable(map.apply(property)); | return Optional.ofNullable(map.apply(property)); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
@@ -290,7 +290,7 @@ public class XmlProperty extends Task { | |||||
// Set the prefix for this node to include its tag name. | // Set the prefix for this node to include its tag name. | ||||
String nodePrefix = prefix; | String nodePrefix = prefix; | ||||
if (node.getNodeType() != Node.TEXT_NODE) { | if (node.getNodeType() != Node.TEXT_NODE) { | ||||
if (prefix.trim().length() > 0) { | |||||
if (!prefix.trim().isEmpty()) { | |||||
nodePrefix += "."; | nodePrefix += "."; | ||||
} | } | ||||
nodePrefix += node.getNodeName(); | nodePrefix += node.getNodeName(); | ||||
@@ -936,12 +936,12 @@ public class Zip extends MatchingTask { | |||||
fileMode = zfs.getFileMode(getProject()); | fileMode = zfs.getFileMode(getProject()); | ||||
} | } | ||||
if (prefix.length() > 0 && fullpath.length() > 0) { | |||||
if (!prefix.isEmpty() && !fullpath.isEmpty()) { | |||||
throw new BuildException( | throw new BuildException( | ||||
"Both prefix and fullpath attributes must not be set on the same fileset."); | "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( | throw new BuildException( | ||||
"fullpath attribute may only be specified for filesets that specify a single file."); | "fullpath attribute may only be specified for filesets that specify a single file."); | ||||
} | } | ||||
@@ -125,10 +125,10 @@ public class IsReachable extends ProjectComponent implements Condition { | |||||
* | * | ||||
* @param string param to check | * @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 | @Override | ||||
public boolean eval() throws BuildException { | public boolean eval() throws BuildException { | ||||
if (empty(host) && empty(url)) { | |||||
if (isNullOrEmpty(host) && isNullOrEmpty(url)) { | |||||
throw new BuildException(ERROR_NO_HOSTNAME); | throw new BuildException(ERROR_NO_HOSTNAME); | ||||
} | } | ||||
if (timeout < 0) { | if (timeout < 0) { | ||||
throw new BuildException(ERROR_BAD_TIMEOUT); | throw new BuildException(ERROR_BAD_TIMEOUT); | ||||
} | } | ||||
String target = host; | String target = host; | ||||
if (!empty(url)) { | |||||
if (!empty(host)) { | |||||
if (!isNullOrEmpty(url)) { | |||||
if (!isNullOrEmpty(host)) { | |||||
throw new BuildException(ERROR_BOTH_TARGETS); | throw new BuildException(ERROR_BOTH_TARGETS); | ||||
} | } | ||||
try { | try { | ||||
//get the host of a url | //get the host of a url | ||||
final URL realURL = new URL(url); | final URL realURL = new URL(url); | ||||
target = realURL.getHost(); | target = realURL.getHost(); | ||||
if (empty(target)) { | |||||
if (isNullOrEmpty(target)) { | |||||
throw new BuildException(ERROR_NO_HOST_IN_URL + url); | throw new BuildException(ERROR_NO_HOST_IN_URL + url); | ||||
} | } | ||||
} catch (final MalformedURLException e) { | } catch (final MalformedURLException e) { | ||||
@@ -135,7 +135,7 @@ public class ResourceContains implements Condition { | |||||
public synchronized boolean eval() throws BuildException { | public synchronized boolean eval() throws BuildException { | ||||
validate(); | validate(); | ||||
if (substring.length() == 0) { | |||||
if (substring.isEmpty()) { | |||||
if (getProject() != null) { | if (getProject() != null) { | ||||
getProject().log("Substring is empty; returning true", | getProject().log("Substring is empty; returning true", | ||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
@@ -184,7 +184,7 @@ public class EchoProperties extends Task { | |||||
* @param prefix The new prefix value | * @param prefix The new prefix value | ||||
*/ | */ | ||||
public void setPrefix(String prefix) { | public void setPrefix(String prefix) { | ||||
if (prefix != null && prefix.length() != 0) { | |||||
if (prefix != null && !prefix.isEmpty()) { | |||||
this.prefix = prefix; | this.prefix = prefix; | ||||
PropertySet ps = new PropertySet(); | PropertySet ps = new PropertySet(); | ||||
ps.setProject(getProject()); | ps.setProject(getProject()); | ||||
@@ -365,7 +365,7 @@ public class ReplaceRegExp extends Task { | |||||
log("Replacing pattern '" + regex.getPattern(getProject()) | log("Replacing pattern '" + regex.getPattern(getProject()) | ||||
+ "' with '" + subs.getExpression(getProject()) | + "' with '" + subs.getExpression(getProject()) | ||||
+ "' in '" + f.getPath() + "'" + (byline ? " by line" : "") | + "' in '" + f.getPath() + "'" + (byline ? " by line" : "") | ||||
+ (flags.length() > 0 ? " with flags: '" + flags + "'" : "") | |||||
+ (flags.isEmpty() ? "" : " with flags: '" + flags + "'") | |||||
+ ".", Project.MSG_VERBOSE); | + ".", Project.MSG_VERBOSE); | ||||
if (byline) { | if (byline) { | ||||
@@ -417,7 +417,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||||
// Lastly create File object for the Jar files. If we are using | // Lastly create File object for the Jar files. If we are using | ||||
// a flat destination dir, then we need to redefine baseName! | // 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); | int startName = baseName.lastIndexOf(File.separator); | ||||
if (startName == -1) { | if (startName == -1) { | ||||
startName = 0; | startName = 0; | ||||
@@ -553,7 +553,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool { | |||||
javaTask.createArg().setValue(destJar.getPath()); | javaTask.createArg().setValue(destJar.getPath()); | ||||
javaTask.createArg().setLine(getOptions()); | javaTask.createArg().setLine(getOptions()); | ||||
if (getCombinedClasspath() != null | if (getCombinedClasspath() != null | ||||
&& getCombinedClasspath().toString().length() > 0) { | |||||
&& !getCombinedClasspath().toString().isEmpty()) { | |||||
javaTask.createArg().setValue("-cp"); | javaTask.createArg().setValue("-cp"); | ||||
javaTask.createArg().setValue(getCombinedClasspath().toString()); | javaTask.createArg().setValue(getCombinedClasspath().toString()); | ||||
} | } | ||||
@@ -365,12 +365,9 @@ public class Translate extends MatchingTask { | |||||
bundleCountry, | bundleCountry, | ||||
bundleVariant); | 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 + variant, BUNDLE_SPECIFIED_LANGUAGE_COUNTRY_VARIANT, false); | ||||
processBundle(bundle + language + country, BUNDLE_SPECIFIED_LANGUAGE_COUNTRY, false); | processBundle(bundle + language + country, BUNDLE_SPECIFIED_LANGUAGE_COUNTRY, false); | ||||
@@ -381,12 +378,9 @@ public class Translate extends MatchingTask { | |||||
//using default file encoding scheme. | //using default file encoding scheme. | ||||
locale = Locale.getDefault(); | 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"); | bundleEncoding = System.getProperty("file.encoding"); | ||||
processBundle(bundle + language + country + variant, BUNDLE_DEFAULT_LANGUAGE_COUNTRY_VARIANT, false); | processBundle(bundle + language + country + variant, BUNDLE_DEFAULT_LANGUAGE_COUNTRY_VARIANT, false); | ||||
@@ -456,7 +450,7 @@ public class Translate extends MatchingTask { | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (key.length() > 0) { | |||||
if (!key.isEmpty()) { | |||||
//Has key already been loaded into resourceMap? | //Has key already been loaded into resourceMap? | ||||
resourceMap.putIfAbsent(key, value); | resourceMap.putIfAbsent(key, value); | ||||
} | } | ||||
@@ -556,7 +556,7 @@ public class JDependTask extends Task { | |||||
// not sure whether this test is needed but cost nothing to put. | // not sure whether this test is needed but cost nothing to put. | ||||
// hope it will be reviewed by anybody competent | // hope it will be reviewed by anybody competent | ||||
if (getClasspath().toString().length() > 0) { | |||||
if (!getClasspath().toString().isEmpty()) { | |||||
createJvmarg(commandline).setValue("-classpath"); | createJvmarg(commandline).setValue("-classpath"); | ||||
createJvmarg(commandline).setValue(getClasspath().toString()); | createJvmarg(commandline).setValue(getClasspath().toString()); | ||||
} | } | ||||
@@ -174,7 +174,7 @@ public class WLJspc extends MatchingTask { | |||||
File jspFile = new File(filename); | File jspFile = new File(filename); | ||||
args[j] = "-package"; | args[j] = "-package"; | ||||
String parents = jspFile.getParent(); | String parents = jspFile.getParent(); | ||||
if (parents == null || "".equals(parents)) { | |||||
if (parents == null || parents.isEmpty()) { | |||||
args[j + 1] = destinationPackage; | args[j + 1] = destinationPackage; | ||||
} else { | } else { | ||||
parents = this.replaceString(parents, File.separator, "_."); | parents = this.replaceString(parents, File.separator, "_."); | ||||
@@ -265,7 +265,7 @@ public class WLJspc extends MatchingTask { | |||||
String parents = jspFile.getParent(); | String parents = jspFile.getParent(); | ||||
String pack; | String pack; | ||||
if (parents == null || "".equals(parents)) { | |||||
if (parents == null || parents.isEmpty()) { | |||||
pack = pathToPackage; | pack = pathToPackage; | ||||
} else { | } else { | ||||
parents = this.replaceString(parents, File.separator, "_/"); | parents = this.replaceString(parents, File.separator, "_/"); | ||||
@@ -87,7 +87,7 @@ public abstract class DefaultJspCompilerAdapter | |||||
* @param argument The argument | * @param argument The argument | ||||
*/ | */ | ||||
protected void addArg(CommandlineJava cmd, String argument) { | protected void addArg(CommandlineJava cmd, String argument) { | ||||
if (argument != null && argument.length() != 0) { | |||||
if (argument != null && !argument.isEmpty()) { | |||||
cmd.createArgument().setValue(argument); | cmd.createArgument().setValue(argument); | ||||
} | } | ||||
} | } | ||||
@@ -152,7 +152,7 @@ public class BriefJUnitResultFormatter implements JUnitResultFormatter, IgnoredT | |||||
sb.append(StringUtils.LINE_SEP); | sb.append(StringUtils.LINE_SEP); | ||||
// append the err and output streams to the log | // append the err and output streams to the log | ||||
if (systemOutput != null && systemOutput.length() > 0) { | |||||
if (systemOutput != null && !systemOutput.isEmpty()) { | |||||
sb.append("------------- Standard Output ---------------") | sb.append("------------- Standard Output ---------------") | ||||
.append(StringUtils.LINE_SEP) | .append(StringUtils.LINE_SEP) | ||||
.append(systemOutput) | .append(systemOutput) | ||||
@@ -160,7 +160,7 @@ public class BriefJUnitResultFormatter implements JUnitResultFormatter, IgnoredT | |||||
.append(StringUtils.LINE_SEP); | .append(StringUtils.LINE_SEP); | ||||
} | } | ||||
if (systemError != null && systemError.length() > 0) { | |||||
if (systemError != null && !systemError.isEmpty()) { | |||||
sb.append("------------- Standard Error -----------------") | sb.append("------------- Standard Error -----------------") | ||||
.append(StringUtils.LINE_SEP) | .append(StringUtils.LINE_SEP) | ||||
.append(systemError) | .append(systemError) | ||||
@@ -67,7 +67,7 @@ public class JUnit4TestMethodAdapter implements Test { | |||||
if (methodNames[i] == null) { | if (methodNames[i] == null) { | ||||
throw new IllegalArgumentException("method name #" + i + " is <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"); | throw new IllegalArgumentException("method name #" + i + " is empty"); | ||||
} | } | ||||
} | } | ||||
@@ -155,7 +155,7 @@ public class JUnitVersionHelper { | |||||
if (annotation != null) { | if (annotation != null) { | ||||
Method valueMethod = annotation.annotationType().getMethod("value"); | Method valueMethod = annotation.annotationType().getMethod("value"); | ||||
String value = (String) valueMethod.invoke(annotation); | String value = (String) valueMethod.invoke(annotation); | ||||
if (value != null && value.length() > 0) { | |||||
if (value != null && !value.isEmpty()) { | |||||
message = value; | message = value; | ||||
} | } | ||||
} | } | ||||
@@ -127,7 +127,7 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter, IgnoredT | |||||
nf.format(suite.getRunTime() / ONE_SECOND))); | nf.format(suite.getRunTime() / ONE_SECOND))); | ||||
// write the err and output streams to the log | // write the err and output streams to the log | ||||
if (systemOutput != null && systemOutput.length() > 0) { | |||||
if (systemOutput != null && !systemOutput.isEmpty()) { | |||||
write("------------- Standard Output ---------------"); | write("------------- Standard Output ---------------"); | ||||
write(StringUtils.LINE_SEP); | write(StringUtils.LINE_SEP); | ||||
write(systemOutput); | write(systemOutput); | ||||
@@ -135,7 +135,7 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter, IgnoredT | |||||
write(StringUtils.LINE_SEP); | write(StringUtils.LINE_SEP); | ||||
} | } | ||||
if (systemError != null && systemError.length() > 0) { | |||||
if (systemError != null && !systemError.isEmpty()) { | |||||
write("------------- Standard Error -----------------"); | write("------------- Standard Error -----------------"); | ||||
write(StringUtils.LINE_SEP); | write(StringUtils.LINE_SEP); | ||||
write(systemError); | write(systemError); | ||||
@@ -190,11 +190,11 @@ public class SummaryJUnitResultFormatter | |||||
sb.append(System.lineSeparator()); | sb.append(System.lineSeparator()); | ||||
if (withOutAndErr) { | if (withOutAndErr) { | ||||
if (systemOutput != null && systemOutput.length() > 0) { | |||||
if (systemOutput != null && !systemOutput.isEmpty()) { | |||||
sb.append(String.format("Output:%n%s%n", systemOutput)); | 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)); | sb.append(String.format("Output:%n%s%n", systemError)); | ||||
} | } | ||||
} | } | ||||
@@ -313,7 +313,7 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
currentTest.appendChild(nested); | currentTest.appendChild(nested); | ||||
final String message = t.getMessage(); | 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_MESSAGE, t.getMessage()); | ||||
} | } | ||||
nested.setAttribute(ATTR_TYPE, t.getClass().getName()); | nested.setAttribute(ATTR_TYPE, t.getClass().getName()); | ||||
@@ -467,22 +467,19 @@ public class FTP extends Task implements FTPTaskConfig { | |||||
} | } | ||||
if (myfile.isDirectory()) { | if (myfile.isDirectory()) { | ||||
if (isIncluded(currentelement) | |||||
&& currentelement.length() > 0) { | |||||
if (isIncluded(currentelement) && !currentelement.isEmpty()) { | |||||
accountForIncludedDir(currentelement, myfile, true); | accountForIncludedDir(currentelement, myfile, true); | ||||
} else { | |||||
if (currentelement.length() > 0 | |||||
} else { | |||||
if (!currentelement.isEmpty() | |||||
&& currentelement.charAt(currentelement.length() - 1) | && currentelement.charAt(currentelement.length() - 1) | ||||
!= File.separatorChar) { | != File.separatorChar) { | ||||
currentelement += File.separatorChar; | currentelement += File.separatorChar; | ||||
} | } | ||||
scandir(myfile.getAbsolutePath(), currentelement, true); | scandir(myfile.getAbsolutePath(), currentelement, true); | ||||
} | } | ||||
} else if (isCaseSensitive | |||||
&& originalpattern.equals(currentelement)) { | |||||
} else if (isCaseSensitive && originalpattern.equals(currentelement)) { | |||||
accountForIncludedFile(currentelement); | accountForIncludedFile(currentelement); | ||||
} else if (!isCaseSensitive && originalpattern | |||||
.equalsIgnoreCase(currentelement)) { | |||||
} else if (!isCaseSensitive && originalpattern.equalsIgnoreCase(currentelement)) { | |||||
accountForIncludedFile(currentelement); | accountForIncludedFile(currentelement); | ||||
} | } | ||||
} | } | ||||
@@ -1490,7 +1487,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||||
* @see org.apache.commons.net.ftp.FTPClientConfig | * @see org.apache.commons.net.ftp.FTPClientConfig | ||||
*/ | */ | ||||
public void setSystemTypeKey(FTPSystemType systemKey) { | public void setSystemTypeKey(FTPSystemType systemKey) { | ||||
if (systemKey != null && !"".equals(systemKey.getValue())) { | |||||
if (systemKey != null && !systemKey.getValue().isEmpty()) { | |||||
this.systemTypeKey = systemKey; | this.systemTypeKey = systemKey; | ||||
configurationHasBeenSet(); | configurationHasBeenSet(); | ||||
} | } | ||||
@@ -1503,7 +1500,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||||
* @see org.apache.commons.net.ftp.FTPClientConfig | * @see org.apache.commons.net.ftp.FTPClientConfig | ||||
*/ | */ | ||||
public void setDefaultDateFormatConfig(String defaultDateFormat) { | public void setDefaultDateFormatConfig(String defaultDateFormat) { | ||||
if (defaultDateFormat != null && !"".equals(defaultDateFormat)) { | |||||
if (defaultDateFormat != null && !defaultDateFormat.isEmpty()) { | |||||
this.defaultDateFormatConfig = defaultDateFormat; | this.defaultDateFormatConfig = defaultDateFormat; | ||||
configurationHasBeenSet(); | configurationHasBeenSet(); | ||||
} | } | ||||
@@ -1516,7 +1513,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||||
* @see org.apache.commons.net.ftp.FTPClientConfig | * @see org.apache.commons.net.ftp.FTPClientConfig | ||||
*/ | */ | ||||
public void setRecentDateFormatConfig(String recentDateFormat) { | public void setRecentDateFormatConfig(String recentDateFormat) { | ||||
if (recentDateFormat != null && !"".equals(recentDateFormat)) { | |||||
if (recentDateFormat != null && !recentDateFormat.isEmpty()) { | |||||
this.recentDateFormatConfig = recentDateFormat; | this.recentDateFormatConfig = recentDateFormat; | ||||
configurationHasBeenSet(); | configurationHasBeenSet(); | ||||
} | } | ||||
@@ -1542,7 +1539,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||||
* @see org.apache.commons.net.ftp.FTPClientConfig | * @see org.apache.commons.net.ftp.FTPClientConfig | ||||
*/ | */ | ||||
public void setServerTimeZoneConfig(String serverTimeZoneId) { | public void setServerTimeZoneConfig(String serverTimeZoneId) { | ||||
if (serverTimeZoneId != null && !"".equals(serverTimeZoneId)) { | |||||
if (serverTimeZoneId != null && !serverTimeZoneId.isEmpty()) { | |||||
this.serverTimeZoneConfig = serverTimeZoneId; | this.serverTimeZoneConfig = serverTimeZoneId; | ||||
configurationHasBeenSet(); | configurationHasBeenSet(); | ||||
} | } | ||||
@@ -1556,7 +1553,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||||
* @see org.apache.commons.net.ftp.FTPClientConfig | * @see org.apache.commons.net.ftp.FTPClientConfig | ||||
*/ | */ | ||||
public void setShortMonthNamesConfig(String shortMonthNames) { | public void setShortMonthNamesConfig(String shortMonthNames) { | ||||
if (shortMonthNames != null && !"".equals(shortMonthNames)) { | |||||
if (shortMonthNames != null && !shortMonthNames.isEmpty()) { | |||||
this.shortMonthNamesConfig = shortMonthNames; | this.shortMonthNamesConfig = shortMonthNames; | ||||
configurationHasBeenSet(); | configurationHasBeenSet(); | ||||
} | } | ||||
@@ -1652,7 +1649,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||||
* @param timestampGranularity The timestampGranularity to set. | * @param timestampGranularity The timestampGranularity to set. | ||||
*/ | */ | ||||
public void setTimestampGranularity(Granularity timestampGranularity) { | public void setTimestampGranularity(Granularity timestampGranularity) { | ||||
if (null == timestampGranularity || "".equals(timestampGranularity.getValue())) { | |||||
if (null == timestampGranularity || timestampGranularity.getValue().isEmpty()) { | |||||
return; | return; | ||||
} | } | ||||
this.timestampGranularity = timestampGranularity; | this.timestampGranularity = timestampGranularity; | ||||
@@ -43,7 +43,7 @@ class FTPConfigurator { | |||||
task.log("custom configuration", Project.MSG_VERBOSE); | task.log("custom configuration", Project.MSG_VERBOSE); | ||||
FTPClientConfig config; | FTPClientConfig config; | ||||
String systemTypeKey = task.getSystemTypeKey(); | String systemTypeKey = task.getSystemTypeKey(); | ||||
if (systemTypeKey != null && !"".equals(systemTypeKey)) { | |||||
if (systemTypeKey != null && !systemTypeKey.isEmpty()) { | |||||
config = new FTPClientConfig(systemTypeKey); | config = new FTPClientConfig(systemTypeKey); | ||||
task.log("custom config: system key = " | task.log("custom config: system key = " | ||||
+ systemTypeKey, Project.MSG_VERBOSE); | + systemTypeKey, Project.MSG_VERBOSE); | ||||
@@ -69,7 +69,7 @@ class FTPConfigurator { | |||||
String serverLanguageCodeConfig = task.getServerLanguageCodeConfig(); | String serverLanguageCodeConfig = task.getServerLanguageCodeConfig(); | ||||
if (serverLanguageCodeConfig != null) { | if (serverLanguageCodeConfig != null) { | ||||
if (!"".equals(serverLanguageCodeConfig) | |||||
if (!serverLanguageCodeConfig.isEmpty() | |||||
&& !FTPClientConfig.getSupportedLanguageCodes() | && !FTPClientConfig.getSupportedLanguageCodes() | ||||
.contains(serverLanguageCodeConfig)) { | .contains(serverLanguageCodeConfig)) { | ||||
throw new BuildException("unsupported language code" + | throw new BuildException("unsupported language code" + | ||||
@@ -504,7 +504,7 @@ public class FTPTask extends Task implements FTPTaskConfig { | |||||
* @see org.apache.commons.net.ftp.FTPClientConfig | * @see org.apache.commons.net.ftp.FTPClientConfig | ||||
*/ | */ | ||||
public void setSystemTypeKey(FTPSystemType systemKey) { | public void setSystemTypeKey(FTPSystemType systemKey) { | ||||
if (systemKey != null && !"".equals(systemKey.getValue())) { | |||||
if (systemKey != null && !systemKey.getValue().isEmpty()) { | |||||
this.systemTypeKey = systemKey; | this.systemTypeKey = systemKey; | ||||
configurationHasBeenSet(); | configurationHasBeenSet(); | ||||
} | } | ||||
@@ -517,7 +517,7 @@ public class FTPTask extends Task implements FTPTaskConfig { | |||||
* @see org.apache.commons.net.ftp.FTPClientConfig | * @see org.apache.commons.net.ftp.FTPClientConfig | ||||
*/ | */ | ||||
public void setDefaultDateFormatConfig(String defaultDateFormat) { | public void setDefaultDateFormatConfig(String defaultDateFormat) { | ||||
if (defaultDateFormat != null && !"".equals(defaultDateFormat)) { | |||||
if (defaultDateFormat != null && !defaultDateFormat.isEmpty()) { | |||||
this.defaultDateFormatConfig = defaultDateFormat; | this.defaultDateFormatConfig = defaultDateFormat; | ||||
configurationHasBeenSet(); | configurationHasBeenSet(); | ||||
} | } | ||||
@@ -530,7 +530,7 @@ public class FTPTask extends Task implements FTPTaskConfig { | |||||
* @see org.apache.commons.net.ftp.FTPClientConfig | * @see org.apache.commons.net.ftp.FTPClientConfig | ||||
*/ | */ | ||||
public void setRecentDateFormatConfig(String recentDateFormat) { | public void setRecentDateFormatConfig(String recentDateFormat) { | ||||
if (recentDateFormat != null && !"".equals(recentDateFormat)) { | |||||
if (recentDateFormat != null && recentDateFormat.isEmpty()) { | |||||
this.recentDateFormatConfig = recentDateFormat; | this.recentDateFormatConfig = recentDateFormat; | ||||
configurationHasBeenSet(); | configurationHasBeenSet(); | ||||
} | } | ||||
@@ -556,7 +556,7 @@ public class FTPTask extends Task implements FTPTaskConfig { | |||||
* @see org.apache.commons.net.ftp.FTPClientConfig | * @see org.apache.commons.net.ftp.FTPClientConfig | ||||
*/ | */ | ||||
public void setServerTimeZoneConfig(String serverTimeZoneId) { | public void setServerTimeZoneConfig(String serverTimeZoneId) { | ||||
if (serverTimeZoneId != null && !"".equals(serverTimeZoneId)) { | |||||
if (serverTimeZoneId != null && serverTimeZoneId.isEmpty()) { | |||||
this.serverTimeZoneConfig = serverTimeZoneId; | this.serverTimeZoneConfig = serverTimeZoneId; | ||||
configurationHasBeenSet(); | configurationHasBeenSet(); | ||||
} | } | ||||
@@ -570,7 +570,7 @@ public class FTPTask extends Task implements FTPTaskConfig { | |||||
* @see org.apache.commons.net.ftp.FTPClientConfig | * @see org.apache.commons.net.ftp.FTPClientConfig | ||||
*/ | */ | ||||
public void setShortMonthNamesConfig(String shortMonthNames) { | public void setShortMonthNamesConfig(String shortMonthNames) { | ||||
if (shortMonthNames != null && !"".equals(shortMonthNames)) { | |||||
if (shortMonthNames != null && !shortMonthNames.isEmpty()) { | |||||
this.shortMonthNamesConfig = shortMonthNames; | this.shortMonthNamesConfig = shortMonthNames; | ||||
configurationHasBeenSet(); | configurationHasBeenSet(); | ||||
} | } | ||||
@@ -671,7 +671,7 @@ public class FTPTask extends Task implements FTPTaskConfig { | |||||
* @param timestampGranularity The timestampGranularity to set. | * @param timestampGranularity The timestampGranularity to set. | ||||
*/ | */ | ||||
public void setTimestampGranularity(Granularity timestampGranularity) { | public void setTimestampGranularity(Granularity timestampGranularity) { | ||||
if (null == timestampGranularity || "".equals(timestampGranularity.getValue())) { | |||||
if (null == timestampGranularity || timestampGranularity.getValue().isEmpty()) { | |||||
return; | return; | ||||
} | } | ||||
this.timestampGranularity = timestampGranularity; | this.timestampGranularity = timestampGranularity; | ||||
@@ -359,12 +359,10 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||||
} | } | ||||
if (myfile.isDirectory()) { | if (myfile.isDirectory()) { | ||||
if (isIncluded(currentelement) | |||||
&& currentelement.length() > 0) { | |||||
if (isIncluded(currentelement) && !currentelement.isEmpty()) { | |||||
accountForIncludedDir(currentelement, myfile, true); | 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) { | != File.separatorChar) { | ||||
currentelement += File.separatorChar; | currentelement += File.separatorChar; | ||||
} | } | ||||
@@ -181,7 +181,7 @@ public class SetProxy extends Task { | |||||
Properties sysprops = System.getProperties(); | Properties sysprops = System.getProperties(); | ||||
if (proxyHost != null) { | if (proxyHost != null) { | ||||
settingsChanged = true; | settingsChanged = true; | ||||
if (proxyHost.length() != 0) { | |||||
if (!proxyHost.isEmpty()) { | |||||
traceSettingInfo(); | traceSettingInfo(); | ||||
enablingProxy = true; | enablingProxy = true; | ||||
sysprops.put(ProxySetup.HTTP_PROXY_HOST, proxyHost); | sysprops.put(ProxySetup.HTTP_PROXY_HOST, proxyHost); | ||||
@@ -216,7 +216,7 @@ public class SetProxy extends Task { | |||||
//socks | //socks | ||||
if (socksProxyHost != null) { | if (socksProxyHost != null) { | ||||
settingsChanged = true; | settingsChanged = true; | ||||
if (socksProxyHost.length() != 0) { | |||||
if (!socksProxyHost.isEmpty()) { | |||||
enablingProxy = true; | enablingProxy = true; | ||||
sysprops.put(ProxySetup.SOCKS_PROXY_HOST, socksProxyHost); | sysprops.put(ProxySetup.SOCKS_PROXY_HOST, socksProxyHost); | ||||
sysprops.put(ProxySetup.SOCKS_PROXY_PORT, Integer.toString(socksProxyPort)); | sysprops.put(ProxySetup.SOCKS_PROXY_PORT, Integer.toString(socksProxyPort)); | ||||
@@ -243,7 +243,7 @@ public class Pvcs extends Task { | |||||
commandLine.clearArgs(); | commandLine.clearArgs(); | ||||
commandLine.setExecutable(getExecutable(GET_EXE)); | commandLine.setExecutable(getExecutable(GET_EXE)); | ||||
if (getConfig() != null && getConfig().length() > 0) { | |||||
if (getConfig() != null && !getConfig().isEmpty()) { | |||||
commandLine.createArgument().setValue("-c" + getConfig()); | commandLine.createArgument().setValue("-c" + getConfig()); | ||||
} | } | ||||
@@ -182,8 +182,8 @@ public class SplashTask extends Task { | |||||
sp.setProxyPassword(password); | sp.setProxyPassword(password); | ||||
sp.applyWebProxySettings(); | 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); | log("Using proxied Connection", Project.MSG_DEBUG); | ||||
System.getProperties().put("http.proxySet", "true"); | System.getProperties().put("http.proxySet", "true"); | ||||
@@ -191,7 +191,7 @@ public class SplashTask extends Task { | |||||
URL url = new URL(imgurl); | URL url = new URL(imgurl); | ||||
conn = url.openConnection(); | conn = url.openConnection(); | ||||
if (user != null && user.length() > 0) { | |||||
if (user != null && !user.isEmpty()) { | |||||
// converted from sun internal classes to | // converted from sun internal classes to | ||||
// new Base64Converter | // new Base64Converter | ||||
// utility class extracted from Get task | // utility class extracted from Get task | ||||
@@ -85,7 +85,7 @@ public class SSHSession extends SSHBase { | |||||
*/ | */ | ||||
public void setLocaltunnels(final String tunnels) { | public void setLocaltunnels(final String tunnels) { | ||||
for (String tunnelSpec : tunnels.split(", ")) { | for (String tunnelSpec : tunnels.split(", ")) { | ||||
if (tunnelSpec.length() > 0) { | |||||
if (!tunnelSpec.isEmpty()) { | |||||
final String[] spec = tunnelSpec.split(":", 3); | final String[] spec = tunnelSpec.split(":", 3); | ||||
final int lport = Integer.parseInt(spec[0]); | final int lport = Integer.parseInt(spec[0]); | ||||
final String rhost = spec[1]; | final String rhost = spec[1]; | ||||
@@ -107,7 +107,7 @@ public class SSHSession extends SSHBase { | |||||
*/ | */ | ||||
public void setRemotetunnels(final String tunnels) { | public void setRemotetunnels(final String tunnels) { | ||||
for (String tunnelSpec : tunnels.split(", ")) { | for (String tunnelSpec : tunnels.split(", ")) { | ||||
if (tunnelSpec.length() > 0) { | |||||
if (!tunnelSpec.isEmpty()) { | |||||
final String[] spec = tunnelSpec.split(":", 3); | final String[] spec = tunnelSpec.split(":", 3); | ||||
final int rport = Integer.parseInt(spec[0]); | final int rport = Integer.parseInt(spec[0]); | ||||
final String lhost = spec[1]; | final String lhost = spec[1]; | ||||
@@ -417,7 +417,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants { | |||||
*/ | */ | ||||
protected String getLabel() { | protected String getLabel() { | ||||
String shortLabel = ""; | String shortLabel = ""; | ||||
if (label != null && label.length() > 0) { | |||||
if (label != null && !label.isEmpty()) { | |||||
shortLabel = FLAG_LABEL + getShortLabel(); | shortLabel = FLAG_LABEL + getShortLabel(); | ||||
} | } | ||||
return shortLabel; | return shortLabel; | ||||
@@ -95,7 +95,7 @@ public final class RmicAdapterFactory { | |||||
Path classpath) | Path classpath) | ||||
throws BuildException { | throws BuildException { | ||||
//handle default specially by choosing the sun or kaffe compiler | //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()) { | if (KaffeRmic.isAvailable()) { | ||||
rmicType = KaffeRmic.COMPILER_NAME; | rmicType = KaffeRmic.COMPILER_NAME; | ||||
} else if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) { | } else if (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) { | ||||
@@ -256,7 +256,7 @@ public abstract class ArchiveScanner extends DirectoryScanner { | |||||
*/ | */ | ||||
public boolean match(String path) { | public boolean match(String path) { | ||||
String vpath = path; | String vpath = path; | ||||
if (path.length() > 0) { | |||||
if (!path.isEmpty()) { | |||||
vpath = path.replace('/', File.separatorChar). | vpath = path.replace('/', File.separatorChar). | ||||
replace('\\', File.separatorChar); | replace('\\', File.separatorChar); | ||||
if (vpath.charAt(0) == File.separatorChar) { | if (vpath.charAt(0) == File.separatorChar) { | ||||
@@ -183,8 +183,7 @@ public class Commandline implements Cloneable { | |||||
* @return an array of strings. | * @return an array of strings. | ||||
*/ | */ | ||||
public String[] getParts() { | 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; | return parts; | ||||
} | } | ||||
String[] fullParts = new String[parts.length]; | String[] fullParts = new String[parts.length]; | ||||
@@ -327,7 +326,7 @@ public class Commandline implements Cloneable { | |||||
* @since Ant 1.9.7 | * @since Ant 1.9.7 | ||||
*/ | */ | ||||
public void setExecutable(String executable, boolean translateFileSeparator) { | public void setExecutable(String executable, boolean translateFileSeparator) { | ||||
if (executable == null || executable.length() == 0) { | |||||
if (executable == null || executable.isEmpty()) { | |||||
return; | return; | ||||
} | } | ||||
this.executable = translateFileSeparator | this.executable = translateFileSeparator | ||||
@@ -468,7 +467,7 @@ public class Commandline implements Cloneable { | |||||
* An empty or null toProcess parameter results in a zero sized array. | * An empty or null toProcess parameter results in a zero sized array. | ||||
*/ | */ | ||||
public static String[] translateCommandline(String toProcess) { | public static String[] translateCommandline(String toProcess) { | ||||
if (toProcess == null || toProcess.length() == 0) { | |||||
if (toProcess == null || toProcess.isEmpty()) { | |||||
//no command? no string | //no command? no string | ||||
return new String[0]; | return new String[0]; | ||||
} | } | ||||
@@ -756,8 +756,8 @@ public class CommandlineJava implements Cloneable { | |||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
*/ | */ | ||||
public boolean haveClasspath() { | 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(); | |||||
} | } | ||||
/** | /** | ||||
@@ -283,7 +283,7 @@ public class FilterSet extends DataType implements Cloneable { | |||||
if (isReference()) { | if (isReference()) { | ||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
} | } | ||||
if (startOfToken == null || "".equals(startOfToken)) { | |||||
if (startOfToken == null || startOfToken.isEmpty()) { | |||||
throw new BuildException("beginToken must not be empty"); | throw new BuildException("beginToken must not be empty"); | ||||
} | } | ||||
this.startOfToken = startOfToken; | this.startOfToken = startOfToken; | ||||
@@ -310,7 +310,7 @@ public class FilterSet extends DataType implements Cloneable { | |||||
if (isReference()) { | if (isReference()) { | ||||
throw tooManyAttributes(); | throw tooManyAttributes(); | ||||
} | } | ||||
if (endOfToken == null || "".equals(endOfToken)) { | |||||
if (endOfToken == null || endOfToken.isEmpty()) { | |||||
throw new BuildException("endToken must not be empty"); | throw new BuildException("endToken must not be empty"); | ||||
} | } | ||||
this.endOfToken = endOfToken; | this.endOfToken = endOfToken; | ||||
@@ -79,9 +79,8 @@ public class MultiRootFileSet extends AbstractFileSet | |||||
if (isReference()) { | if (isReference()) { | ||||
throw tooManyAttributes(); | 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)); | baseDirs.add(getProject().resolveFile(d)); | ||||
} | } | ||||
} | } | ||||
@@ -56,7 +56,7 @@ public class ExtendSelector extends BaseSelector { | |||||
* Instantiates the identified custom selector class. | * Instantiates the identified custom selector class. | ||||
*/ | */ | ||||
public void selectorCreate() { | public void selectorCreate() { | ||||
if (classname != null && classname.length() > 0) { | |||||
if (classname != null && !classname.isEmpty()) { | |||||
try { | try { | ||||
Class<?> c; | Class<?> c; | ||||
if (classpath == null) { | if (classpath == null) { | ||||
@@ -64,9 +64,8 @@ public class TokenizedPath { | |||||
* @param child the child, must not contain the file separator | * @param child the child, must not contain the file separator | ||||
*/ | */ | ||||
public TokenizedPath(TokenizedPath parent, String child) { | 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; | path = parent.path + File.separatorChar + child; | ||||
} else { | } else { | ||||
path = parent.path + child; | path = parent.path + child; | ||||
@@ -96,7 +96,7 @@ public class Service extends ProjectComponent { | |||||
"type attribute must be set for service element", | "type attribute must be set for service element", | ||||
getLocation()); | getLocation()); | ||||
} | } | ||||
if (type.length() == 0) { | |||||
if (type.isEmpty()) { | |||||
throw new BuildException( | throw new BuildException( | ||||
"Invalid empty type classname", getLocation()); | "Invalid empty type classname", getLocation()); | ||||
} | } | ||||
@@ -248,7 +248,7 @@ public class DOMElementWriter { | |||||
out.write("<?"); | out.write("<?"); | ||||
out.write(child.getNodeName()); | out.write(child.getNodeName()); | ||||
String data = child.getNodeValue(); | String data = child.getNodeValue(); | ||||
if (data != null && data.length() > 0) { | |||||
if (data != null && !data.isEmpty()) { | |||||
out.write(' '); | out.write(' '); | ||||
out.write(data); | out.write(data); | ||||
} | } | ||||
@@ -398,7 +398,7 @@ public class DOMElementWriter { | |||||
if (namespacePolicy.qualifyElements) { | if (namespacePolicy.qualifyElements) { | ||||
String uri = getNamespaceURI(element); | String uri = getNamespaceURI(element); | ||||
String prefix = nsPrefixMap.get(uri); | String prefix = nsPrefixMap.get(uri); | ||||
if (prefix != null && !"".equals(prefix)) { | |||||
if (prefix != null && !prefix.isEmpty()) { | |||||
out.write(prefix); | out.write(prefix); | ||||
out.write(":"); | out.write(":"); | ||||
} | } | ||||
@@ -60,7 +60,7 @@ public class DeweyDecimal implements Comparable<DeweyDecimal> { | |||||
for (int i = 0; i < components.length; i++) { | for (int i = 0; i < components.length; i++) { | ||||
final String component = tokenizer.nextToken(); | final String component = tokenizer.nextToken(); | ||||
if (component.length() == 0) { | |||||
if (component.isEmpty()) { | |||||
throw new NumberFormatException("Empty component in string"); | throw new NumberFormatException("Empty component in string"); | ||||
} | } | ||||
@@ -634,7 +634,7 @@ public class FileUtils { | |||||
* @since Ant 1.7 | * @since Ant 1.7 | ||||
*/ | */ | ||||
public static boolean isContextRelativePath(String filename) { | public static boolean isContextRelativePath(String filename) { | ||||
if (!(ON_DOS || ON_NETWARE) || filename.length() == 0) { | |||||
if (!(ON_DOS || ON_NETWARE) || filename.isEmpty()) { | |||||
return false; | return false; | ||||
} | } | ||||
char sep = File.separatorChar; | char sep = File.separatorChar; | ||||
@@ -658,10 +658,10 @@ public class FileUtils { | |||||
* @since Ant 1.6.3 | * @since Ant 1.6.3 | ||||
*/ | */ | ||||
public static boolean isAbsolutePath(String filename) { | public static boolean isAbsolutePath(String filename) { | ||||
int len = filename.length(); | |||||
if (len == 0) { | |||||
if (filename.isEmpty()) { | |||||
return false; | return false; | ||||
} | } | ||||
int len = filename.length(); | |||||
char sep = File.separatorChar; | char sep = File.separatorChar; | ||||
filename = filename.replace('/', sep).replace('\\', sep); | filename = filename.replace('/', sep).replace('\\', sep); | ||||
char c = filename.charAt(0); | char c = filename.charAt(0); | ||||
@@ -353,7 +353,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
LogicalLine line; | LogicalLine line; | ||||
if (comment) { | if (comment) { | ||||
line = new Comment(logicalLineBuffer.toString()); | line = new Comment(logicalLineBuffer.toString()); | ||||
} else if (logicalLineBuffer.toString().trim().length() == 0) { | |||||
} else if (logicalLineBuffer.toString().trim().isEmpty()) { | |||||
line = new Blank(); | line = new Blank(); | ||||
} else { | } else { | ||||
line = new Pair(logicalLineBuffer.toString()); | line = new Pair(logicalLineBuffer.toString()); | ||||
@@ -657,7 +657,7 @@ public class ResourceUtils { | |||||
lineTokenizer.setIncludeDelims(true); | lineTokenizer.setIncludeDelims(true); | ||||
String line = lineTokenizer.getToken(in); | String line = lineTokenizer.getToken(in); | ||||
while (line != null) { | while (line != null) { | ||||
if (line.length() == 0) { | |||||
if (line.isEmpty()) { | |||||
// this should not happen, because the lines are | // this should not happen, because the lines are | ||||
// returned with the end of line delimiter | // returned with the end of line delimiter | ||||
out.newLine(); | out.newLine(); | ||||
@@ -995,7 +995,7 @@ public class TarEntry implements TarConstants { | |||||
if (isDirectory() && !name.endsWith("/")) { | if (isDirectory() && !name.endsWith("/")) { | ||||
name += "/"; | name += "/"; | ||||
} | } | ||||
if (prefix.length() > 0) { | |||||
if (!prefix.isEmpty()) { | |||||
name = prefix + "/" + name; | name = prefix + "/" + name; | ||||
} | } | ||||
} | } | ||||
@@ -288,7 +288,7 @@ public class TarOutputStream extends FilterOutputStream { | |||||
TarConstants.LF_GNUTYPE_LONGNAME, "file name"); | TarConstants.LF_GNUTYPE_LONGNAME, "file name"); | ||||
final String linkName = entry.getLinkName(); | final String linkName = entry.getLinkName(); | ||||
boolean paxHeaderContainsLinkPath = linkName != null && linkName.length() > 0 | |||||
boolean paxHeaderContainsLinkPath = linkName != null && !linkName.isEmpty() | |||||
&& handleLongName(entry, linkName, paxHeaders, "linkpath", | && handleLongName(entry, linkName, paxHeaders, "linkpath", | ||||
TarConstants.LF_GNUTYPE_LONGLINK, "link name"); | TarConstants.LF_GNUTYPE_LONGLINK, "link name"); | ||||
@@ -241,7 +241,7 @@ public class AsiExtraField implements ZipExtraField, UnixStat, Cloneable { | |||||
* @since 1.1 | * @since 1.1 | ||||
*/ | */ | ||||
public boolean isLink() { | public boolean isLink() { | ||||
return getLinkedFile().length() != 0; | |||||
return !getLinkedFile().isEmpty(); | |||||
} | } | ||||
/** | /** | ||||
@@ -265,7 +265,7 @@ public class TokenFilterTest { | |||||
public static class Capitalize implements TokenFilter.Filter { | public static class Capitalize implements TokenFilter.Filter { | ||||
public String filter(String token) { | public String filter(String token) { | ||||
if (token.length() == 0) { | |||||
if (token.isEmpty()) { | |||||
return token; | return token; | ||||
} | } | ||||
return token.substring(0, 1).toUpperCase() + token.substring(1); | return token.substring(0, 1).toUpperCase() + token.substring(1); | ||||
@@ -65,7 +65,7 @@ public class LocatorTest { | |||||
* @param enabled is the test enabled? | * @param enabled is the test enabled? | ||||
*/ | */ | ||||
private void assertResolved(String uri, String expectedResult, String result, boolean enabled) { | private void assertResolved(String uri, String expectedResult, String result, boolean enabled) { | ||||
if (enabled && expectedResult != null && expectedResult.length() > 0) { | |||||
if (enabled && expectedResult != null && !expectedResult.isEmpty()) { | |||||
assertEquals("Expected " + uri + " to resolve to \n" + expectedResult + "\n but got\n" | assertEquals("Expected " + uri + " to resolve to \n" + expectedResult + "\n but got\n" | ||||
+ result + "\n", expectedResult, result); | + result + "\n", expectedResult, result); | ||||
} | } | ||||
@@ -302,7 +302,7 @@ public class CopyTest { | |||||
try (BufferedReader reader = new BufferedReader(new FileReader(srcFile))) { | try (BufferedReader reader = new BufferedReader(new FileReader(srcFile))) { | ||||
originalContent = FileUtils.readFully(reader); | originalContent = FileUtils.readFully(reader); | ||||
} | } | ||||
assertTrue("Content missing in file " + srcFile, originalContent != null && originalContent.length() > 0); | |||||
assertTrue("Content missing in file " + srcFile, originalContent != null && !originalContent.isEmpty()); | |||||
// run the copy tests | // run the copy tests | ||||
buildRule.executeTarget("testSelfCopy"); | buildRule.executeTarget("testSelfCopy"); | ||||
@@ -54,7 +54,7 @@ public class DemuxOutputTask extends Task { | |||||
protected void handleOutput(String line) { | protected void handleOutput(String line) { | ||||
line = line.trim(); | line = line.trim(); | ||||
if (line.length() != 0 && !line.equals(randomOutValue)) { | |||||
if (!line.isEmpty() && !line.equals(randomOutValue)) { | |||||
String message = "Received = [" + line + "], expected = [" | String message = "Received = [" + line + "], expected = [" | ||||
+ randomOutValue + "]"; | + randomOutValue + "]"; | ||||
throw new BuildException(message); | throw new BuildException(message); | ||||
@@ -64,7 +64,7 @@ public class DemuxOutputTask extends Task { | |||||
protected void handleErrorOutput(String line) { | protected void handleErrorOutput(String line) { | ||||
line = line.trim(); | line = line.trim(); | ||||
if (line.length() != 0 && !line.equals(randomErrValue)) { | |||||
if (!line.isEmpty() && !line.equals(randomErrValue)) { | |||||
String message = "Received = [" + line + "], expected = [" | String message = "Received = [" + line + "], expected = [" | ||||
+ randomErrValue + "]"; | + randomErrValue + "]"; | ||||
throw new BuildException(message); | throw new BuildException(message); | ||||
@@ -87,7 +87,7 @@ public class ExecuteWatchdogTest { | |||||
int retcode = p.waitFor(); | int retcode = p.waitFor(); | ||||
if (retcode != 0) { | if (retcode != 0) { | ||||
String err = getErrorOutput(p); | String err = getErrorOutput(p); | ||||
if (err.length() > 0) { | |||||
if (!err.isEmpty()) { | |||||
System.err.println("ERROR:"); | System.err.println("ERROR:"); | ||||
System.err.println(err); | System.err.println(err); | ||||
} | } | ||||
@@ -608,7 +608,7 @@ public class FileUtilsTest { | |||||
*/ | */ | ||||
private void assertEqualsIgnoreDriveCase(String s1, String s2) { | private void assertEqualsIgnoreDriveCase(String s1, String s2) { | ||||
if ((Os.isFamily("dos") || Os.isFamily("netware")) | if ((Os.isFamily("dos") || Os.isFamily("netware")) | ||||
&& s1.length() > 0 && s2.length() > 0) { | |||||
&& !s1.isEmpty() && !s2.isEmpty()) { | |||||
StringBuilder sb1 = new StringBuilder(s1); | StringBuilder sb1 = new StringBuilder(s1); | ||||
StringBuilder sb2 = new StringBuilder(s2); | StringBuilder sb2 = new StringBuilder(s2); | ||||
sb1.setCharAt(0, Character.toUpperCase(s1.charAt(0))); | sb1.setCharAt(0, Character.toUpperCase(s1.charAt(0))); | ||||