| @@ -145,36 +145,37 @@ public class Target implements TaskContainer { | |||
| public static List<String> parseDepends(String depends, | |||
| String targetName, | |||
| String attributeName) { | |||
| if (depends.isEmpty()) { | |||
| return new ArrayList<>(); | |||
| } | |||
| List<String> list = new ArrayList<>(); | |||
| if (depends.length() > 0) { | |||
| StringTokenizer tok = | |||
| new StringTokenizer(depends, ",", true); | |||
| while (tok.hasMoreTokens()) { | |||
| String token = tok.nextToken().trim(); | |||
| // Make sure the dependency is not empty string | |||
| if ("".equals(token) || ",".equals(token)) { | |||
| StringTokenizer tok = new StringTokenizer(depends, ",", true); | |||
| while (tok.hasMoreTokens()) { | |||
| String token = tok.nextToken().trim(); | |||
| // Make sure the dependency is not empty string | |||
| if (token.isEmpty() || ",".equals(token)) { | |||
| throw new BuildException("Syntax Error: " | |||
| + attributeName | |||
| + " attribute of target \"" | |||
| + targetName | |||
| + "\" contains an empty string."); | |||
| } | |||
| list.add(token); | |||
| // Make sure that depends attribute does not | |||
| // end in a , | |||
| if (tok.hasMoreTokens()) { | |||
| token = tok.nextToken(); | |||
| if (!tok.hasMoreTokens() || !",".equals(token)) { | |||
| throw new BuildException("Syntax Error: " | |||
| + attributeName | |||
| + " attribute of target \"" | |||
| + " attribute for target \"" | |||
| + targetName | |||
| + "\" contains an empty string."); | |||
| } | |||
| list.add(token); | |||
| // Make sure that depends attribute does not | |||
| // end in a , | |||
| if (tok.hasMoreTokens()) { | |||
| token = tok.nextToken(); | |||
| if (!tok.hasMoreTokens() || !",".equals(token)) { | |||
| throw new BuildException("Syntax Error: " | |||
| + attributeName | |||
| + " attribute for target \"" | |||
| + targetName | |||
| + "\" ends with a \",\" " | |||
| + "character"); | |||
| } | |||
| + "\" ends with a \",\" " | |||
| + "character"); | |||
| } | |||
| } | |||
| } | |||
| @@ -52,44 +52,40 @@ public class DispatchUtils { | |||
| String mName = null; | |||
| try { | |||
| final String name = dispatchable.getActionParameterName(); | |||
| if (name != null && name.trim().length() > 0) { | |||
| mName = "get" + name.trim().substring(0, 1).toUpperCase(); | |||
| if (name.length() > 1) { | |||
| mName += name.substring(1); | |||
| } | |||
| final Class<? extends Dispatchable> c = dispatchable.getClass(); | |||
| final Method actionM = c.getMethod(mName); | |||
| if (actionM != null) { | |||
| final Object o = actionM.invoke(dispatchable, (Object[]) null); | |||
| if (o != null) { | |||
| final String s = o.toString().trim(); | |||
| if (s.length() > 0) { | |||
| methodName = s; | |||
| Method executeM = dispatchable.getClass().getMethod(methodName); | |||
| if (executeM == null) { | |||
| throw new BuildException( | |||
| "No public " + methodName + "() in " | |||
| + dispatchable.getClass()); | |||
| } | |||
| executeM.invoke(dispatchable, (Object[]) null); | |||
| if (task instanceof UnknownElement) { | |||
| ((UnknownElement) task).setRealThing(null); | |||
| } | |||
| } else { | |||
| throw new BuildException( | |||
| "Dispatchable Task attribute '" + name.trim() | |||
| + "' not set or value is empty."); | |||
| } | |||
| } else { | |||
| throw new BuildException( | |||
| "Dispatchable Task attribute '" + name.trim() | |||
| + "' not set or value is empty."); | |||
| } | |||
| } | |||
| } else { | |||
| if (name == null || name.trim().isEmpty()) { | |||
| throw new BuildException( | |||
| "Action Parameter Name must not be empty for Dispatchable Task."); | |||
| } | |||
| mName = "get" + name.trim().substring(0, 1).toUpperCase(); | |||
| if (name.length() > 1) { | |||
| mName += name.substring(1); | |||
| } | |||
| final Class<? extends Dispatchable> c = dispatchable.getClass(); | |||
| final Method actionM = c.getMethod(mName); | |||
| if (actionM != null) { | |||
| final Object o = actionM.invoke(dispatchable, (Object[]) null); | |||
| if (o == null) { | |||
| throw new BuildException( | |||
| "Dispatchable Task attribute '" + name.trim() | |||
| + "' not set or value is empty."); | |||
| } | |||
| methodName = o.toString().trim(); | |||
| if (methodName.isEmpty()) { | |||
| throw new BuildException( | |||
| "Dispatchable Task attribute '" + name.trim() | |||
| + "' not set or value is empty."); | |||
| } | |||
| Method executeM = dispatchable.getClass().getMethod(methodName); | |||
| if (executeM == null) { | |||
| throw new BuildException( | |||
| "No public " + methodName + "() in " | |||
| + dispatchable.getClass()); | |||
| } | |||
| executeM.invoke(dispatchable, (Object[]) null); | |||
| if (task instanceof UnknownElement) { | |||
| ((UnknownElement) task).setRealThing(null); | |||
| } | |||
| } | |||
| } catch (NoSuchMethodException nsme) { | |||
| throw new BuildException("No public " + mName + "() in " + task.getClass()); | |||
| } | |||
| @@ -383,19 +383,15 @@ public class Ant extends Task { | |||
| String thisAntFile = getProject().getProperty(MagicNames.ANT_FILE); | |||
| // Are we trying to call the target in which we are defined (or | |||
| // the build file if this is a top level task)? | |||
| if (thisAntFile != null | |||
| && file.equals(getProject().resolveFile(thisAntFile)) | |||
| && getOwningTarget() != null) { | |||
| if ("".equals(getOwningTarget().getName())) { | |||
| if ("antcall".equals(getTaskName())) { | |||
| throw new BuildException( | |||
| "antcall must not be used at the top level."); | |||
| } | |||
| if (thisAntFile != null && file.equals(getProject().resolveFile(thisAntFile)) | |||
| && getOwningTarget() != null && getOwningTarget().getName().isEmpty()) { | |||
| if ("antcall".equals(getTaskName())) { | |||
| throw new BuildException( | |||
| "antcall must not be used at the top level."); | |||
| } | |||
| throw new BuildException( | |||
| "%s task at the top level must not invoke its own build file.", | |||
| getTaskName()); | |||
| } | |||
| } | |||
| try { | |||
| @@ -452,11 +452,11 @@ public class Commandline implements Cloneable { | |||
| } | |||
| // path containing one or more elements | |||
| final StringBuilder result = new StringBuilder(); | |||
| for (int i = 0; i < line.length; i++) { | |||
| if (i > 0) { | |||
| for (String l : line) { | |||
| if (result.length() > 0) { | |||
| result.append(' '); | |||
| } | |||
| result.append(quoteArgument(line[i])); | |||
| result.append(quoteArgument(l)); | |||
| } | |||
| return result.toString(); | |||
| } | |||
| @@ -508,7 +508,7 @@ public class Commandline implements Cloneable { | |||
| } else if ("\"".equals(nextTok)) { | |||
| state = inDoubleQuote; | |||
| } else if (" ".equals(nextTok)) { | |||
| if (lastTokenHasBeenQuoted || current.length() != 0) { | |||
| if (lastTokenHasBeenQuoted || current.length() > 0) { | |||
| result.add(current.toString()); | |||
| current.setLength(0); | |||
| } | |||
| @@ -519,7 +519,7 @@ public class Commandline implements Cloneable { | |||
| break; | |||
| } | |||
| } | |||
| if (lastTokenHasBeenQuoted || current.length() != 0) { | |||
| if (lastTokenHasBeenQuoted || current.length() > 0) { | |||
| result.add(current.toString()); | |||
| } | |||
| if (state == inQuote || state == inDoubleQuote) { | |||
| @@ -502,7 +502,7 @@ public class PropertySet extends DataType implements ResourceCollection { | |||
| StringBuilder b = new StringBuilder(); | |||
| TreeMap<String, Object> sorted = new TreeMap<>(getPropertyMap()); | |||
| for (Entry<String, Object> e : sorted.entrySet()) { | |||
| if (b.length() != 0) { | |||
| if (b.length() > 0) { | |||
| b.append(", "); | |||
| } | |||
| b.append(e.getKey()); | |||
| @@ -710,7 +710,7 @@ public class FileUtils { | |||
| String pathComponent = tokenizer.nextToken(); | |||
| pathComponent = pathComponent.replace('/', File.separatorChar); | |||
| pathComponent = pathComponent.replace('\\', File.separatorChar); | |||
| if (path.length() != 0) { | |||
| if (path.length() > 0) { | |||
| path.append(File.pathSeparatorChar); | |||
| } | |||
| path.append(pathComponent); | |||
| @@ -176,8 +176,10 @@ public class ResourceUtils { | |||
| final Union result = new Union(); | |||
| for (final Resource sr : source) { | |||
| String srName = sr.getName(); | |||
| srName = srName == null | |||
| ? srName : srName.replace('/', File.separatorChar); | |||
| if (srName != null) { | |||
| srName = srName.replace('/', File.separatorChar); | |||
| } | |||
| String[] targetnames = null; | |||
| try { | |||
| @@ -653,7 +655,6 @@ public class ResourceUtils { | |||
| final LineTokenizer lineTokenizer = new LineTokenizer(); | |||
| lineTokenizer.setIncludeDelims(true); | |||
| String newline = null; | |||
| String line = lineTokenizer.getToken(in); | |||
| while (line != null) { | |||
| if (line.length() == 0) { | |||
| @@ -661,8 +662,7 @@ public class ResourceUtils { | |||
| // returned with the end of line delimiter | |||
| out.newLine(); | |||
| } else { | |||
| newline = filters.replaceTokens(line); | |||
| out.write(newline); | |||
| out.write(filters.replaceTokens(line)); | |||
| } | |||
| line = lineTokenizer.getToken(in); | |||
| } | |||
| @@ -104,10 +104,10 @@ public class StringTokenizer extends ProjectComponent implements Tokenizer { | |||
| if (inToken) { | |||
| if (isDelim) { | |||
| if (delimsAreTokens) { | |||
| if (word.length() == 0) { | |||
| word.append(c); | |||
| } else { | |||
| if (word.length() > 0) { | |||
| pushed = ch; | |||
| } else { | |||
| word.append(c); | |||
| } | |||
| break; | |||
| } | |||
| @@ -1148,20 +1148,16 @@ public class ZipOutputStream extends FilterOutputStream { | |||
| } | |||
| String comm = ze.getComment(); | |||
| if (comm != null && !"".equals(comm)) { | |||
| boolean commentEncodable = zipEncoding.canEncode(comm); | |||
| if (createUnicodeExtraFields == UnicodeExtraFieldPolicy.ALWAYS | |||
| || !commentEncodable) { | |||
| ByteBuffer commentB = getEntryEncoding(ze).encode(comm); | |||
| ze.addExtraField(new UnicodeCommentExtraField(comm, | |||
| commentB.array(), | |||
| commentB.arrayOffset(), | |||
| commentB.limit() | |||
| - commentB.position()) | |||
| ); | |||
| } | |||
| if (comm == null || comm.isEmpty()) { | |||
| return; | |||
| } | |||
| if (createUnicodeExtraFields == UnicodeExtraFieldPolicy.ALWAYS | |||
| || !zipEncoding.canEncode(comm)) { | |||
| ByteBuffer commentB = getEntryEncoding(ze).encode(comm); | |||
| ze.addExtraField(new UnicodeCommentExtraField(comm, | |||
| commentB.array(), commentB.arrayOffset(), | |||
| commentB.limit() - commentB.position())); | |||
| } | |||
| } | |||
| @@ -79,7 +79,9 @@ public class Find extends Task { | |||
| // create list | |||
| StringBuilder list = new StringBuilder(); | |||
| for (String file : foundFiles) { | |||
| if (list.length() > 0) list.append(delimiter); | |||
| if (list.length() > 0) { | |||
| list.append(delimiter); | |||
| } | |||
| list.append(file); | |||
| } | |||
| rv = list.toString(); | |||
| @@ -84,7 +84,9 @@ public class Find extends Task { | |||
| // create list | |||
| StringBuilder list = new StringBuilder(); | |||
| for (String file : foundFiles) { | |||
| if (list.length() > 0) list.append(delimiter); | |||
| if (list.length() > 0) { | |||
| list.append(delimiter); | |||
| } | |||
| list.append(file); | |||
| } | |||
| rv = list.toString(); | |||